Skip to content

Commit 75d403d

Browse files
Merge branch 'develop' into telemetry
2 parents 1a835a4 + 3864e5d commit 75d403d

File tree

19 files changed

+620
-148
lines changed

19 files changed

+620
-148
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: "v0.6.9"
7+
rev: "v0.7.0"
88
hooks:
99
- id: ruff
1010
args: [--fix, --show-fixes]

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Features
44

5+
- Adds support to `pybamm.Experiment` for the `output_variables` option in the `IDAKLUSolver`. ([#4534](https://github.com/pybamm-team/PyBaMM/pull/4534))
56
- Adds an option "voltage as a state" that can be "false" (default) or "true". If "true" adds an explicit algebraic equation for the voltage. ([#4507](https://github.com/pybamm-team/PyBaMM/pull/4507))
67
- Improved `QuickPlot` accuracy for simulations with Hermite interpolation. ([#4483](https://github.com/pybamm-team/PyBaMM/pull/4483))
78
- Added Hermite interpolation to the (`IDAKLUSolver`) that improves the accuracy and performance of post-processing variables. ([#4464](https://github.com/pybamm-team/PyBaMM/pull/4464))
@@ -20,7 +21,7 @@
2021
- Removed the `start_step_offset` setting and disabled minimum `dt` warnings for drive cycles with the (`IDAKLUSolver`). ([#4416](https://github.com/pybamm-team/PyBaMM/pull/4416))
2122

2223
## Bug Fixes
23-
24+
- Fixed bug in post-processing solutions with infeasible experiments using the (`IDAKLUSolver`). ([#4541](https://github.com/pybamm-team/PyBaMM/pull/4541))
2425
- Disabled IREE on MacOS due to compatibility issues and added the CasADI
2526
path to the environment to resolve issues on MacOS and Linux. Windows
2627
users may still experience issues with interpolation. ([#4528](https://github.com/pybamm-team/PyBaMM/pull/4528))

docs/source/api/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ API documentation
99
:Release: |version|
1010
:Date: |today|
1111

12-
This reference manual details functions, modules, and objects
13-
included in PyBaMM, describing what they are and what they do.
12+
This reference manual details the classes, functions, modules, and objects included in PyBaMM, describing what they are and what they do.
1413
For a high-level introduction to PyBaMM, see the :ref:`user guide <user_guide>` and the :ref:`examples <pybamm_examples>`.
1514

15+
1616
.. toctree::
1717
:maxdepth: 2
1818

docs/source/api/util.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ Utility functions
1919
.. autofunction:: pybamm.has_jax
2020

2121
.. autofunction:: pybamm.is_jax_compatible
22+
23+
.. autofunction:: pybamm.set_logging_level

docs/source/examples/notebooks/getting_started/tutorial-4-setting-parameter-values.ipynb

Lines changed: 121 additions & 89 deletions
Large diffs are not rendered by default.

docs/source/examples/notebooks/parameterization/parameter-values.ipynb

Lines changed: 75 additions & 32 deletions
Large diffs are not rendered by default.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
----------
2+
Public API
3+
----------
4+
5+
.. module:: pybamm
6+
:noindex:
7+
8+
PyBaMM is a Python package for mathematical modelling and simulation of battery systems. The main classes and functions that are intended to be used by the user are described in this document.
9+
For a more detailed description of the classes and methods, see the :doc:`API reference </source/api/index>`.
10+
11+
Available PyBaMM models
12+
-----------------------
13+
14+
PyBaMM includes a number of pre-implemented models, which can be used as they are or modified to suit your needs. The main models are:
15+
16+
- :class:`lithium_ion.SPM`: Single Particle Model
17+
- :class:`lithium_ion.SPMe`: Single Particle Model with Electrolyte
18+
- :class:`lithium_ion.DFN`: Doyle-Fuller-Newman
19+
20+
The behaviour of the models can be modified by passing in an :class:`BatteryModelOptions` object when creating the model.
21+
22+
Simulations
23+
-----------
24+
25+
:class:`Simulation` is a class that automates the process of setting up a model and solving it, and acts as the highest-level API to PyBaMM.
26+
Pass at least a :class:`BaseModel` object, and optionally the experiment, solver, parameter values, and geometry objects described below to the :class:`Simulation` object.
27+
Any of these optional arguments not provided will be supplied by the defaults specified in the model.
28+
29+
Parameters
30+
----------
31+
32+
PyBaMM models are parameterised by a set of parameters, which are stored in a :class:`ParameterValues` object. This object acts like a Python dictionary with a few extra PyBaMM specific features and methods.
33+
Parameters in a model are represented as either :class:`Parameter` objects or :class:`FunctionParameter` objects, and the values in the :class:`ParameterValues` object replace these objects in the model before it is solved.
34+
The values in the :class:`ParameterValues` object can be scalars, Python functions or expressions of type :class:`Symbol`.
35+
36+
Experiments
37+
-----------
38+
39+
An :class:`Experiment` object represents an experimental protocol that can be used to simulate the behaviour of a battery. The particular protocol can be provided as a Python string, or as a sequences of
40+
:class:`step.BaseStep` objects.
41+
42+
Solvers
43+
-------
44+
45+
The two main solvers in PyBaMM are the :class:`CasadiSolver` and the :class:`IDAKLUSolver`. Both are wrappers around the Sundials suite of solvers, but the :class:`CasadiSolver` uses the CasADi library
46+
whereas the :class:`IDAKLUSolver` is PyBaMM specific. Both solvers have many options that can be set to control the solver behaviour, see the documentation for each solver for more details.
47+
48+
When a model is solved, the solution is returned as a :class:`Solution` object.
49+
50+
Plotting
51+
--------
52+
53+
A solution object can be plotted using the :meth:`Solution.plot` or :meth:`Simulation.plot` methods, which returns a :class:`QuickPlot` object.
54+
Note that the arguments to the plotting methods of both classes are the same as :class:`QuickPlot`.
55+
56+
Other plotting functions are the :func:`plot_voltage_components` and :func:`plot_summary_variables` functions, which correspond to the similarly named methods of the :class:`Solution` and :class:`Simulation` classes.
57+
58+
Writing PyBaMM models
59+
---------------------
60+
61+
Each PyBaMM model, and the custom models written by users, are written as a set of expressions that describe the model. Each of the expressions is a subclass of the :class:`Symbol` class, which represents a mathematical expression.
62+
63+
If you wish to create a custom model, you can use the :class:`BaseModel` class as a starting point.
64+
65+
66+
Discretisation
67+
--------------
68+
69+
Each PyBaMM model contains continuous operators that must be discretised before they can be solved. This is done using a :class:`Discretisation` object, which takes a :class:`Mesh` object and a dictionary of :class:`SpatialMethod` objects.
70+
71+
Logging
72+
-------
73+
74+
PyBaMM uses the Python logging module to log messages at different levels of severity. Use the :func:`pybamm.set_logging_level` function to set the logging level for PyBaMM.

docs/source/user_guide/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ maxdepth: 2
2222
---
2323
fundamentals/index
2424
fundamentals/battery_models
25+
fundamentals/public_api
2526
```
2627

2728
```{toctree}

src/pybamm/logger.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ def func(self, message, *args, **kws):
2424

2525

2626
def set_logging_level(level):
27+
"""
28+
Set the logging level for PyBaMM
29+
30+
Parameters
31+
----------
32+
33+
level: str
34+
The logging level to set. Should be one of 'DEBUG', 'INFO', 'WARNING',
35+
'ERROR', 'CRITICAL'
36+
37+
"""
2738
logger.setLevel(level)
2839

2940

src/pybamm/solvers/base_solver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@ def get_termination_reason(solution, events):
14521452
solution.t_event,
14531453
solution.y_event,
14541454
solution.termination,
1455+
variables_returned=solution.variables_returned,
14551456
)
14561457
event_sol.solve_time = 0
14571458
event_sol.integration_time = 0

0 commit comments

Comments
 (0)