Claim Check / Sample report

Sample. No client was involved.

PyBaMM BasicDFN: does the model conserve lithium when the transference number varies?

Versions
v26.4.1, main at 258fdc8, PR #5524 head
Inputs
One discharge and charge protocol, one parameter set, seven mesh and tolerance settings
Verdict
Fails: the model gains about 2.44% of its lithium over the cycle

How this sample was built

This is the structure a client receives, filled in from a real, public, self-initiated investigation. Every number below is computed at build time from the public reproduction package at commit adaa877 (summary.csv and controls.json, SHA-256 matched to the package’s own manifest).

1. The question, as agreed

The model conserves lithium: the total in the electrolyte and particles stays constant over a cycle, up to solver tolerance.

Settled by: an independent lithium count that uses the library’s mesh and solution but none of its averaging or total-lithium diagnostics. The claim fails if the count drifts by more than solver tolerance; the cause is reported separately.

2. Verdict

Fails. With a concentration-dependent transference number, the model’s lithium inventory grows: the largest drift is between 2.4407% and 2.4417% of the initial inventory in all 21 runs, and every run ends with more lithium than it started with. The cause is a missing term in the equation, not the numerical method. Two control models hold: their largest drift in any run is 1.3e-13 of the inventory.

3. What was run

Froze three revisions: release v26.4.1 (d9e5afb), main (258fdc8), and the head of then-open pull request #5524 (719763b).

Counted lithium from the mesh, the parameters and the raw concentrations, without using the library’s own totals. A second, loop-based implementation was checked against the first on every run.

Ran 84 jobs: four model cases × three revisions × seven mesh and tolerance settings. A constant-transference model and the full DFN model served as controls.

4. Proof the check works

Before the count was trusted, it was run on synthetic cases with known answers. Five planted defects were each caught, and two correct cases balanced:

Case given to the counterLargest imbalance reportedReading
closed transfer1.8e-15 molbalances, as it should
boundary and source conserving3.3e-15 molbalances, as it should
altered inventory0.020 molcaught
wrong boundary sign0.600 molcaught
omitted source0.200 molcaught
wrong volume factor0.005 molcaught
synthetic imbalance0.010 molcaught

A second implementation of the count, written separately with explicit loops, agrees with the first to 3.6e-15 mol on these synthetic arrays.

5. Evidence

Mesh (cells)Time toleranceCase under testConstant-transference controlFull DFN control
20 × 201e-06+2.4417%1.8e-141.5e-14
20 × 201e-08+2.4417%1.9e-141.5e-14
20 × 201e-10+2.4417%1.8e-141.5e-14
20 × 801e-10+2.4417%2.9e-141.3e-13
40 × 401e-10+2.4409%2.8e-142.6e-14
80 × 201e-10+2.4407%2.0e-142.1e-14
80 × 801e-10+2.4407%2.7e-141.3e-13

Largest drift in the lithium inventory as a fraction of the initial inventory, worst of three revisions. For the case under test the drift is a gain.

The measured rate matched the rate predicted from the missing transference-gradient term to within 1.2 × 10⁻¹⁷ mol/s in all 21 runs. The equation, not the discretisation, is the cause. A PyBaMM contributor confirmed the missing term on the original thread.

6. What this does not show

One library, two model families, one protocol (rest, 1C discharge, rest, 1C charge, rest) and one parameter set (O’Regan 2022). The full DFN model conserved lithium; nothing here is said against it. No physical battery was measured.

7. Next actions

  • Add the missing transference-gradient term (done upstream in PR #5747, released in 26.9.0.0).
  • Add the independent lithium count as a test that runs on every release, so a future change cannot reintroduce the drift.
  • The finite-volume question raised in #5700 is a separate claim and would need its own check.

8. Re-run

The count, the 84-job table and the planted-defect checks are in the reproduction package. In a client report, this section gives the exact command and environment.