Skip to content

Commit d218aa4

Browse files
Merge pull request #2648 from pybamm-team/markdown-docs
switch some doc files to markdown, add favicon
2 parents 0c120de + 3c9da5f commit d218aa4

File tree

13 files changed

+116
-125
lines changed

13 files changed

+116
-125
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.DS_Store
77
*.mat
88
*.csv
9+
*.hidden
910

1011
# don't ignore important .txt and .csv files
1112
!requirements*

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"sphinx.ext.napoleon",
5050
"sphinx_design",
5151
"sphinx_copybutton",
52+
"myst_parser",
5253
]
5354

5455

@@ -99,6 +100,7 @@
99100
# https://pydata-sphinx-theme.readthedocs.io/en/latest/index.html# for more information)
100101
# mostly copied from numpy, scipy, pandas
101102
html_logo = "source/_static/pybamm_logo.png"
103+
html_favicon = "source/_static/favicon/favicon.png"
102104

103105
html_theme_options = {
104106
"logo": {

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PyBaMM documentation
1313
:maxdepth: 1
1414
:hidden:
1515

16-
source/user_guide/index
16+
User Guide <source/user_guide/index>
1717
source/api/index
1818

1919
**Version**: |version|

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ sphinx>4.0
2020
pydata-sphinx-theme
2121
sphinx_design
2222
sphinx-copybutton
23+
myst-parser
41.8 KB
Loading
Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,82 @@
1-
Fundamentals
2-
============
1+
# Fundamentals
32

43
PyBaMM (Python Battery Mathematical Modelling) is an open-source battery simulation package
54
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.
76
Broadly, PyBaMM consists of
87

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.
1211

1312
Together, these enable flexible model definitions and fast battery simulations, allowing users to
1413
explore the effect of different battery designs and modeling assumptions under a variety of operating scenarios.
1514

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.
1716
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
1918

20-
Core framework
21-
~~~~~~~~~~~~~~
2219
The core of the framework is a custom computer algebra system to define mathematical equations,
2320
and a domain specific modeling language to combine these equations into systems of differential equations
2421
(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
2623
walk through creating models of increasing complexity.
2724

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
2928

30-
Model and Parameter Library
31-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3229
PyBaMM contains an extensive library of battery models and parameters.
3330
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).
3532
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.
3734

3835
The parameter library is simply a collection of python files each defining a complete set of parameters
3936
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)).
4538

46-
.. code-block:: python
39+
## Battery-specific tools
4740

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
5842

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+
```
6055

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.
6257

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:
6459

65-
import pybamm
66-
import matplotlib.pyplot as plt
60+
```python
61+
import pybamm
62+
import matplotlib.pyplot as plt
6763

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+
```
7370

7471
Finally, PyBaMM provides cusotm visualization tools:
7572

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
7875

7976
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
8077

81-
.. code-block:: python
82-
83-
solution["variable name"].data
78+
```python
79+
solution["variable name"].data
80+
```
8481

85-
and using the plotting library of their choice.
82+
and using the plotting library of their choice.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Getting Started
2+
3+
The easiest way to use PyBaMM is to run a 1C constant-current discharge with a model of your choice with all the default settings:
4+
5+
```python
6+
import pybamm
7+
model = pybamm.lithium_ion.DFN() # Doyle-Fuller-Newman model
8+
sim = pybamm.Simulation(model)
9+
sim.solve([0, 3600]) # solve for 1 hour
10+
sim.plot()
11+
```
12+
13+
or simulate an experiment such as a constant-current discharge followed by a constant-current-constant-voltage charge:
14+
15+
```python
16+
import pybamm
17+
experiment = pybamm.Experiment(
18+
[
19+
("Discharge at C/10 for 10 hours or until 3.3 V",
20+
"Rest for 1 hour",
21+
"Charge at 1 A until 4.1 V",
22+
"Hold at 4.1 V until 50 mA",
23+
"Rest for 1 hour")
24+
]
25+
* 3,
26+
)
27+
model = pybamm.lithium_ion.DFN()
28+
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver())
29+
sim.solve()
30+
sim.plot()
31+
```
32+
33+
However, much greater customisation is available. It is possible to change the physics, parameter values, geometry, submesh type, number of submesh points, methods for spatial discretisation and solver for integration (see DFN [script](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/scripts/DFN.py) or [notebook](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/models/DFN.ipynb)).
34+
35+
For new users we recommend the [Getting Started](https://github.com/pybamm-team/PyBaMM/tree/develop/examples/notebooks/Getting%20Started) guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM, and can either be downloaded and used locally, or used online through [Google Colab](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/develop).
36+
37+
Further details can be found in a number of [detailed examples](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/README.md), hosted on
38+
GitHub. In addition, full details of classes and methods can be found in the [](api_docs).
39+
Additional supporting material can be found
40+
[here](https://github.com/pybamm-team/pybamm-supporting-material/).

docs/source/user_guide/getting_started.rst

Lines changed: 0 additions & 41 deletions
This file was deleted.

docs/source/user_guide/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(user)=
2+
3+
# PyBaMM user guide
4+
5+
This guide is an overview and explains the important features;
6+
details are found in [](api_docs).
7+
8+
```{toctree}
9+
---
10+
caption: Getting started
11+
maxdepth: 1
12+
---
13+
14+
installation/index
15+
getting_started
16+
```
17+
18+
```{toctree}
19+
---
20+
caption: Fundamentals and usage
21+
maxdepth: 2
22+
---
23+
fundamentals/index
24+
```

docs/source/user_guide/index.rst

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)