Lemonergy · Studio block
Energy counter with capacity input
Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.
- Implementation ID
battery-variable-energy-counter- Reviewed
- 2026-10-27
Behavior
Integrates signed discharge current or power over elapsed sample time. Charge efficiency applies during charging. The initial sample has zero elapsed time. Variable-capacity variants preserve the current fraction when capacity changes and report the resulting amount revaluation separately. Reset restores the initial fraction without integrating that event.
Interface
| Name | Direction | Unit | Meaning |
|---|---|---|---|
rate | input | W | Signed battery power; scalar. |
reset | input | true / false | Reset; scalar. |
capacity | input | J | Energy capacity (J); scalar. |
fraction | output | 1 (fraction) | State of energy; scalar. |
throughput | output | J | Net throughput (J); scalar. |
revaluation | output | J | Capacity revaluation (J); scalar. |
boundary | output | J | Boundary amount (J); scalar. |
Parameters
Defaults are initial model values. Select values for your own model and operating conditions.
| Parameter | Unit | Default | Meaning and limits |
|---|---|---|---|
Sample interval (s)sampleTimeS | s | 1 | Positive sample interval. Initialization has zero elapsed time; subsequent accepted samples update memory. |
Energy capacity (J)capacity | J | 7200 | Energy capacity (J). This is an editable model input; the default belongs to the synthetic worked example. |
Initial SOE (0–1)initialFraction | 0–1 | 0.8 | Initial SOE (0–1). This is an editable model input; the default belongs to the synthetic worked example. |
Charging efficiency (0–1)chargeEfficiency | 0–1 | 1 | Charging efficiency (0–1). This is an editable model input; the default belongs to the synthetic worked example. |
Equations and rules
amount[k] = amount[k-1] - effectiveRate[k] * elapsedTimefraction = clamp(amount / capacity, 0, 1)charge capacity in coulombs = 3600 * capacityAh
Worked example
Energy counter with capacity input worked example
Use the defaults below with Signed battery power = 2 W, Reset = 0 true / false, Energy capacity (J) = 7200 J. At 0 s, State of energy is 0.8 1 (fraction). Additional checks are listed below.
Open Studio example after release →| Output | Time (s) | Expected value | Unit | Absolute tolerance |
|---|---|---|---|---|
State of energyfraction | 0 | 0.8 | 1 (fraction) | 1e-08 |
Net throughput (J)throughput | 0 | 0 | J | 0 |
State of energyfraction | 1 | 0.7997222222222222 | 1 (fraction) | 1e-08 |
Explore the recorded outputs
Energy counter with capacity input recorded example
Energy counter with capacity input / State of energy2 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.
Read the selected signal as a table
| Time (s) | Value |
|---|
Download the recorded samples (JSON) · Open this Studio example after release
Use in a workflow
Energy counter with capacity input worked example
Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.
- Energy counter with capacity input: Integrates signed discharge current or power over elapsed sample time. Charge efficiency applies during charging. The initial sample has zero elapsed time. Variable-capacity variants preserve the current fraction when capacity changes and report the resulting amount revaluation separately. Reset restores the initial fraction without integrating that event.
- Use the parameter values in the block reference.
- Implementation tested locally; public release pending.
Connected concepts
Limits and interpretation
- Current or power bias accumulates. Fraction clipping is reported as a boundary amount; it does not make the connected plant respect that boundary. Energy variants need capacity in joules.
- The example verifies numerical behavior for synthetic parameters. Cell characterization and validation for an intended use are separate tasks.
Scientific and mathematical references
These sources explain the scientific and mathematical background. The behavior, interface and limits above define the Lemonergy implementation; a citation does not imply every model option in the source is implemented.
- Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs: Part 2. Modeling and identification
Gregory L. Plett · Journal of Power Sources · 2004
Technical reference · Battery charge balance, open-circuit voltage, ohmic loss, polarization dynamics and model identification; parameters require cell-specific data.
Implementation sources
This reference follows the public interface and locally verified numerical checks for an upcoming release.
Contract: Lemonergy Studio public contract · Verification record: verification-2026-10-27
docs/glossary/native-block-verification.json
This implementation and its workflow uses (JSON) · Knowledge graph (JSON-LD)