|
1 | | -Fundamentals |
2 | | -============ |
| 1 | +# Fundamentals |
3 | 2 |
|
4 | 3 | PyBaMM (Python Battery Mathematical Modelling) is an open-source battery simulation package |
5 | 4 | written in Python. Our mission is to accelerate battery modelling research by |
6 | | -providing open-source tools for multi-institutional, interdisciplinary collaboration. |
| 5 | +providing open-source tools for multi-institutional, interdisciplinary collaboration. |
7 | 6 | Broadly, PyBaMM consists of |
8 | 7 |
|
9 | | -#. a framework for writing and solving systems of differential equations, |
10 | | -#. a library of battery models and parameters, and |
11 | | -#. specialized tools for simulating battery-specific experiments and visualizing the results. |
| 8 | +1. a framework for writing and solving systems of differential equations, |
| 9 | +2. a library of battery models and parameters, and |
| 10 | +3. specialized tools for simulating battery-specific experiments and visualizing the results. |
12 | 11 |
|
13 | 12 | Together, these enable flexible model definitions and fast battery simulations, allowing users to |
14 | 13 | explore the effect of different battery designs and modeling assumptions under a variety of operating scenarios. |
15 | 14 |
|
16 | | -.. note:: |
| 15 | +> **NOTE**: This user-guide is a work-in-progress, we hope that this brief but incomplete overview will be useful to you. |
17 | 16 |
|
18 | | - This user-guide is a work-in-progress, we hope that this brief but incomplete overview will be useful to you. |
| 17 | +## Core framework |
19 | 18 |
|
20 | | -Core framework |
21 | | -~~~~~~~~~~~~~~ |
22 | 19 | The core of the framework is a custom computer algebra system to define mathematical equations, |
23 | 20 | and a domain specific modeling language to combine these equations into systems of differential equations |
24 | 21 | (usually partial differential equations for variables depending on space and time). |
25 | | -The `expression tree <https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb>`_ example gives an introduction to the computer algebra system, and the `Getting Started <https://github.com/pybamm-team/PyBaMM/tree/develop/examples/notebooks/Getting%20Started>`_ tutorials |
| 22 | +The [expression tree](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb) example gives an introduction to the computer algebra system, and the [Getting Started](https://github.com/pybamm-team/PyBaMM/tree/develop/examples/notebooks/Getting%20Started) tutorials |
26 | 23 | walk through creating models of increasing complexity. |
27 | 24 |
|
28 | | -Once a model has been defined symbolically, PyBaMM solves it using the Method of Lines. First, the equations are discretised in the spatial dimension, using the finite volume method. Then, the resulting system is solved using third-party numerical solvers. Depending on the form of the model, the system can be ordinary differential equations (ODEs) (if only `model.rhs` is defined), or algebraic equations (if only `model.algebraic` is defined), or differential-algebraic equations (DAEs) (if both `model.rhs` and `model.algebraic` are defined). Jupyter notebooks explaining the solvers can be found `here <https://github.com/pybamm-team/PyBaMM/tree/develop/examples/notebooks/solvers>`_. |
| 25 | +Once a model has been defined symbolically, PyBaMM solves it using the Method of Lines. First, the equations are discretised in the spatial dimension, using the finite volume method. Then, the resulting system is solved using third-party numerical solvers. Depending on the form of the model, the system can be ordinary differential equations (ODEs) (if only `model.rhs` is defined), or algebraic equations (if only `model.algebraic` is defined), or differential-algebraic equations (DAEs) (if both `model.rhs` and `model.algebraic` are defined). Jupyter notebooks explaining the solvers can be found [here](https://github.com/pybamm-team/PyBaMM/tree/develop/examples/notebooks/solvers). |
| 26 | + |
| 27 | +## Model and Parameter Library |
29 | 28 |
|
30 | | -Model and Parameter Library |
31 | | -~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
32 | 29 | PyBaMM contains an extensive library of battery models and parameters. |
33 | 30 | The bulk of the library consists of models for lithium-ion, but there are also some other chemistries (lead-acid, lithium metal). |
34 | | -Models are first divided broadly into common named models of varying complexity, such as the single particle model` (SPM) or Doyle-Fuller-Newman model (DFN). |
| 31 | +Models are first divided broadly into common named models of varying complexity, such as the single particle model (SPM) or Doyle-Fuller-Newman model (DFN). |
35 | 32 | Most options can be applied to any model, but some are model-specific (an error will be raised if you attempt to set an option is not compatible with a model). |
36 | | -See :ref:`base_battery_model` for a list of options. |
| 33 | +See [](base_battery_model) for a list of options. |
37 | 34 |
|
38 | 35 | The parameter library is simply a collection of python files each defining a complete set of parameters |
39 | 36 | for a particular battery chemistry, covering all major lithium-ion chemistries (NMC, LFP, NCA, ...). |
40 | | -External parameter sets can be linked using entry points (see :ref:`parameter_sets`). |
41 | | - |
42 | | -Battery-specific tools |
43 | | -~~~~~~~~~~~~~~~~~~~~~~ |
44 | | -One of PyBaMM's unique features is the ``Experiment`` class, which allows users to define synthetic experiments using simple instructions in English |
| 37 | +External parameter sets can be linked using entry points (see [](parameter_sets)). |
45 | 38 |
|
46 | | -.. code-block:: python |
| 39 | +## Battery-specific tools |
47 | 40 |
|
48 | | - pybamm.Experiment( |
49 | | - [ |
50 | | - ("Discharge at C/10 for 10 hours or until 3.3 V", |
51 | | - "Rest for 1 hour", |
52 | | - "Charge at 1 A until 4.1 V", |
53 | | - "Hold at 4.1 V until 50 mA", |
54 | | - "Rest for 1 hour") |
55 | | - ] |
56 | | - * 3, |
57 | | - ) |
| 41 | +One of PyBaMM's unique features is the `Experiment` class, which allows users to define synthetic experiments using simple instructions in English |
58 | 42 |
|
59 | | -The above instruction will conduct a standard discharge / rest / charge / rest cycle three times, with a 10 hour discharge and 1 hour rest at the end of each cycle. |
| 43 | +```python |
| 44 | +pybamm.Experiment( |
| 45 | + [ |
| 46 | + ("Discharge at C/10 for 10 hours or until 3.3 V", |
| 47 | + "Rest for 1 hour", |
| 48 | + "Charge at 1 A until 4.1 V", |
| 49 | + "Hold at 4.1 V until 50 mA", |
| 50 | + "Rest for 1 hour") |
| 51 | + ] |
| 52 | + * 3, |
| 53 | +) |
| 54 | +``` |
60 | 55 |
|
61 | | -The ``Simulation`` class handles simulating an ``Experiment``, as well as calculating additional outputs such as capacity as a function of cycle number. For example, the following code will simulate the experiment above and plot the standard output variables: |
| 56 | +The above instruction will conduct a standard discharge / rest / charge / rest cycle three times, with a 10 hour discharge and 1 hour rest at the end of each cycle. |
62 | 57 |
|
63 | | -.. code-block:: python |
| 58 | +The `Simulation` class handles simulating an `Experiment`, as well as calculating additional outputs such as capacity as a function of cycle number. For example, the following code will simulate the experiment above and plot the standard output variables: |
64 | 59 |
|
65 | | - import pybamm |
66 | | - import matplotlib.pyplot as plt |
| 60 | +```python |
| 61 | +import pybamm |
| 62 | +import matplotlib.pyplot as plt |
67 | 63 |
|
68 | | - # load model and parameter values |
69 | | - model = pybamm.lithium_ion.DFN() |
70 | | - sim = pybamm.Simulation(model, experiment=experiment) |
71 | | - solution = sim.solve() |
72 | | - solution.plot() |
| 64 | +# load model and parameter values |
| 65 | +model = pybamm.lithium_ion.DFN() |
| 66 | +sim = pybamm.Simulation(model, experiment=experiment) |
| 67 | +solution = sim.solve() |
| 68 | +solution.plot() |
| 69 | +``` |
73 | 70 |
|
74 | 71 | Finally, PyBaMM provides cusotm visualization tools: |
75 | 72 |
|
76 | | -* :ref:`quick_plot`: for easily plotting simulation outputs in a grid, including comparing multiple simulations |
77 | | -* :ref:`plot_voltage_components`: for plotting the component overpotentials that make up a voltage curve |
| 73 | +- [](quick_plot): for easily plotting simulation outputs in a grid, including comparing multiple simulations |
| 74 | +- [](plot_voltage_components): for plotting the component overpotentials that make up a voltage curve |
78 | 75 |
|
79 | 76 | Users are not limited to these tools and can plot the output of a simulation solution by accessing the underlying numpy array for the solution variables as |
80 | 77 |
|
81 | | -.. code-block:: python |
82 | | -
|
83 | | - solution["variable name"].data |
| 78 | +```python |
| 79 | +solution["variable name"].data |
| 80 | +``` |
84 | 81 |
|
85 | | -and using the plotting library of their choice. |
| 82 | +and using the plotting library of their choice. |
0 commit comments