Lemonergy · Studio block

Charge counter

Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.

Implementation ID
battery-charge-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

Charge counter interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Charge counterStudio blockrateresetfractionthroughputrevaluationboundary
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
rateinputASigned battery current; scalar.
resetinputtrue / falseReset; scalar.
fractionoutput1 (fraction)State of charge; scalar.
throughputoutputCNet throughput (C); scalar.
revaluationoutputCCapacity revaluation (C); scalar.
boundaryoutputCBoundary amount (C); 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.
Charge capacity (Ah)
capacity
Ah2Charge capacity (Ah). This is an editable model input; the default belongs to the synthetic worked example.
Initial SOC (0–1)
initialFraction
0–10.8Initial SOC (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

Charge counter worked example

Use the defaults below with Signed battery current = 2 A, Reset = 0 true / false. At 0 s, State of charge 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 charge
fraction
00.81 (fraction)1e-08
Net throughput (C)
throughput
00C0
State of charge
fraction
10.79972222222222221 (fraction)1e-08

Explore the recorded outputs

Charge counter recorded example

Charge counter / State of charge
Charge counter / State of charge against timeRecorded synthetic simulation values. Time in seconds; output in 1 (fraction).0.799700.79978060.250.79986110.50.79994170.750.800022211 (fraction)Time (s)
Charge counter / State of charge: 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

Charge counter worked example

Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.

  1. Charge counter: 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)