Fitting PyBaMM Parameters: PyBOP Versions, Identifiability and Validation
Fitting PyBaMM Parameters: PyBOP Versions, Identifiability and Validation
Search
Ask the AI

Fitting PyBaMM Parameters: PyBOP Versions, Identifiability and Validation

Parameter fitting can reduce the mismatch between a measured discharge curve and a PyBaMM model. Check the software version, the parameters that the experiment can identify, and performance on held-out data.

A small fitting residual measures agreement with the selected data. Parameter meaning also depends on the model, excitation, noise and constraints. This article explains how to choose a fitting tool and test those conditions.

PyBaMM battery modelling series · Silent failures, measured (part 7 of 8): Previous: PyBaMM Solver Convergence Failures: Numerics or Physics · Next: GITT Diffusion Coefficient Errors Tested with Known-D PyBaMM Data · Series hub: Data pipeline (5) + Silent failures, measured (8) · RSS feed.

1. Choosing the fitting tool

The pybamm-param README directs new users to PyBOP:

All the functionality in pybamm-param is now available in PyBOP, which will be the focus of future development.

PyBOP is the successor recommended by the pybamm-param developers (pip install pybop). Check its release notes and examples alongside the PyBaMM version used for the fit.

2. Copied API snippets are likely to be stale

PyBOP’s README identifies v25.10 as a major restructure: model/problem/cost setup changed to simulator/cost/problem setup. Older examples that use the changed interfaces need migration; unaffected calls may still work.

Use examples from the tag that matches the installed release. The command below locates that installation. The remaining sections discuss parameter selection and diagnostics, which apply across fitting libraries.

# Rather than copying a call that may be stale, read the examples that ship
# with the version you actually installed
python -c "import pybop, pathlib; print(pybop.__version__, pathlib.Path(pybop.__file__).parent)"
# then open examples/ at the matching tag in the repository - not an arbitrary
# tutorial from the search results

3. The real problem: you cannot fit what the data cannot see

A DFN model can contain dozens of physical parameters and parameter functions; the count depends on its options and parameterization. A single voltage trace may constrain only a subset or combinations of them. An optimizer can return a low residual without uniquely recovering the individual values.

Parameter combinations can be better constrained than individual parameters. For example, volumetric reaction terms contain the product of exchange current density and specific surface area. Halving one and doubling the other preserves that product, but other appearances of surface area, geometry or transport can still change the discharge curve. Test the full model’s sensitivity before treating this as an exact invariance.

Two useful starting points are:

  • Fit a selected subset. Use sensitivity and identifiability analysis under the intended conditions. OCP and particle diffusivity are useful candidates in some discharge fits; the cited LFP discussion recommends them for that case.
  • Add informative experiments. Different C-rates, SOCs or measurement types can separate parameters when they excite distinct sensitivities. More curves at the same insensitive conditions need not break a structural degeneracy.

4. Checking the fitted parameters

Use the following steps to check the fit, whichever library you use.

Hold out a rate you did not fit

Fit on selected C-rates and validate on one held out. A mismatch on the held-out rate identifies a transfer problem. Investigate parameter uncertainty, missing mechanisms, initial states and measurement conditions before attributing it to overfitting.

Re-fit from several starting points

Repeat the optimization from several initial guesses. Widely different parameters with similar residuals indicate a flat or multimodal objective and weak practical identification. Agreement across starts supports numerical stability; combine it with sensitivity analysis, parameter profiles or uncertainty estimates to assess identification.

Multi-start fitting complements uncertainty analysis. Neither a single local covariance estimate nor agreement across a finite set of starts establishes global identifiability.

Check the values against physical bounds

A porosity above one or stoichiometry outside [0, 1] violates their physical definitions. A diffusivity far from a relevant literature value calls for checking chemistry, temperature, units and compensation for other model errors. Set justified bounds and investigate fits that reach them. The site’s EIS equivalent-circuit fitter conservatively flags a bound-hitting parameter as not identified; this software rule is a diagnostic, not a general proof of non-identifiability.

Look at the residual shape, not only its size

A structured residual, such as a consistent offset or error near the discharge endpoint, helps locate systematic mismatch. Possible causes include parameters, missing mechanisms, sensor bias, alignment and numerical error. Noise-like residuals support the selected error model but do not by themselves identify the parameters.

5. When the model is the problem, not the parameters

Parameter adjustment cannot introduce a mechanism absent from the equations. The table lists hypotheses to investigate when a fit does not transfer:

Symptom Likely cause
Fit is good at low rate, diverges at high rate Electrolyte limitation the model averages away. SPM cannot represent it at all; try SPMe or DFN.
Fit is good on a fresh cell, drifts on an aged one No degradation submodel enabled, so the fit is compensating with unphysical transport parameters.
Fit needs a different parameter set per temperature Missing or wrong Arrhenius dependence; the temperature behaviour is being absorbed into constants.
Residual has a consistent offset Often not the cell at all – check the measurement, contact resistance and OCP reference.

The symptoms in the table have several possible causes. For example, a separately parameterized aged cell can fit without a dynamic degradation submodel, and temperature dependence need not follow a single Arrhenius law. Compare candidate mechanisms and parameterizations against additional data before selecting a diagnosis.

6. What to record

Record which quantities were fitted, fixed or inherited, along with their sources and fitting conditions. The following is a record-format example, not a reported experiment:

Base set:        Chen2020
Fitted:          negative particle diffusivity, positive OCP shift
Held fixed:      everything else (source: Chen2020)
Data:            3 discharge curves, 0.5C / 1C / 2C, 25 C, cell ID ...
Held out:        1.5C, used only for validation
Optimiser:       <name and version>
Restarts:        8 starting points; fitted values spread < 5%
Held-out error:  RMSE ... mV
Residual shape:  noise-like, no structure at either end
Bounds hit:      none

Report multi-start results and held-out error together with bounds, data provenance, fitted/fixed parameters, residual diagnostics and uncertainty. These records show what the fit supports and where its values will be used.

References

Related: PyBaMM architecture and solver choice, EIS labels and identifiability, and solver convergence failures. The site’s HPPC pulse resistance analyser uses a first-order Thevenin fit and reports a lower bound on tau when its relaxation-window criterion is not met.

Related: eight failures that never errored — what this same identifiability problem looks like at the code level, including ZARC R–Q degeneracy and a guard that cried wolf.

Related: why a GITT diffusion coefficient goes wrong, on measuring the particle diffusivity directly, with each error it covers checked against a known D.

Related: PyBaMM’s built-in parameter sets, measured. The reported 0.78C comparison uses Marquis2019’s measured low-rate capacity as its denominator; Chen2020’s weak capacity change refers to the tested temperature comparison.

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

Leave a Reply

Scroll down