Parameter Values#

class pybamm.ParameterValues(values, 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 an inbuilt parameter set If string and matches one of the inbuilt parameter sets, returns that parameter set.

Examples

>>> values = {"some parameter": 1, "another parameter": 2}
>>> param = pybamm.ParameterValues(values)
>>> param["some parameter"]
1
>>> param = pybamm.ParameterValues("Marquis2019")
>>> param["Reference temperature [K]"]
298.15
copy()[source]#

Returns a copy of the parameter values. Makes sure to copy the internal dictionary.

static create_from_bpx(filename, target_soc=1)[source]#
Parameters:
  • filename (str) – The filename of the bpx file

  • target_soc (float, optional) – Target state of charge. Must be between 0 and 1. Default is 1.

Returns:

A parameter values object with the parameters in the bpx file

Return type:

ParameterValues

evaluate(symbol, inputs=None)[source]#

Process and evaluate a symbol.

Parameters:

symbol (pybamm.Symbol) – Symbol or Expression tree to evaluate

Returns:

The evaluated symbol

Return type:

number or array

get(key, default=None)[source]#

Return item corresponding to key if it exists, otherwise return default

items()[source]#

Get the items of the dictionary

keys()[source]#

Get the keys of the dictionary

print_evaluated_parameters(evaluated_parameters, output_file)[source]#

Print a dictionary of evaluated parameters to an output file

Parameters:
  • evaluated_parameters (defaultdict) – The evaluated parameters, for further processing if needed

  • output_file (string, optional) – The file to print parameters to. If None, the parameters are not printed, and this function simply acts as a test that all the parameters can be evaluated

print_parameters(parameters, output_file=None)[source]#

Return dictionary of evaluated parameters, and optionally print these evaluated parameters to an output file.

Parameters:
  • parameters (class or dict containing pybamm.Parameter objects) – Class or dictionary containing all the parameters to be evaluated

  • output_file (string, optional) – The file to print parameters to. If None, the parameters are not printed, and this function simply acts as a test that all the parameters can be evaluated, and returns the dictionary of evaluated parameters.

Returns:

evaluated_parameters – The evaluated parameters, for further processing if needed

Return type:

defaultdict

Notes

A C-rate of 1 C is the current required to fully discharge the battery in 1 hour, 2 C is current to discharge the battery in 0.5 hours, etc

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 (dict) – 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

search(key, print_values=True)[source]#

Search dictionary for keys containing ‘key’.

See pybamm.FuzzyDict.search().

set_initial_ocps(initial_value, param=None, known_value='cyclable lithium capacity', inplace=True, options=None)[source]#

Set the initial OCP of each electrode, based on the initial SOC or voltage

set_initial_stoichiometries(initial_value, param=None, known_value='cyclable lithium capacity', inplace=True, options=None, inputs=None, tol=1e-06)[source]#

Set the initial stoichiometry of each electrode, based on the initial SOC or voltage

set_initial_stoichiometry_half_cell(initial_value, param=None, known_value='cyclable lithium capacity', inplace=True, options=None, inputs=None)[source]#

Set the initial stoichiometry of the working electrode, based on the initial SOC or voltage

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

values()[source]#

Get the values of the dictionary