Parameter Sets

class ionworkspipeline.parameter_values.ParameterValues(values)
apply_degradation_state(degradation_state, inplace=True)

Apply a degradation state to the parameter values. Can account for loss of (cyclable) lithium inventory, loss of active material and resistance change via an additional ohmic resistance (the model option “contact resistance” must be “true” for PyBaMM models to include a contact resistance).

API inspired by aepybamm (About-Energy-OpenSource/AEPyBaMM).

Note: this is not valid for composite electrodes.

Parameters

degradation_statedict

The degradation state to apply to the parameter values. Can have the following keys:

  • “LAM_ne [%]”: Loss of active material in negative electrode (%)

  • “LAM_pe [%]”: Loss of active material in positive electrode (%)

  • “LLI [%]”: Loss of lithium inventory (%)

  • “R0_addn [Ohm]”: Additional ohmic resistance (Ohm). This is achieved by adding to the contact resistance.

Each of these keys is optional, and if not provided, the default value of 0 will be used.

inplacebool, optional

If True, update the parameter values in place. Otherwise, return a new parameter values object.

static check_parameter_values(values)

Check if the parameter values are valid.

copy()

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

static from_json(filename)

Loads a JSON file and converts it to a ParameterValues object

Parameters

filenamestr

The filename to load the JSON file from

Returns

ParameterValues

The ParameterValues object

process_symbol(symbol)

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

Parameters

symbolpybamm.Symbol

Symbol or Expression tree to set parameters for

Returns

symbolpybamm.Symbol

Symbol with Parameter instances replaced by Value

scale_parameter(name, scale_factor=None, inplace=True)

Apply a scale factor to a parameter in a the ParameterValues object. The updated parameter returns the original parameter value multiplied by the scale factor. If the parameter is a callable function, the updated parameter is returned as a function-like object, so that it can be used in expressions as a function of other parameters. If the parameter is not a callable function, the updated parameter is returned as a float or int equal to the original parameter value multiplied by the scale factor.

Parameters

namestr

The name of the parameter to apply the scale factor to. Must be a key in parameter_values.

scale_factorfloat, int, or pybamm.Parameter, optional

The scale factor to apply to the parameter. If None, adds a parameter with the name name + “ (scale factor)”.

inplacebool, optional

If True, update the parameter values in place. Otherwise, return a new parameter values object.

to_json(filename=None)

Converts the parameter values to a JSON-serializable dictionary and optionally saves it to a file.

Parameters

filenamestr, optional

The filename to save the JSON file to. If not provided, the dictionary is not saved.

Returns

dict

The JSON-serializable dictionary

ionworkspipeline.parameter_values.scalarize_dict(params: dict[str, Any], ignored_keys: list[str] | None = None) dict[str, Any]

Expand list-valued items into scalar keys while preserving tags. Example ——- {‘a [V]’: [1, 2]} → {‘a (0) [V]’: 1, ‘a (1) [V]’: 2}

Parameters

paramsdict[str, Any]

The dictionary to scalarize

ignored_keyslist[str], optional

The keys to ignore. Defaults to ["citations"].

Returns

dict[str, Any]

The scalarized dictionary

ionworkspipeline.parameter_values.arrayize_dict(scalar_dict: dict[str, Any]) dict[str, Any]

Collapse scalar keys back into lists. Tags are kept with the base name ('a [V]'). A sequence is collapsed only if indices 0…N are all present.

Parameters

scalar_dictdict[str, Any]

The dictionary to arrayize

Returns

dict[str, Any]

The arrayized dictionary