pybamm.ParameterValues is the central object for managing parameters in a simulation. It stores scalar constants, callables, and interpolant data, and provides methods to substitute those values into a symbolic model or geometry.
Constructor
The parameter data to load. Accepts:
- A plain
dictmapping parameter names to values. - A
strmatching the name of a built-in parameter set (e.g."Chen2020"). - An existing
ParameterValuesinstance (copy constructor).
Class Methods
create_from_bpx
Create a ParameterValues instance directly from a BPX JSON file.
Path to the
.json BPX file.State of charge used to calculate the initial electrode concentrations. Must be between 0 and 1.
create_from_bpx_obj
Same as create_from_bpx but accepts a pre-parsed dict instead of a file path.
from_json
Load parameters that were previously saved with to_json.
Dictionary Interface
ParameterValues behaves like a dict. You can read, write, and iterate over entries with standard Python syntax.
__getitem__ / __setitem__
get
Return the value for a key, or default if the key is absent.
update
Merge a dictionary of new or updated values into the existing store.
Mapping of parameter name → new value.
search
Print (or return) all keys that contain the search string.
Substring to search for in parameter names.
Whether to print the matching parameters to stdout.
Processing Methods
These methods substitute the stored values into symbolic PyBaMM objects.process_model
Walk through a model and replace every pybamm.Parameter node with the corresponding stored value.
The symbolic model returned by e.g.
pybamm.lithium_ion.SPM().If
True, modify the model in place and return it. If False, return a new parameterised copy.If
True, variable processing is deferred to a post-processing step.The parameterised model.
process_geometry
Substitute parameter values into a geometry dictionary (in place).
Geometry dict, typically created with
pybamm.battery_geometry().process_symbol
Replace all Parameter nodes in a single symbolic expression.
Serialisation
to_json
Convert the parameter store to a JSON-serialisable dict and optionally write to disk.
Full Simulation Example
Physical constants (Faraday constant, ideal gas constant, etc.) were previously stored in
ParameterValues. They are now deprecated there — use pybamm.constants.F, pybamm.constants.R, etc. instead.