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

Energy counter with capacity input interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Energy counter with capacity inputStudio blockrateresetcapacityfractionthroughputrevaluationboundary
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
rateinputWSigned battery power; scalar.
resetinputtrue / falseReset; scalar.
capacityinputJEnergy capacity (J); scalar.
fractionoutput1 (fraction)State of energy; scalar.
throughputoutputJNet throughput (J); scalar.
revaluationoutputJCapacity revaluation (J); scalar.
boundaryoutputJBoundary amount (J); scalar.

Parameters

Defaults are initial model values. Select values for your own model and operating conditions.

Configuration fields
ParameterUnitDefaultMeaning and limits
Sample interval (s)
sampleTimeS
s1Positive sample interval. Initialization has zero elapsed time; subsequent accepted samples update memory.
Energy capacity (J)
capacity
J7200Energy capacity (J). This is an editable model input; the default belongs to the synthetic worked example.
Initial SOE (0–1)
initialFraction
0–10.8Initial SOE (0–1). This is an editable model input; the default belongs to the synthetic worked example.
Charging efficiency (0–1)
chargeEfficiency
0–11Charging 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] * elapsedTime
  • fraction = 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 →
Numerical checks for the bundled synthetic example
OutputTime (s)Expected valueUnitAbsolute tolerance
State of energy
fraction
00.81 (fraction)1e-08
Net throughput (J)
throughput
00J0
State of energy
fraction
10.79972222222222221 (fraction)1e-08

Explore the recorded outputs

Energy counter with capacity input recorded example

Energy counter with capacity input / State of energy
Energy counter with capacity input / State of energy against timeRecorded synthetic simulation values. Time in seconds; output in 1 (fraction).0.799700.79978060.250.79986110.50.79994170.750.800022211 (fraction)Time (s)
Energy counter with capacity input / State of energy: 0.8 1 (fraction) at 0 s

2 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.

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.

  1. 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.
Open Studio example after release

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.

  1. 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)