Previous topic

Parameters

Next topic

Geometric Parameters

This Page

Base Parameter Values

class pybamm.ParameterValues(values=None, chemistry=None)[source]

The parameter values for a simulation.

Note that this class does not inherit directly from the python dictionary class as this causes issues with saving and loading simulations.

Parameters:
  • values (dict or string) – Explicit set of parameters, or reference to a file of parameters If string, gets passed to read_parameters_csv to read a file.
  • chemistry (dict) – Dict of strings for default chemistries. Must be of the form: {“base chemistry”: base_chemistry, “cell”: cell_properties_authorYear, “anode”: anode_chemistry_authorYear, “separator”: separator_chemistry_authorYear, “cathode”: cathode_chemistry_authorYear, “electrolyte”: electrolyte_chemistry_authorYear, “experiment”: experimental_conditions_authorYear}. Then the anode chemistry is loaded from the file inputs/parameters/base_chemistry/anodes/anode_chemistry_authorYear, etc. Parameters in “cell” should include geometry and current collector properties. Parameters in “experiment” should include parameters relating to experimental conditions, such as initial conditions and currents.

Examples

>>> import pybamm
>>> values = {"some parameter": 1, "another parameter": 2}
>>> param = pybamm.ParameterValues(values)
>>> param["some parameter"]
1
>>> file = "input/parameters/lithium-ion/cells/kokam_Marquis2019/parameters.csv"
>>> values_path = pybamm.get_parameters_filepath(file)
>>> param = pybamm.ParameterValues(values=values_path)
>>> param["Negative current collector thickness [m]"]
2.5e-05
>>> param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
>>> param["Reference temperature [K]"]
298.15
evaluate(symbol)[source]

Process and evaluate a symbol.

Parameters:symbol (pybamm.Symbol) – Symbol or Expression tree to evaluate
Returns:The evaluated symbol
Return type:number of array
items()[source]

Get the items of the dictionary

keys()[source]

Get the keys of the dictionary

process_boundary_conditions(model)[source]

Process boundary conditions for a model Boundary conditions are dictionaries {“left”: left bc, “right”: right bc} in general, but may be imposed on the tabs (or not on the tab) for a small number of variables, e.g. {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc “no tab”: no tab bc}.

process_geometry(geometry)[source]

Assign parameter values to a geometry (inplace).

Parameters:geometry (pybamm.Geometry) – Geometry specs to assign parameter values to
process_model(unprocessed_model, inplace=True)[source]

Assign parameter values to a model. Currently inplace, could be changed to return a new model.

Parameters:
  • unprocessed_model (pybamm.BaseModel) – Model to assign parameter values for
  • inplace (bool, optional) – If True, replace the parameters in the model in place. Otherwise, return a new model with parameter values set. Default is True.
Raises:

pybamm.ModelError – If an empty model is passed (model.rhs = {} and model.algebraic = {} and model.variables = {})

process_symbol(symbol)[source]

Walk through the symbol and replace any Parameter with a Value. If a symbol has already been processed, the stored value is returned.

Parameters:symbol (pybamm.Symbol) – Symbol or Expression tree to set parameters for
Returns:symbol – Symbol with Parameter instances replaced by Value
Return type:pybamm.Symbol
read_parameters_csv(filename)[source]

Reads parameters from csv file into dict.

Parameters:filename (str) – The name of the csv file containing the parameters.
Returns:{name: value} pairs for the parameters.
Return type:dict
search(key, print_values=True)[source]

Search dictionary for keys containing ‘key’.

See pybamm.FuzzyDict.search().

update(values, check_conflict=False, check_already_exists=True, path='')[source]

Update parameter dictionary, while also performing some basic checks.

Parameters:
  • values (dict) – Dictionary of parameter values to update parameter dictionary with
  • check_conflict (bool, optional) – Whether to check that a parameter in values has not already been defined in the parameter class when updating it, and if so that its value does not change. This is set to True during initialisation, when parameters are combined from different sources, and is False by default otherwise
  • check_already_exists (bool, optional) – Whether to check that a parameter in values already exists when trying to update it. This is to avoid cases where an intended change in the parameters is ignored due a typo in the parameter name, and is True by default but can be manually overridden.
  • path (string, optional) – Path from which to load functions
update_from_chemistry(chemistry)[source]

Load standard set of components from a ‘chemistry’ dictionary

values()[source]

Get the values of the dictionary