pybop.parameters.parameter_set#

Classes#

ParameterSet

Handles the import and export of parameter sets for battery models.

Functions#

set_formation_concentrations(parameter_set)

Compute the concentration of lithium in the positive electrode assuming that

Module Contents#

class pybop.parameters.parameter_set.ParameterSet(json_path=None, params_dict=None)[source]#

Handles the import and export of parameter sets for battery models.

This class provides methods to load parameters from a JSON file and to export them back to a JSON file. It also includes custom logic to handle special cases, such as parameter values that require specific initialization.

Parameters:
  • json_path (str, optional) – Path to a JSON file containing parameter data. If provided, parameters will be imported from this file during initialization.

  • params_dict (dict, optional) – A dictionary of parameters to initialize the ParameterSet with. If not provided, an empty dictionary is used.

__call__()[source]#
__getitem__(key)[source]#
__setitem__(key, value)[source]#
export_parameters(output_json_path, fit_params=None)[source]#

Exports parameters to a JSON file specified by output_json_path.

The current state of the params attribute is written to the file. If fit_params is provided, these parameters are updated before export. Non-serializable values are handled and noted in the output JSON.

Parameters:
  • output_json_path (str) – The file path where the JSON output will be saved.

  • fit_params (list of fitted parameter objects, optional) – Parameters that have been fitted and need to be included in the export.

Raises:

ValueError – If there are no parameters to export.

import_from_bpx(json_path=None)[source]#

Imports parameters from a JSON file in the BPX format specified by the json_path attribute. Credit: PyBaMM

If a json_path is provided at initialization or as an argument, that JSON file is loaded and the parameters are stored in the params attribute.

Parameters:

json_path (str, optional) – Path to the JSON file from which to import parameters. If provided, it overrides the instance’s json_path.

Returns:

The dictionary containing the imported parameters.

Return type:

dict

Raises:

FileNotFoundError – If the specified JSON file cannot be found.

import_parameters(json_path=None)[source]#

Imports parameters from a JSON file specified by the json_path attribute.

If a json_path is provided at initialization or as an argument, that JSON file is loaded and the parameters are stored in the params attribute. Special cases are handled appropriately.

Parameters:

json_path (str, optional) – Path to the JSON file from which to import parameters. If provided, it overrides the instance’s json_path.

Returns:

The dictionary containing the imported parameters.

Return type:

dict

Raises:

FileNotFoundError – If the specified JSON file cannot be found.

is_json_serializable(value)[source]#

Determines if the given value can be serialized to JSON format.

Parameters:

value (any) – The value to check for JSON serializability.

Returns:

True if the value is JSON serializable, False otherwise.

Return type:

bool

keys() List[source]#

A list of parameter names

classmethod pybamm(name, formation_concentrations=False)[source]#

Retrieves a PyBaMM parameter set by name.

Parameters:
  • name (str) – The name of the PyBaMM parameter set to retrieve.

  • set_formation_concentrations (bool, optional) – If True, re-calculates the initial concentrations of lithium in the active material (default: False).

Returns:

A PyBaMM parameter set corresponding to the provided name.

Return type:

pybamm.ParameterValues

pybop.parameters.parameter_set.set_formation_concentrations(parameter_set)[source]#

Compute the concentration of lithium in the positive electrode assuming that all lithium in the active material originated from the positive electrode.

Parameters:

parameter_set (pybamm.ParameterValues) – A PyBaMM parameter set containing standard lithium ion parameters.