Invntr
Source

All instruments

battery_ecm

Battery cell equivalent-circuit (Thevenin) model: open-circuit voltage against state of charge given as points, series resistance R₀ and up to two RC pairs, capacity.

Over a constant, pulse, csv or discharge-charge round-trip current profile it gives terminal voltage, state of charge, heat and energy, time to a voltage cut-off and round-trip efficiency, for one cell or an n_series x n_parallel pack.

Solved exactly piecewise (no numerical integration); trace in out/trace.csv.

Field
Electrochemistry and batteries
Version
0.1.0
Runs as
Compiled (Rust)
Typical run
0.05 s

Compiled from source: run sh packs/install.sh once before admitting it.

Known answers it must pass

Admission replaybattery_ecm 0.1.0 · files b88dd2245baa…7e50
  1. r0001constant current from full, no cut-off (Coulomb counting closed form): runtime = Q/I = 3 Ah / 1.5 A = 7200 s; instant drop I R₀ = 0.075 V; linear OCV 3.0-4.2 V gives chemical energy Q x mean OCV = 10.8 Wh, heat I² R₀ t = 810 J, delivered 10.575 Wh (rel 10⁻⁹, exact piecewise solution)passed

    runtime_s7200 ± 7.2 × 10⁻⁶7200lockedunder 0.01 % of the tolerance used
    stop_reason= emptyemptylockedexact match
    instant_drop_V0.075 ± 7.5 × 10⁻¹¹0.075lockedunder 0.01 % of the tolerance used
    energy_chemical_Wh10.8 ± 1.1 × 10⁻⁸10.8lockedunder 0.01 % of the tolerance used
    heat_J810 ± 8.1 × 10⁻⁷810lockedunder 0.01 % of the tolerance used
    energy_delivered_Wh10.575 ± 1.1 × 10⁻⁸10.575lockedunder 0.01 % of the tolerance used
    cell_voltage_end_V2.925 ± 2.9 × 10⁻⁹2.925lockedunder 0.01 % of the tolerance used
  2. r0002time to cut-off, closed form for linear OCV and R₀ only: 4.2 - 1.2 I t/Q - I R₀ = 3.3 V gives t = 0.825 × 10800 / 1.8 = 4950 s, soc_end = 0.3125 (rel 10⁻⁹; cut-off found by bisection to machine precision)passed

    time_to_cutoff_s4950 ± 5 × 10⁻⁶4950lockedunder 0.01 % of the tolerance used
    soc_end0.3125 ± 3.1 × 10⁻¹⁰0.3125lockedunder 0.01 % of the tolerance used
    stop_reason= cutoff_lowcutoff_lowlockedexact match
    cell_voltage_end_V3.3 ± 3.3 × 10⁻⁹3.3lockedunder 0.01 % of the tolerance used
  3. r0003RC relaxation after a pulse (first-order RC closed form): 2 A for 400 s into R₁ = 0.02 Ω, C₁ = 1000 F (τ 20 s) charges v₁ to I R₁ (1 - e⁻²⁰) = 0.0399999999175 V; after one time constant of rest v₁/v₁(0) = e⁻¹ = 0.367879 (36.79 %), terminal = 3.7 - v₁ e⁻¹ = 3.6852848224 V (rel 10⁻⁹)passed

    tau1_s20 ± 2 × 10⁻¹¹20lockedunder 0.01 % of the tolerance used
    instant_drop_V0.1 ± 10⁻¹⁰0.1lockedunder 0.01 % of the tolerance used
    rc1_voltage_rest_start_V0.04 ± 4 × 10⁻¹¹0.04lockedunder 0.01 % of the tolerance used
    rc1_rest_fraction0.367879 ± 3.7 × 10⁻¹⁰0.367879lockedunder 0.01 % of the tolerance used
    cell_voltage_end_V3.68528 ± 3.7 × 10⁻⁹3.68528lockedunder 0.01 % of the tolerance used
    runtime_s420 ± 4.2 × 10⁻¹⁰420lockedunder 0.01 % of the tolerance used
  4. r0004energy balance with an RC pair (closed-form integrals): flat OCV 3.7 V, 2 A for 100 s, R₀ 0.05, R₁ 0.02, C₁ 1000 F: heat = I² R₀ T + I² R₁ [T - 2 τ (1-e⁻⁵) + τ/2 (1-e⁻¹⁰)] = 25.6215251 J, stored C v^2/2 = 0.7892556 J, delivered = 740 J - heat - stored = 713.5892193 J = 0.1982192276 Wh, min voltage 3.7 - 0.1 - 0.04 (1-e⁻⁵) (rel 10⁻⁹)passed

    heat_J25.6215 ± 2.6 × 10⁻⁸25.6215lockedunder 0.01 % of the tolerance used
    rc_stored_J0.789256 ± 7.9 × 10⁻¹⁰0.789256lockedunder 0.01 % of the tolerance used
    energy_chemical_Wh0.205556 ± 2.1 × 10⁻¹⁰0.205556lockedunder 0.01 % of the tolerance used
    energy_delivered_Wh0.198219 ± 2 × 10⁻¹⁰0.198219lockedunder 0.01 % of the tolerance used
    cell_voltage_min_V3.56027 ± 3.6 × 10⁻⁹3.56027lockedunder 0.01 % of the tolerance used
    energy_balance_residual_J0 ± 10⁻⁶2.06556 × 10⁻¹¹lockedunder 0.01 % of the tolerance used
  5. r0005zero current (definition of open-circuit voltage): terminal voltage = OCV at soc0 = 0.37 on the line 3.0 + 1.2 soc through three points = 3.444 V, no heat, soc unchanged (rel 10⁻¹²)passed

    cell_voltage_end_V3.444 ± 3.4 × 10⁻¹²3.444lockedunder 0.01 % of the tolerance used
    ocv_end_V3.444 ± 3.4 × 10⁻¹²3.444lockedunder 0.01 % of the tolerance used
    soc_end0.37 ± 3.7 × 10⁻¹³0.37lockedunder 0.01 % of the tolerance used
    heat_J0 ± 10⁻¹²0lockedunder 0.01 % of the tolerance used
  6. r0006round-trip efficiency, closed form for flat OCV and R₀ only: (U - I R₀)/(U + I R₀) = 3.625/3.775 = 0.96026490066; discharged Q(U - I R₀) = 10.875 Wh, charged Q(U + I R₀) = 11.325 Wh (rel 10⁻⁹)passed

    round_trip_efficiency0.960265 ± 9.6 × 10⁻¹⁰0.960265lockedunder 0.01 % of the tolerance used
    energy_discharged_Wh10.875 ± 1.1 × 10⁻⁸10.875lockedunder 0.01 % of the tolerance used
    energy_charged_Wh11.325 ± 1.1 × 10⁻⁸11.325lockedunder 0.01 % of the tolerance used
    soc_end1 ± 10⁻¹²1lockedunder 0.01 % of the tolerance used
  7. r0007pack scaling (Kirchhoff): 3 series x 2 parallel at 3 A pack current = 1.5 A per cell: runtime Q/I = 7200 s, start voltage 3 × 4.2 = 12.6 V, end voltage 3 × 2.925 = 8.775 V, delivered 6 × 10.575 = 63.45 Wh, pack R₀ = 0.05 × 3/2 = 0.075 Ω (rel 10⁻⁹)passed

    runtime_s7200 ± 7.2 × 10⁻⁶7200lockedunder 0.01 % of the tolerance used
    pack_voltage_start_V12.6 ± 1.3 × 10⁻⁸12.6lockedunder 0.01 % of the tolerance used
    pack_voltage_end_V8.775 ± 8.8 × 10⁻⁹8.775lockedunder 0.01 % of the tolerance used
    energy_delivered_Wh63.45 ± 6.3 × 10⁻⁸63.45lockedunder 0.01 % of the tolerance used
    pack_r0_ohm0.075 ± 7.5 × 10⁻¹¹0.075lockedunder 0.01 % of the tolerance used
    pack_capacity_Ah6 ± 6 × 10⁻¹²6lockedunder 0.01 % of the tolerance used
