PyBaMM 24.11 has now been released! This off-band release slightly differs from the previous release schedule conforming to three releases a year and marks the fourth release of 2024. We would like to thank all the contributors who made this release possible.
The full list of changes can be found in the CHANGELOG file, but here we provide a deeper overview of the main features of this release.
Implemented by Valentin Sulzer (Ionworks)
With this release, we have introduced a new opt-in telemetry collection system to help us better understand how PyBaMM is being used. This system collects anonymous usage data, such as the version of PyBaMM being used, the operating system, and the Python version. This data will help us make informed decisions about the future of PyBaMM. We would like to assure you that no personal data is collected, and the data is only used by the PyBaMM team. Here are some details:
PYBAMM_DISABLE_TELEMETRY=true
(or any value other than false
) or use pybamm.telemetry.disable()
in your code. You can also select “no” when PyBaMM asks if you would like to enable telemetry.Implemented by Pip Liggins (Oxford RSE)
Simulations using experiments now support the use of output variables from the IDAKLUSolver
. This means that the model can be solved only storing the specified output variables (instead of the whole state vector), which provides benefits both in terms of computational speed and memory usage. For example, if we want to run a long simulation of the SPM model and only store time, current, and voltage; we can run:
model = pybamm.lithium_ion.SPM()
output_variables = ["Time [s]", "Current [A]", "Voltage [V]"]
solver = pybamm.IDAKLUSolver(output_variables=output_variables)
experiment = pybamm.Experiment(
[
(
"Charge at 1C until 4.2 V",
"Hold at 4.2 V until C/50",
"Rest for 1 hour",
)
] * 1000
)
sim = pybamm.Simulation(model, experiment=experiment, solver=solver)
sol = sim.solve()
This new release comes with several performance improvements associated with the solvers.
Implemented by Marc Berliner (Ionworks) and Martin Robinson (Oxford RSE)
This release leverages several features of SUNDIALS to improve the performance of the IDAKLU solver. The solver now uses Hermite interpolation which significantly speeds up processing variables after solving the model. It also improves the plots, especially when the solution has very few timesteps. The initialisation and reinitialisation of ODEs is now done directly by SUNDIALS, which improves the performance of the solver. This is particularly noticeable when solving models with a evaluation times vector t_eval
.
Finally, the IDAKLU solver can now run multiple simulations in parallel using OpenMP. This is particularly relevant when running parameter sweeps. For a given model
the parallelisation can be run by
options = {"num_threads": num_threads, "num_solvers": num_solvers}
solver = pybamm.IDAKLUSolver(options=options)
t_eval = [0, 1]
ninputs = 8
inputs_list = [{"C-rate": 0.1 * (i + 1)} for i in range(ninputs)]
solutions = solver.solve(
model, t_eval, inputs=inputs_list
)
Implemented by Brady Planden (University of Oxford)
The JAX Solver has been refactored to improve its performance. The default method is now "BDF"
which has better performance than the previous default "RK45"
. Bugs related to calculating sensitivities have now been fixed too. For more details please see this example script.
Implemented by Ferran Brosa Planella (University of Warwick & Ionworks)
PyBaMM now includes a DFN model for sodium-ion batteries. The model is defined identically to that for lithium-ion batteries, but it is a separate class to prevent clashes with unavailable options. The model can be called as pybamm.sodium_ion.BasicDFN()
. It comes with the parameter set presented in the article by Chayambuka et al (2022). For more details please see the example notebook.
Implemented by Martin Robinson (Oxford RSE)
The Simulation
class now supports sensitivity calculation, including when running experiments. This means that the sensitivity of the output variables with respect to the parameters can be calculated when running experiments that switch operating modes (e.g. CCCV). For example, to calculate the sensitivity of the voltage with respect to the initial concentration of lithium in the negative electrode, we can run:
model = pybamm.lithium_ion.SPM()
parameter_values = model.default_parameter_values
input_param_name = "Negative electrode active material volume fraction"
input_param_value = param[input_param_name]
parameter_values.update({input_param_name: "[input]"})
solver = pybamm.IDAKLUSolver()
experiment = pybamm.Experiment(
[
(
"Charge at 1C until 4.2 V",
"Hold at 4.2 V until C/50",
"Rest for 1 hour",
)
]
)
sim = pybamm.Simulation(
model,
experiment=experiment,
solver=solver,
parameter_values=parameter_values,
)
solution = sim.solve(
inputs={input_param_name: input_param_value},
calculate_sensitivities=calculate_sensitivities,
)
sensitivity = solution["Voltage [V]].sensitivities[input_param_name]
Implemented by Robert Timms (Ionworks)
The parameters ... electrode OCP entropic change [V.K-1]
and ... electrode volume change
are now dependent on stoichiometry only (as opposed to stoichiometry and maximum concentration as they used to be). This means that, when defining custom parameter values, these functions need to be defined as
def your_entropic_change_function(sto):
return your_entropic_change_value
and
def your_volume_change_function(sto):
return your_volume_change_value