Base Experiment Class

class pybamm.Experiment(operating_conditions, period='1 minute', termination=None, drive_cycles={}, cccv_handling='two-step')[source]

Base class for experimental conditions under which to run the model. In general, a list of operating conditions should be passed in. Each operating condition should be of the form “Do this for this long” or “Do this until this happens”. For example, “Charge at 1 C for 1 hour”, or “Charge at 1 C until 4.2 V”, or “Charge at 1 C for 1 hour or until 4.2 V”. The instructions can be of the form “(Dis)charge at x A/C/W”, “Rest”, or “Hold at x V”. The running time should be a time in seconds, minutes or hours, e.g. “10 seconds”, “3 minutes” or “1 hour”. The stopping conditions should be a circuit state, e.g. “1 A”, “C/50” or “3 V”. The parameter drive_cycles is mandatory to run drive cycle. For example, “Run x”, then x must be the key of drive_cycles dictionary.

  • operating_conditions (list) – List of operating conditions

  • period (string, optional) – Period (1/frequency) at which to record outputs. Default is 1 minute. Can be overwritten by individual operating conditions.

  • termination (list, optional) – List of conditions under which to terminate the experiment. Default is None.

  • drive_cycles (dict) – Dictionary of drive cycles to use for this experiment.

  • cccv_handling (str, optional) – How to handle CCCV. If “two-step” (default), then the experiment is run in two steps (CC then CV). If “ode”, then the experiment is run in a single step using an ODE for current: see pybamm.external_circuit.CCCVFunctionControl for details.


Convert electrical instructions to consistent output


Convert a time in seconds, minutes or hours to a time in seconds

extend_drive_cycle(drive_cycle, end_time)[source]

Extends the drive cycle to enable for event

is_cccv(step, next_step)[source]

Check whether a step and the next step indicate a CCCV charge

read_operating_conditions(operating_conditions, drive_cycles)[source]

Convert operating conditions to the appropriate format

  • operating_conditions (list) – List of operating conditions

  • drive_cycles (dictionary) – Dictionary of Drive Cycles


operating_conditions – Operating conditions in the tuple format

Return type


read_string(cond, drive_cycles)[source]

Convert a string to a tuple of the right format

  • cond (str) – String of appropriate form for example “Charge at x C for y hours”. x and y must be numbers, ‘C’ denotes the unit of the external circuit (can be A for current, C for C-rate, V for voltage or W for power), and ‘hours’ denotes the unit of time (can be second(s), minute(s) or hour(s))

  • drive_cycles (dict) – A map specifying the drive cycles


Read the termination reason. If this condition is hit, the experiment will stop.