Previous topic

Plot Summary Variables

Next topic

Callbacks

This Page

Utility functions

pybamm.get_infinite_nested_dict()[source]

Return a dictionary that allows infinite nesting without having to define level by level.

See: https://stackoverflow.com/questions/651794/whats-the-best-way-to-initialize-a-dict-of-dicts-in-python/652226#652226

Example

>>> import pybamm
>>> d = pybamm.get_infinite_nested_dict()
>>> d["a"] = 1
>>> d["a"]
1
>>> d["b"]["c"]["d"] = 2
>>> d["b"]["c"] == {"d": 2}
True
pybamm.load_function(filename)[source]

Load a python function from an absolute or relative path using importlib. Example - pybamm.load_function(“pybamm/input/example.py”)

Parameters

filename (str) – The path of the file containing the function.

Returns

The python function loaded from the file.

Return type

function

pybamm.rmse(x, y)[source]

Calculate the root-mean-square-error between two vectors x and y, ignoring NaNs

pybamm.root_dir()[source]

return the root directory of the PyBaMM install directory

class pybamm.Timer[source]

Provides accurate timing.

Example

timer = pybamm.Timer() print(timer.time())

reset()[source]

Resets this timer’s start time.

time()[source]

Returns the time (float, in seconds) since this timer was created, or since meth:reset() was last called.