A returned PyBaMM Experiment solution can contain fewer steps than requested, or use cycle boundaries and output sampling differently from what you intended. The tests below examine five such cases in PyBaMM 26.5.0, mostly with Chen2020 and OKane2022; section 1 also uses Ramadass2004 and section 5 compares eight sets.
PyBaMM battery modelling series · Silent failures, measured (part 2 of 8): Previous: 18 PyBaMM 26.5 Parameter Sets: Capacity, Temperature and Model Compatibility · Next: PyBaMM Thermal Models, Measured: Zero Heating, Missing Entropy and a Cold Start at 25 °C · Series hub: Data pipeline (5) + Silent failures, measured (8) · RSS feed.
1. A step given in amps stops at 24 hours
Here is the same slow discharge on a 5 A·h cell, written two ways:
| Step string | Ran for | End voltage | Discharged | Steps completed |
|---|---|---|---|---|
Discharge at C/50 until 2.5 V |
51.5 h | 2.500 V | 5.149 A·h | 1 / 1 |
Discharge at 0.1 A until 2.5 V |
24.0 h | 3.778 V | 2.400 A·h | 1 / 1 |
the 0.1 A step, then Rest, then Charge |
24.0 h | 3.778 V | 2.400 A·h | 1 / 3 |
Discharge at 0.1 A for 60 hours or until 2.5 V |
51.5 h | 2.500 V | 5.149 A·h | 1 / 1 |
0.1 A is C/50 on this cell. Written as a C-rate, the step runs to the voltage cut-off. Written in amps, it stops at exactly 24 hours with less than half the charge removed, and in a multi-step protocol every following step is skipped. sim.solve() returns normally. sol.termination reads 'final time', which is indistinguishable from a step that was supposed to end on time.
The source explains why. When a step has no duration, PyBaMM assigns a default one:
- C-rate steps:
2 / Chours, twice the time to pass the nominal capacity. - Constant non-C-rate steps such as current in amps, power and voltage holds: 24 hours. Drive-cycle data and custom steps can define a different duration.
This dates from PR #4239, the fix for issue #4224 (a 0.01C discharge stopping at 24 hours). The fix changed only C-rate steps to 2/C hours; the accompanying unit test still asserts that a current step defaults to 24 * 3600 seconds. So this is intended behaviour. Anyone who switches from C-rates to amps (for instance to avoid the nominal-capacity error described in the parameter-set article) walks straight into it at low currents.
The C-rate default is not bulletproof either, because it is computed from nominal capacity. Ramadass2004 holds 1.775× its nominal capacity, so a C/20 discharge takes about 35.5 of its 40 allotted hours. The nominal discharge is 20 hours, which leaves a 20-hour margin, and this cell uses 15.5 of those hours (78%) before anything else goes wrong.
Correction, 2026-11-07: this paragraph used to say that 89% of the safety margin was gone. 89% is the share of the 40 allotted hours; the margin is the 20 hours above nominal, so the figure is 78%. The run itself gives 35.49 h and 1.775 A·h on both 26.5.0 and 26.10.1.1.
The warning, and how to lose it
PyBaMM logs the truncation. It writes “Experiment is infeasible: default duration (86400 seconds) was reached…” through its own logger, at WARNING level. The message is not a Python warning and not an exception. Batch scripts commonly quiet PyBaMM’s chatter with:
pybamm.set_logging_level("ERROR")
With that line the truncation still happens and the message disappears entirely. I checked both levels: at WARNING the message appears, at ERROR nothing does.
Fix: give every slow or open-ended step an explicit ceiling, such as "Discharge at 0.1 A for 60 hours or until 2.5 V", and verify completion (section 6) instead of trusting that no exception means no problem.
2. A flat list is not a cycle
These two experiments contain exactly the same steps:
steps = ("Discharge at 1C until 2.5 V", "Rest for 30 minutes",
"Charge at C/2 until 4.2 V", "Hold at 4.2 V until C/50")
pybamm.Experiment([steps] * 12) # a list of tuples: 12 cycles
pybamm.Experiment(list(steps) * 12) # a flat list: 48 "cycles"
A tuple groups its steps into one cycle. A flat list makes every string its own cycle. On OKane2022 with an SEI model, I ran both for 12 real cycles and fitted capacity against cycle number:
| Written as | Summary rows | Lithium inventory lost | Fitted fade per “cycle” |
|---|---|---|---|
| tuple | 12 | 0.0234% | −0.1357 mAh / cycle |
| flat list | 48 | 0.0234% | −0.0343 mAh / cycle |
Both protocols execute the same sequence and have the same recorded lithium inventory loss. The flat list labels each of four steps as a cycle, changing the fitted slope from −0.1357 to −0.0343 mAh per reported cycle. A linear extrapolation using those slopes would differ by about 4×; the 12-cycle test itself does not validate an 80%-capacity lifetime prediction. Capacity [A.h] is an eSOH state-derived quantity, so summary rows at different step endpoints also need consistent interpretation.
I fell into this one myself while testing section 5: a four-step protocol printed only one step per “cycle”, because I had written it as a list.
Fix: wrap each cycle’s steps in a tuple, and check len(sol.cycles) against the number of cycles you meant.
3. save_at_cycles leaves holes
For long runs, sim.solve(save_at_cycles=5) keeps full solutions only for some cycles. With 12 cycles, the saved ones were 1, 5, 10 and 12 (the first and last are always kept). The rest are None but stay in the list:
len(sol.cycles) -> 12
sol.cycles[3]["Voltage [V]"] -> TypeError: 'NoneType' object is not subscriptable
Any loop that plots every cycle breaks here. The per-cycle summary variables are unaffected (all 12 rows are present), so use sol.summary_variables for per-cycle metrics and filter the full solutions with [c for c in sol.cycles if c is not None].
4. Output sampling and derived-quantity accuracy
In this IDAKLU test, changing period changed the returned sampling without changing the reported final capacity or event time:
| period | Output points | Discharged | End time | Solve time |
|---|---|---|---|---|
| 1 second | 3596 | 4.991870 A·h | 3594.146 s | 0.36 s |
| 1 minute (default) | 61 | 4.991870 A·h | 3594.146 s | 0.25 s |
| 1 hour | 2 | 4.991870 A·h | 3594.146 s | 0.24 s |
Capacity agrees to six decimal places in this comparison. IDAKLU uses adaptive internal steps and locates the voltage event within its numerical tolerances. period controls requested output sampling here; its interaction with internal integration can depend on the solver and step implementation.
Sampling resolution matters when deriving quantities from the returned points. For a constant-current, constant-voltage charge, current decays during the hold:
| period | Points | PyBaMM’s charge | np.trapezoid on output |
Error |
|---|---|---|---|---|
| 10 seconds | 987 | 5.1217 A·h | 5.1219 A·h | +0.00% |
| 1 minute | 167 | 5.1217 A·h | 5.1221 A·h | +0.01% |
| 10 minutes | 19 | 5.1217 A·h | 5.1377 A·h | +0.31% |
| 30 minutes | 8 | 5.1217 A·h | 5.2798 A·h | +3.09% |
Use the appropriate cumulative variable when available. Discharge capacity [A.h] is a signed current integral, while Throughput capacity [A.h] integrates absolute current. Take endpoint differences over the intended interval. When integrating or differentiating sampled output yourself, refine period until the derived quantity converges.
5. initial_soc=1.0 is not 4.2 V
initial_soc is measured against the parameter set’s own voltage window. I read the open-circuit voltage one second into a rest at initial_soc=1.0:
| Set | Upper cut-off | Voltage at initial_soc=1.0 |
|---|---|---|
| Chen2020, OKane2022, Mohtat2020, Ai2020, Ecker2015 | 4.2 V | 4.2000 V |
| Marquis2019 | 4.1 V | 4.1000 V |
| Prada2013 (LFP) | 3.6 V | 3.6000 V |
| ORegan2022 | 4.4 V | 4.4000 V |
In the recorded comparison, ORegan2022 started 0.2 V above the 4.2 V sets and its first loaded discharge voltage was 4.2466 V. Charging steps ended at 4.2000 V within the reported precision, so the high initial voltage came from initialization. For comparisons across parameter sets, specify the initial equilibrium voltage or SOC convention and stoichiometry mapping, as appropriate to the experiment; SOC alone does not establish equal starting voltage. Also check the experiment cutoffs against each set’s window (see the parameter-set article).
6. Check that the experiment actually finished
Cycle and step counts provide an initial structural check. The historical helper below checks those counts; it does not certify that each requested event or experiment-level termination was reached:
def experiment_completed(sol, experiment):
"""(ok, message): False when PyBaMM stopped the experiment early."""
n_run = len(sol.cycles)
n_expected = len(experiment.cycles)
steps_done = len(sol.cycles[-1].steps) # the last cycle is always saved
steps_expected = experiment.cycle_lengths[n_run - 1]
if steps_done < steps_expected:
return False, f"cycle {n_run} stopped after step {steps_done} of {steps_expected}"
if n_run < n_expected and not experiment.termination:
return False, f"only {n_run} of {n_expected} cycles ran"
return True, f"{n_run} of {n_expected} cycles ran, last cycle complete"
normal, 3 cycles (True, '3 of 3 cycles ran, last cycle complete')
0.1 A step, truncated (False, 'cycle 1 stopped after step 1 of 3')
12 cycles with save_at_cycles=5 (True, '12 of 12 cycles ran, last cycle complete')
truncated in cycle 2 of 3 (False, 'cycle 2 stopped after step 1 of 3')
capacity termination set (True, '3 of 3 cycles ran, last cycle complete')
Limits of this helper: a one-step discharge truncated at its default duration still has 1 of 1 cycles and steps, so the helper returns True. Any configured termination= also bypasses its short-cycle check without proving that condition was reached. Inspect each step’s termination and the logger/callback record, distinguish intended stops from default-duration and unexpected events, and verify the actual experiment-level threshold. Handle empty solutions, skipped steps and continuation offsets explicitly. The flat-list convention likewise requires comparison with the intended physical cycles.
7. How this was measured
- PyBaMM 26.5.0, Python 3.13, Apple M3, default
IDAKLUSolver. - Sections 1, 3, 4 and 6 use Chen2020; section 2 uses OKane2022 with
{"SEI": "solvent-diffusion limited"}; section 5 uses the sets named. - Section 1 discharges, including the Ramadass2004 C/20 figure, start from
initial_soc=1. From PyBaMM’s default initial state the C/50 discharge runs 50.96 h and delivers 5.096 A·h, and the 0.1 A step with no time limit still stops at 24 hours, at 3.768 V. - Default durations are read from
pybamm/experiment/step/base_step.pyandsteps.pyin this version, and from the diff of PR #4239. - Logger behaviour was checked by attaching a handler to
pybamm.loggerand running the truncated case at WARNING and at ERROR.
References
- PyBaMM issue #4224: simulations with pybamm.Experiment terminate after 24 h
- PyBaMM PR #4239: default duration of 2/C for C-rate steps, and the infeasibility warning
- PyBaMM: simulating long experiments
- PyBaMM Experiment API
Related: PyBaMM’s built-in parameter sets, measured, on nominal capacity and voltage windows; PyBaMM solver convergence failures, for when the experiment does raise; and the aging dataset pipeline, where a truncated cycle becomes a mislabelled training sample. For experiments run at a set temperature, PyBaMM thermal model pitfalls covers why a lumped cell can start warm. If you schedule cycles with start_time, read the start_time box in PyBaMM SEI and lithium plating pitfalls: in PyBaMM 24.5 to 26.9.0.0, repeated identical steps silently lose their scheduled rests (fixed in 26.10.0.0).
A tool I built
Validate your cell model on independent data
VoltSift is an online workspace I built. Upload three CSV files (a fitting record, an independent validation record and an open-circuit voltage curve), and it fits a cell model, checks voltage error and coverage on the held-out record, and produces a report. The standard workflow supports single NMC cells at 25°C and SOC 20%–100%. Register and verify your email to get one free analysis, available for seven days.
Visit VoltSift · Prepare the three CSV files · How to read the validation results
