Lemonergy · Studio block

SOC adaptive EKF with capacity input

One-state extended Kalman observer with a calibrated fraction-to-OCV table, Joseph covariance update and explicit measurement validity. Innovation matching adapts bounded voltage-noise variance.

Implementation ID
battery-soc-adaptive-ekf-variable-capacity
Reviewed
2026-10-27

Behavior

Predicts a charge or energy fraction from signed throughput and corrects it using terminal voltage and a calibrated fraction-to-OCV table. Scalar Joseph covariance updates preserve nonnegative variance. Invalid voltage measurements skip correction; flat OCV regions report limited observability. Adaptive variants bound an innovation-based voltage-noise estimate.

Interface

SOC adaptive EKF 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.SOC adaptive EKF with capacityinputStudio blockcurrentvoltagevalidresetcapacityfractionvarianceinnovationgainnoisestatus
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
currentinputASigned battery current; scalar.
voltageinputVMeasured voltage; scalar.
validinputtrue / falseVoltage measurement valid; scalar.
resetinputtrue / falseReset; scalar.
capacityinputAhCharge capacity (Ah); scalar.
fractionoutput1 (fraction)State of charge; scalar.
varianceoutput1Posterior fraction variance; scalar.
innovationoutputVVoltage innovation; scalar.
gainoutput1Correction gain; scalar.
noiseoutput1Voltage-noise variance; scalar.
statusoutput1Status (0 prediction, 1 correction, 2 unobservable, 3 clipped); 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.6Initial SOC (0–1). This is an editable model input; the default belongs to the synthetic worked example.
Initial fraction variance
initialVariance
10.04Initial fraction variance. This is an editable model input; the default belongs to the synthetic worked example.
Process variance rate (fraction²/s)
processNoise
fraction²/s0Process variance rate (fraction²/s). This is an editable model input; the default belongs to the synthetic worked example.
Voltage measurement variance (V²)
measurementNoise
V²0.01Voltage measurement variance (V²). This is an editable model input; the default belongs to the synthetic worked example.
Series resistance (Ω)
resistanceOhm
Ω0.05Series resistance (Ω). This is an editable model input; the default belongs to the synthetic worked example.
Noise adaptation weight (0–1)
adaptationRate
0–10.1Noise adaptation weight (0–1). This is an editable model input; the default belongs to the synthetic worked example.
Minimum voltage variance (V²)
minimumNoise
V²1e-06Minimum voltage variance (V²). This is an editable model input; the default belongs to the synthetic worked example.
Maximum voltage variance (V²)
maximumNoise
V²1Maximum voltage variance (V²). This is an editable model input; the default belongs to the synthetic worked example.
Open-circuit voltage table [SOC fraction, V]
ocvTable
See field order[[0, 3], [1, 4]]Open-circuit voltage table [SOC fraction, V]. Rows are ordered coordinate/value pairs; the first column must be strictly increasing.

Equations and rules

  • innovation = Vmeasured - Vpredicted
  • K = Ppredicted*H / (H^2*Ppredicted + R)
  • fraction = predictedFraction + K*innovation
  • P = (1-K*H)^2*Ppredicted + K^2*R

Worked example

SOC adaptive EKF with capacity input worked example

Use the defaults below with Signed battery current = 0 A, Measured voltage = 3.8 V, Voltage measurement valid = 1 true / false, Reset = 0 true / false, Charge capacity (Ah) = 2 Ah. At 0 s, State of charge is 0.76 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.761 (fraction)1e-08
Posterior fraction variance
variance
00.00811e-08
Voltage innovation
innovation
00.2V1e-08
Correction gain
gain
00.811e-08

Explore the recorded outputs

SOC adaptive EKF with capacity input recorded example

SOC adaptive EKF with capacity input / State of charge
SOC adaptive EKF with capacity input / State of charge against timeRecorded synthetic simulation values. Time in seconds; output in 1 (fraction).0.758494100.76395290.250.76941170.50.77487050.750.780329311 (fraction)Time (s)
SOC adaptive EKF with capacity input / State of charge: 0.76 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

SOC adaptive EKF with capacity input worked example

One-state extended Kalman observer with a calibrated fraction-to-OCV table, Joseph covariance update and explicit measurement validity. Innovation matching adapts bounded voltage-noise variance.

  1. SOC adaptive EKF with capacity input: Predicts a charge or energy fraction from signed throughput and corrects it using terminal voltage and a calibrated fraction-to-OCV table. Scalar Joseph covariance updates preserve nonnegative variance. Invalid voltage measurements skip correction; flat OCV regions report limited observability. Adaptive variants bound an innovation-based voltage-noise estimate.
    • Use the parameter values in the block reference.
    • Implementation tested locally; public release pending.
Open Studio example after release

Connected concepts

Limits and interpretation

  • One-state extended Kalman observers, without an unscented transform, RC polarization states or automatic cell identification. SOE requires its own energy-fraction-to-OCV calibration. Synthetic filter settings are not accuracy guarantees.
  • 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 3. State and parameter estimation

    Gregory L. Plett · Journal of Power Sources · 2004

    Technical reference · Model-based battery state-of-charge and parameter estimation with extended Kalman filtering, including uncertainty and model dependence.

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