Invntr
Source

All instruments

battery_ecm

Battery cell equivalent-circuit (Thevenin) model: open-circuit voltage against state of charge given as points, series resistance R0 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 R0 = 0.075 V; linear OCV 3.0-4.2 V gives chemical energy Q x mean OCV = 10.8 Wh, heat I^2 R0 t = 810 J, delivered 10.575 Wh (rel 1e-9, exact piecewise solution)passed

    runtime_s7200 ± 7.2e-067200lockedunder 0.01 % of the tolerance used
    stop_reason= emptyemptylockedexact match
    instant_drop_V0.075 ± 7.5e-110.075lockedunder 0.01 % of the tolerance used
    energy_chemical_Wh10.8 ± 1.1e-0810.8lockedunder 0.01 % of the tolerance used
    heat_J810 ± 8.1e-07810lockedunder 0.01 % of the tolerance used
    energy_delivered_Wh10.575 ± 1.1e-0810.575lockedunder 0.01 % of the tolerance used
    cell_voltage_end_V2.925 ± 2.9e-092.925lockedunder 0.01 % of the tolerance used
  2. r0002time to cut-off, closed form for linear OCV and R0 only: 4.2 - 1.2 I t/Q - I R0 = 3.3 V gives t = 0.825 x 10800 / 1.8 = 4950 s, soc_end = 0.3125 (rel 1e-9; cut-off found by bisection to machine precision)passed

    time_to_cutoff_s4950 ± 5e-064950lockedunder 0.01 % of the tolerance used
    soc_end0.3125 ± 3.1e-100.3125lockedunder 0.01 % of the tolerance used
    stop_reason= cutoff_lowcutoff_lowlockedexact match
    cell_voltage_end_V3.3 ± 3.3e-093.3lockedunder 0.01 % of the tolerance used
  3. r0003RC relaxation after a pulse (first-order RC closed form): 2 A for 400 s into R1 = 0.02 ohm, C1 = 1000 F (tau 20 s) charges v1 to I R1 (1 - e^-20) = 0.0399999999175 V; after one time constant of rest v1/v1(0) = e^-1 = 0.367879 (36.79 %), terminal = 3.7 - v1 e^-1 = 3.6852848224 V (rel 1e-9)passed

    tau1_s20 ± 2e-1120lockedunder 0.01 % of the tolerance used
    instant_drop_V0.1 ± 1e-100.1lockedunder 0.01 % of the tolerance used
    rc1_voltage_rest_start_V0.04 ± 4e-110.04lockedunder 0.01 % of the tolerance used
    rc1_rest_fraction0.367879 ± 3.7e-100.367879lockedunder 0.01 % of the tolerance used
    cell_voltage_end_V3.68528 ± 3.7e-093.68528lockedunder 0.01 % of the tolerance used
    runtime_s420 ± 4.2e-10420lockedunder 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, R0 0.05, R1 0.02, C1 1000 F: heat = I^2 R0 T + I^2 R1 [T - 2 tau (1-e^-5) + tau/2 (1-e^-10)] = 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^-5) (rel 1e-9)passed

    heat_J25.6215 ± 2.6e-0825.6215lockedunder 0.01 % of the tolerance used
    rc_stored_J0.789256 ± 7.9e-100.789256lockedunder 0.01 % of the tolerance used
    energy_chemical_Wh0.205556 ± 2.1e-100.205556lockedunder 0.01 % of the tolerance used
    energy_delivered_Wh0.198219 ± 2e-100.198219lockedunder 0.01 % of the tolerance used
    cell_voltage_min_V3.56027 ± 3.6e-093.56027lockedunder 0.01 % of the tolerance used
    energy_balance_residual_J0 ± 1e-062.06556e-11lockedunder 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 1e-12)passed

    cell_voltage_end_V3.444 ± 3.4e-123.444lockedunder 0.01 % of the tolerance used
    ocv_end_V3.444 ± 3.4e-123.444lockedunder 0.01 % of the tolerance used
    soc_end0.37 ± 3.7e-130.37lockedunder 0.01 % of the tolerance used
    heat_J0 ± 1e-120lockedunder 0.01 % of the tolerance used
  6. r0006round-trip efficiency, closed form for flat OCV and R0 only: (U - I R0)/(U + I R0) = 3.625/3.775 = 0.96026490066; discharged Q(U - I R0) = 10.875 Wh, charged Q(U + I R0) = 11.325 Wh (rel 1e-9)passed

    round_trip_efficiency0.960265 ± 9.6e-100.960265lockedunder 0.01 % of the tolerance used
    energy_discharged_Wh10.875 ± 1.1e-0810.875lockedunder 0.01 % of the tolerance used
    energy_charged_Wh11.325 ± 1.1e-0811.325lockedunder 0.01 % of the tolerance used
    soc_end1 ± 1e-121lockedunder 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 x 4.2 = 12.6 V, end voltage 3 x 2.925 = 8.775 V, delivered 6 x 10.575 = 63.45 Wh, pack R0 = 0.05 x 3/2 = 0.075 ohm (rel 1e-9)passed

    runtime_s7200 ± 7.2e-067200lockedunder 0.01 % of the tolerance used
    pack_voltage_start_V12.6 ± 1.3e-0812.6lockedunder 0.01 % of the tolerance used
    pack_voltage_end_V8.775 ± 8.8e-098.775lockedunder 0.01 % of the tolerance used
    energy_delivered_Wh63.45 ± 6.3e-0863.45lockedunder 0.01 % of the tolerance used
    pack_r0_ohm0.075 ± 7.5e-110.075lockedunder 0.01 % of the tolerance used
    pack_capacity_Ah6 ± 6e-126lockedunder 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 R0.
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/tau1).
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(R0 + R1 + R2) 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