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
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 usedstop_reason= emptyemptylockedexact matchinstant_drop_V0.075 ± 7.5e-110.075lockedunder 0.01 % of the tolerance usedenergy_chemical_Wh10.8 ± 1.1e-0810.8lockedunder 0.01 % of the tolerance usedheat_J810 ± 8.1e-07810lockedunder 0.01 % of the tolerance usedenergy_delivered_Wh10.575 ± 1.1e-0810.575lockedunder 0.01 % of the tolerance usedcell_voltage_end_V2.925 ± 2.9e-092.925lockedunder 0.01 % of the tolerance usedr0002time 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 usedsoc_end0.3125 ± 3.1e-100.3125lockedunder 0.01 % of the tolerance usedstop_reason= cutoff_lowcutoff_lowlockedexact matchcell_voltage_end_V3.3 ± 3.3e-093.3lockedunder 0.01 % of the tolerance usedr0003RC 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 usedinstant_drop_V0.1 ± 1e-100.1lockedunder 0.01 % of the tolerance usedrc1_voltage_rest_start_V0.04 ± 4e-110.04lockedunder 0.01 % of the tolerance usedrc1_rest_fraction0.367879 ± 3.7e-100.367879lockedunder 0.01 % of the tolerance usedcell_voltage_end_V3.68528 ± 3.7e-093.68528lockedunder 0.01 % of the tolerance usedruntime_s420 ± 4.2e-10420lockedunder 0.01 % of the tolerance usedr0004energy 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 usedrc_stored_J0.789256 ± 7.9e-100.789256lockedunder 0.01 % of the tolerance usedenergy_chemical_Wh0.205556 ± 2.1e-100.205556lockedunder 0.01 % of the tolerance usedenergy_delivered_Wh0.198219 ± 2e-100.198219lockedunder 0.01 % of the tolerance usedcell_voltage_min_V3.56027 ± 3.6e-093.56027lockedunder 0.01 % of the tolerance usedenergy_balance_residual_J0 ± 1e-062.06556e-11lockedunder 0.01 % of the tolerance usedr0005zero 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 usedocv_end_V3.444 ± 3.4e-123.444lockedunder 0.01 % of the tolerance usedsoc_end0.37 ± 3.7e-130.37lockedunder 0.01 % of the tolerance usedheat_J0 ± 1e-120lockedunder 0.01 % of the tolerance usedr0006round-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 usedenergy_discharged_Wh10.875 ± 1.1e-0810.875lockedunder 0.01 % of the tolerance usedenergy_charged_Wh11.325 ± 1.1e-0811.325lockedunder 0.01 % of the tolerance usedsoc_end1 ± 1e-121lockedunder 0.01 % of the tolerance usedr0007pack 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 usedpack_voltage_start_V12.6 ± 1.3e-0812.6lockedunder 0.01 % of the tolerance usedpack_voltage_end_V8.775 ± 8.8e-098.775lockedunder 0.01 % of the tolerance usedenergy_delivered_Wh63.45 ± 6.3e-0863.45lockedunder 0.01 % of the tolerance usedpack_r0_ohm0.075 ± 7.5e-110.075lockedunder 0.01 % of the tolerance usedpack_capacity_Ah6 ± 6e-126lockedunder 0.01 % of the tolerance used
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
| Name | Unit | Default | Meaning |
|---|---|---|---|
ocv_soc | 1 | [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_V | V | [3.0, 4.2] | Open-circuit voltage of one cell at each ocv_soc point (taken from the cell's own measured curve). |
capacity_Ah | A h | 3.0 | Capacity of one cell. |
r0_ohm | ohm | 0.0 | Series (instant) resistance of one cell. |
r1_ohm | ohm | 0.0 | First RC pair resistance; 0 leaves the pair out. |
c1_F | F | 0.0 | First RC pair capacitance; 0 leaves the pair out. |
r2_ohm | ohm | 0.0 | Second RC pair resistance; 0 leaves the pair out. |
c2_F | F | 0.0 | Second RC pair capacitance; 0 leaves the pair out. |
soc0 | 1 | 1.0 | Starting state of charge (fraction). RC voltages start at 0 (cell at rest). |
profile | constant | constant: 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_A | A | 1.0 | Pack current, positive on discharge; each cell carries current_A / n_parallel. |
duration_s | s | Length 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_s | s | 10.0 | Length of each pulse (profile pulse). |
pulse_count | 1 | 1 | Number of pulses (profile pulse). |
rest_s | s | 0.0 | Rest at zero current after each pulse, or after each half of a round trip. |
charge_current_A | A | Pack charge current of a round trip (magnitude). Left out: the same as current_A. | |
profile_csv | Current 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_file | The same profile as a csv file (time_s,current_A). | ||
v_min_V | V | Discharge cut-off, per cell. The run stops (a round trip turns to charge) where the terminal voltage first reaches it. | |
v_max_V | V | Charge cut-off, per cell. | |
n_series | 1 | 1 | Cells in series (identical cells, no balancing, no wiring resistance). |
n_parallel | 1 | 1 | Cells in parallel. |
dt_s | s | Spacing of the trace in out/trace.csv. Left out: about 2000 rows. The model is exact at any spacing. |
Readings
| Name | Unit | Meaning |
|---|---|---|
profile | ||
completed | true when the profile ran to its end (or an open-ended constant run reached its natural end). | |
stop_reason | profile_end, empty, full, cutoff_low, cutoff_high. | |
runtime_s | s | |
runtime_h | h | |
time_to_cutoff_s | s | First time the terminal voltage reached v_min_V (discharge) or v_max_V (charge); null if never. |
soc_start | 1 | |
soc_end | 1 | |
soc_min | 1 | |
ocv_start_V | V | |
ocv_end_V | V | |
instant_drop_V | V | Cell voltage step when the first current is applied from rest: I R0. |
cell_voltage_end_V | V | Cell terminal voltage at the end, under the last current applied. |
cell_voltage_min_V | V | |
cell_voltage_max_V | V | |
pack_voltage_start_V | V | Open-circuit pack voltage at the start. |
pack_voltage_end_V | V | |
pack_voltage_min_V | V | |
pack_voltage_max_V | V | |
cell_current_peak_A | A | |
tau1_s | s | |
tau2_s | s | |
rc1_voltage_end_V | V | |
rc2_voltage_end_V | V | |
final_rest_s | s | |
rc1_voltage_rest_start_V | V | First RC voltage when the final rest began. |
rc1_rest_fraction | 1 | First RC voltage at the end over its value at the start of the final rest: exp(-rest/tau1). |
rc2_rest_fraction | 1 | |
charge_out_Ah | A h | |
charge_in_Ah | A h | |
energy_discharged_Wh | W h | |
energy_charged_Wh | W h | |
energy_delivered_Wh | W h | Net energy out of the pack terminals (discharged minus charged). |
energy_chemical_Wh | W h | Net energy drawn from the open-circuit source: delivered + heat + energy still stored in the RC capacitors. |
heat_Wh | W h | |
heat_J | J | |
heat_r0_J | J | |
heat_rc_J | J | |
rc_stored_J | J | |
energy_balance_residual_J | J | chemical - delivered - heat - stored: zero up to rounding. |
heat_mean_W | W | |
heat_peak_W | W | |
round_trip_efficiency | 1 | Energy discharged over energy charged, when the round trip returned to its starting state of charge. |
n_cells | 1 | |
pack_capacity_Ah | A h | |
pack_energy_full_Wh | W h | Open-circuit energy from full to empty: capacity times the integral of OCV over state of charge. |
pack_r0_ohm | ohm | |
pack_dc_resistance_ohm | ohm | (R0 + R1 + R2) n_series / n_parallel. |
trace_rows | 1 | |
steps | 1 | |
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.