7 of 7 cases passed · sandbox macos-seatbeltrecorded from the kernel in a fresh lab

Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.

Inputs

NameUnitDefaultMeaning
ocv_soc1[0, 1]State-of-charge points of the open-circuit-voltage curve, rising strictly from 0 to 1. The curve is straight between points.
ocv_VV[3.0, 4.2]Open-circuit voltage of one cell at each ocv_soc point (taken from the cell's own measured curve).
capacity_AhA h3.0Capacity of one cell.
r0_ohmohm0.0Series (instant) resistance of one cell.
r1_ohmohm0.0First RC pair resistance; 0 leaves the pair out.
c1_FF0.0First RC pair capacitance; 0 leaves the pair out.
r2_ohmohm0.0Second RC pair resistance; 0 leaves the pair out.
c2_FF0.0Second RC pair capacitance; 0 leaves the pair out.
soc011.0Starting state of charge (fraction). RC voltages start at 0 (cell at rest).
profileconstantconstant: current_A for duration_s (or until empty / cut-off). pulse: pulse_count pulses of current_A for pulse_on_s, each followed by rest_s at zero current. csv: rows time_s,current_A, each held until the next row. round_trip: discharge at current_A to empty or v_min_V (or for duration_s), rest_s, charge at charge_current_A back to soc0, rest_s.
current_AA1.0Pack current, positive on discharge; each cell carries current_A / n_parallel.
duration_ssLength of a constant profile, or of the discharge of a round trip. Left out: until the cell is empty, full or at a cut-off.
pulse_on_ss10.0Length of each pulse (profile pulse).
pulse_count11Number of pulses (profile pulse).
rest_ss0.0Rest at zero current after each pulse, or after each half of a round trip.
charge_current_AAPack charge current of a round trip (magnitude). Left out: the same as current_A.
profile_csvCurrent profile for profile csv: lines time_s,current_A (pack current, positive on discharge); a header line is allowed; the last row marks the end.
profile_fileThe same profile as a csv file (time_s,current_A).
v_min_VVDischarge cut-off, per cell. The run stops (a round trip turns to charge) where the terminal voltage first reaches it.
v_max_VVCharge cut-off, per cell.
n_series11Cells in series (identical cells, no balancing, no wiring resistance).
n_parallel11Cells in parallel.
dt_ssSpacing of the trace in out/trace.csv. Left out: about 2000 rows. The model is exact at any spacing.

Readings

NameUnitMeaning
profile
completedtrue when the profile ran to its end (or an open-ended constant run reached its natural end).
stop_reasonprofile_end, empty, full, cutoff_low, cutoff_high.
runtime_ss
runtime_hh
time_to_cutoff_ssFirst time the terminal voltage reached v_min_V (discharge) or v_max_V (charge); null if never.
soc_start1
soc_end1
soc_min1
ocv_start_VV
ocv_end_VV
instant_drop_VVCell voltage step when the first current is applied from rest: I R₀.
cell_voltage_end_VVCell terminal voltage at the end, under the last current applied.
cell_voltage_min_VV
cell_voltage_max_VV
pack_voltage_start_VVOpen-circuit pack voltage at the start.
pack_voltage_end_VV
pack_voltage_min_VV
pack_voltage_max_VV
cell_current_peak_AA
tau1_ss
tau2_ss
rc1_voltage_end_VV
rc2_voltage_end_VV
final_rest_ss
rc1_voltage_rest_start_VVFirst RC voltage when the final rest began.
rc1_rest_fraction1First RC voltage at the end over its value at the start of the final rest: exp(-rest/τ₁).
rc2_rest_fraction1
charge_out_AhA h
charge_in_AhA h
energy_discharged_WhW h
energy_charged_WhW h
energy_delivered_WhW hNet energy out of the pack terminals (discharged minus charged).
energy_chemical_WhW hNet energy drawn from the open-circuit source: delivered + heat + energy still stored in the RC capacitors.
heat_WhW h
heat_JJ
heat_r0_JJ
heat_rc_JJ
rc_stored_JJ
energy_balance_residual_JJchemical - delivered - heat - stored: zero up to rounding.
heat_mean_WW
heat_peak_WW
round_trip_efficiency1Energy discharged over energy charged, when the round trip returned to its starting state of charge.
n_cells1
pack_capacity_AhA h
pack_energy_full_WhW hOpen-circuit energy from full to empty: capacity times the integral of OCV over state of charge.
pack_r0_ohmohm
pack_dc_resistance_ohmohm(R₀ + R₁ + R₂) n_series / n_parallel.
trace_rows1
steps1
warnings
files

Try the call

Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.

Terminal
MCP call