# isEnrgyBalanced

Logical flag for energy conservation

## Syntax

``flag=isEnrgyBalanced(PlantInfoObj)``

## Description

``` `flag=isEnrgyBalanced(PlantInfoObj)` returns logical `1` (`true`) if the system conserves energy. Otherwise, it returns logical `0` (`false`).```

## Input Arguments

collapse all

`autoblks.pwr.PlantInfo` object for the system that you want to analyze.

## Output Arguments

collapse all

Indicator of energy conservation, returned as a logical `1` (`true`) or `0` (`false`).

Data Types: `logical`

## Algorithms

To determine if the system conserves energy, the `isEnrgyBalanced` method checks the energy conservation at each time step.

`${E}_{Err}={\sum }^{\text{​}}{E}_{trans}+{\sum }^{\text{​}}{E}_{nottrans}-{\sum }^{\text{​}}{E}_{store}$`

Blocks change the input energy plus released stored energy to output energy plus stored energy. For example, a mapped engine block uses fuel (not transferred energy) to produce torque (transferred energy) and heat loss (not transferred energy). The total modified energy represents the average between the input fuel energy and the energy exiting the system (torque and heat loss). To calculate the total energy modified by the block, the method uses the integral of the average transferred, not transferred, and stored power.

`${E}_{total}=\frac{1}{2}{\left(\underset{0}{\overset{{t}_{end}}{\int }}\left({\sum }^{\text{​}}|{P}_{trans}|+{\sum }^{\text{​}}|{P}_{nottrans}|+{\sum }^{\text{​}}|{P}_{store}|\right)dt\right)|}_{t={t}_{end}}$`

If the energy conservation error is within an error tolerance, the method returns true. Specifically, if either condition is met, the method returns true.

Condition
`$\frac{|{E}_{Err}|}{{E}_{total}}`

or

`${E}_{total}`

The equations use these variables.

 EErr Energy conservation error Etotal Total energy modified by block EnrgyBalRelTol, EnrgyBalAbsTol Energy balance relative and absolute tolerance, respectively Ptrans, Etrans Transferred power and energy, respectively Pnottrans, Enottrans Not transferred power and energy, respectively Pstore, Estore Stored power and energy, respectively Pinput, Poutput Input and output power logged by Power Accounting Bus Creator block

## Version History

Introduced in R2019a