Skip to content

Commit 8803100

Browse files
committed
#729 merge develop
2 parents 8f3d905 + 891424b commit 8803100

29 files changed

+499
-192
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
- Add new symbols `VariableDot`, representing the derivative of a variable wrt time,
1313
and `StateVectorDot`, representing the derivative of a state vector wrt time
1414
([#858](https://github.com/pybamm-team/PyBaMM/issues/858))
15+
- Added a helper function for info on function parameters ([#881](https://github.com/pybamm-team/PyBaMM/pull/881))
1516
- Added additional notebooks showing how to create and compare models ([#877](https://github.com/pybamm-team/PyBaMM/pull/877))
1617
- Added `Minimum`, `Maximum` and `Sign` operators
1718
([#876](https://github.com/pybamm-team/PyBaMM/pull/876))
1819
- Added a search feature to `FuzzyDict` ([#875](https://github.com/pybamm-team/PyBaMM/pull/875))
1920
- Add ambient temperature as a function of time ([#872](https://github.com/pybamm-team/PyBaMM/pull/872))
2021
- Added `CasadiAlgebraicSolver` for solving algebraic systems with CasADi ([#868](https://github.com/pybamm-team/PyBaMM/pull/868))
2122
- Added electrolyte functions from Landesfeind ([#860](https://github.com/pybamm-team/PyBaMM/pull/860))
23+
- Add new symbols `VariableDot`, representing the derivative of a variable wrt time,
24+
and `StateVectorDot`, representing the derivative of a state vector wrt time
25+
([#858](https://github.com/pybamm-team/PyBaMM/issues/858))
2226

2327
## Bug fixes
2428

INSTALL-WINDOWS-WSL.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
We recommend the use of Windows Subsystem for Linux (WSL) to install PyBaMM, see the
2+
instructions below to get PyBaMM working using Windows, WSL and VSCode.
3+
4+
## Install WSL
5+
6+
Follow the instructions from Microsoft
7+
[here](https://docs.microsoft.com/en-us/windows/wsl/install-win10). When given the
8+
option, choose the Ubuntu 18.04 LTS distribution to install. Don't forget to initialise
9+
the Ubuntu installation using the instructions given
10+
[here](https://docs.microsoft.com/en-us/windows/wsl/initialize-distro).
11+
12+
## Install PyBaMM
13+
14+
Open a terminal window in your installed Ubuntu distribution by selecting "Ubuntu" from
15+
the start menu. This should give you a bash prompt in your home directory.
16+
17+
To download the PyBaMM source code, you first need to install git, which you can do by
18+
typing
19+
20+
```bash
21+
sudo apt install git-core
22+
```
23+
24+
For easier integration with WSL, we recommend that you install PyBaMM in your *Windows*
25+
Documents folder, for example by first navigating to
26+
27+
```bash
28+
$ cd /mnt/c/Users/USER_NAME/Documents
29+
```
30+
31+
where USER_NAME is your username. Exact path to Windows documents may vary. Now use git to clone the PyBaMM repository:
32+
33+
```bash
34+
git clone https://github.com/pybamm-team/PyBaMM.git
35+
```
36+
37+
This will create a new directly called `PyBaMM`, you can move to this directory in bash
38+
using the `cd` command:
39+
40+
```bash
41+
cd PyBaMM
42+
```
43+
44+
If you are unfamiliar with the linux command line, you might find it useful to work through this
45+
[tutorial](https://tutorials.ubuntu.com/tutorial/command-line-for-beginners) provided by Ubuntu.
46+
47+
Now head over and follow the installation instructions for PyBaMM for linux
48+
[here](INSTALL-LINUX-MAC.md).
49+
50+
## Use Visual Studio Code to run PyBaMM
51+
52+
You will probably want to use a native Windows IDE such as Visual Studio Code or the
53+
full Microsoft Visual Studio IDE. Both of these packages can connect to WSL so that you
54+
can write python code in a native windows environment, while at the same time using WSL
55+
to run the code using your installed Ubuntu distribution. The following instructions
56+
assume that you are using Visual Studio Code.
57+
58+
First, setup VSCode to run within the `PyBaMM` directory that you created above, using
59+
the instructions provided [here](https://code.visualstudio.com/docs/remote/wsl).
60+
61+
Once you have opened the `PyBaMM` folder in vscode, use the `Extensions` panel to
62+
install the `Python` extension from Microsoft. Note that extensions are either installed
63+
on the Windows (Local) or on in WSL (WSL:Ubuntu), so even if you have used VSCode
64+
previously with the Python extension, you probably haven't installed it in WSL. Make
65+
sure to reload after installing the Python extension so that it is available.
66+
67+
If you have installed PyBaMM into the virtual environment `env` as in the PyBaMM linux
68+
install guide, then VSCode should automatically start using this environment and you
69+
should see something similar to "Python 3.6.8 64-bit ('env': venv)" in the bottom bar.
70+
71+
To test that vscode can run a PyBaMM script, navigate to the `examples/scripts` folder
72+
and right click on the `create-model.py` script. Select "Run current file in Python
73+
Interactive Window". This should run the script, which sets up and solves a model of SEI
74+
thickness using PyBaMM. You should see a plot of SEI thickness versus time pop up in the
75+
interactive window.
76+
77+
The Python Interactive Window in VSCode can be used to view plots, but is restricted in
78+
functionality and cannot, for example, launch separate windows to show plot. To setup an
79+
xserver on windows and use this to launch windows for plotting, follow these
80+
instructions:
81+
82+
1. Install VcXsrv from [here](https://sourceforge.net/projects/vcxsrv/).
83+
1. Set the display port in the WSL command-line: `echo "export DISPLAY=localhost:0.0" >>
84+
~/.bashrc`
85+
1. Install python3-tk in WSL: `sudo apt-get install python3-tk`
86+
1. Set the matplotlib backend to TKAgg in WSL: `echo "backend : TKAgg" >>
87+
~/.config/matplotlib/matplotlibrc`
88+
1. Before running the code, just launch XLaunch (with the default settings) from within
89+
Windows. Then the code works as usual.

INSTALL-WINDOWS.md

+34-69
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,54 @@
1-
We recommend the use of Windows Subsystem for Linux (WSL) to install PyBaMM, see the
2-
instructions below to get PyBaMM working using Windows, WSL and VSCode.
1+
## Prerequisites
32

4-
## Install WSL
3+
To use and/or contribute to PyBaMM, you must have Python 3.6 or 3.7 installed (note that 3.8 is not yet supported).
54

6-
Follow the instructions from Microsoft
7-
[here](https://docs.microsoft.com/en-us/windows/wsl/install-win10). When given the
8-
option, choose the Ubuntu 18.04 LTS distribution to install. Don't forget to initialise
9-
the Ubuntu installation using the instructions given
10-
[here](https://docs.microsoft.com/en-us/windows/wsl/initialize-distro).
5+
To install Python 3 download the installation files from [Python's website](https://www.python.org/downloads/windows/). Make sure
6+
to tick the box on `Add Python 3.X to PATH`. For more detailed instructions please see the
7+
[official Python on Windows guide](https://docs.python.org/3.7/using/windows.html).
118

129
## Install PyBaMM
1310

14-
Open a terminal window in your installed Ubuntu distribution by selecting "Ubuntu" from
15-
the start menu. This should give you a bash prompt in your home directory.
11+
### User install
12+
Launch the Command Prompt and go to the directory where you want to install PyBaMM. You can find a reminder of how to
13+
navigate the terminal [here](http://www.cs.columbia.edu/~sedwards/classes/2015/1102-fall/Command%20Prompt%20Cheatsheet.pdf).
1614

17-
To download the PyBaMM source code, you first need to install git, which you can do by
18-
typing
15+
We recommend to install PyBaMM within a virtual environment, in order not
16+
to alter any distribution python files.
1917

20-
```bash
21-
sudo apt install git-core
22-
```
23-
24-
For easier integration with WSL, we recommend that you install PyBaMM in your *Windows*
25-
Documents folder, for example by first navigating to
18+
To create a virtual environment `env` within your current directory type:
2619

2720
```bash
28-
$ cd /mnt/c/Users/USER_NAME/Documents
21+
python -m venv env
2922
```
30-
31-
where USER_NAME is your username. Exact path to Windows documents may vary. Now use git to clone the PyBaMM repository:
23+
You can then "activate" the environment using:
3224

3325
```bash
34-
git clone https://github.com/pybamm-team/PyBaMM.git
26+
env\Scripts\activate.bat
3527
```
28+
Now all the calls to pip described below will install PyBaMM and its dependencies into
29+
the environment `env`. When you are ready to exit the environment and go back to your
30+
original system, just type:
3631

37-
This will create a new directly called `PyBaMM`, you can move to this directory in bash
38-
using the `cd` command:
39-
40-
```bash
41-
cd PyBaMM
32+
```bash
33+
deactivate
4234
```
4335

44-
If you are unfamiliar with the linux command line, you might find it useful to work through this
45-
[tutorial](https://tutorials.ubuntu.com/tutorial/command-line-for-beginners) provided by Ubuntu.
46-
47-
Now head over and follow the installation instructions for PyBaMM for linux
48-
[here](INSTALL-LINUX-MAC.md).
49-
50-
## Use Visual Studio Code to run PyBaMM
51-
52-
You will probably want to use a native Windows IDE such as Visual Studio Code or the
53-
full Microsoft Visual Studio IDE. Both of these packages can connect to WSL so that you
54-
can write python code in a native windows environment, while at the same time using WSL
55-
to run the code using your installed Ubuntu distribution. The following instructions
56-
assume that you are using Visual Studio Code.
57-
58-
First, setup VSCode to run within the `PyBaMM` directory that you created above, using
59-
the instructions provided [here](https://code.visualstudio.com/docs/remote/wsl).
60-
61-
Once you have opened the `PyBaMM` folder in vscode, use the `Extensions` panel to
62-
install the `Python` extension from Microsoft. Note that extensions are either installed
63-
on the Windows (Local) or on in WSL (WSL:Ubuntu), so even if you have used VSCode
64-
previously with the Python extension, you probably haven't installed it in WSL. Make
65-
sure to reload after installing the Python extension so that it is available.
36+
PyBaMM can be installed via pip:
37+
```bash
38+
pip install pybamm
39+
```
6640

67-
If you have installed PyBaMM into the virtual environment `env` as in the PyBaMM linux
68-
install guide, then VSCode should automatically start using this environment and you
69-
should see something similar to "Python 3.6.8 64-bit ('env': venv)" in the bottom bar.
41+
PyBaMM's dependencies (such as `numpy`, `scipy`, etc) will be installed automatically when you install PyBaMM using `pip`.
7042

71-
To test that vscode can run a PyBaMM script, navigate to the `examples/scripts` folder
72-
and right click on the `create-model.py` script. Select "Run current file in Python
73-
Interactive Window". This should run the script, which sets up and solves a model of SEI
74-
thickness using PyBaMM. You should see a plot of SEI thickness versus time pop up in the
75-
interactive window.
43+
For an introduction to virtual environments, see (https://realpython.com/python-virtual-environments-a-primer/).
7644

77-
The Python Interactive Window in VSCode can be used to view plots, but is restricted in
78-
functionality and cannot, for example, launch separate windows to show plot. To setup an
79-
xserver on windows and use this to launch windows for plotting, follow these
80-
instructions:
45+
## Uninstall PyBaMM
46+
PyBaMM can be uninstalled by running
47+
```bash
48+
pip uninstall pybamm
49+
```
50+
in your virtual environment.
8151

82-
1. Install VcXsrv from [here](https://sourceforge.net/projects/vcxsrv/).
83-
1. Set the display port in the WSL command-line: `echo "export DISPLAY=localhost:0.0" >>
84-
~/.bashrc`
85-
1. Install python3-tk in WSL: `sudo apt-get install python3-tk`
86-
1. Set the matplotlib backend to TKAgg in WSL: `echo "backend : TKAgg" >>
87-
~/.config/matplotlib/matplotlibrc`
88-
1. Before running the code, just launch XLaunch (with the default settings) from within
89-
Windows. Then the code works as usual.
52+
## Installation using WSL
53+
If you want to install the optional PyBaMM solvers, you have to use the Windows Subsystem for Linux (WSL). You can find
54+
the installation instructions [here](INSTALL-WINDOWS-WSL.md).

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,15 @@ For further examples, see the list of repositories that use PyBaMM [here](https:
5353

5454
### Linux
5555

56-
For instructions on installing PyBaMM on Debian-based distributions, please see [here](INSTALL-LINUX-MAC.md)
56+
For instructions on installing PyBaMM on Debian-based distributions, please see [here](INSTALL-LINUX-MAC.md).
5757

5858
### Mac OS
5959

60-
For instructions on installing PyBaMM on Mac OS distributions, please see [here](INSTALL-LINUX-MAC.md)
60+
For instructions on installing PyBaMM on Mac OS distributions, please see [here](INSTALL-LINUX-MAC.md).
6161

6262
### Windows
6363

64-
We recommend using Windows Subsystem for Linux to install PyBaMM on a Windows OS, for
65-
instructions please see [here](INSTALL-WINDOWS.md)
64+
For instructions on installing PyBaMM on Windows distributions, please see [here](INSTALL-WINDOWS.md). If you want to install the optional solvers (such as scikits-odes and KLU solvers), install PyBaMM on the Windows Subsystem for Linux following the instructions [here](INSTALL-WINDOWS-WSL.md)
6665

6766
## Citing PyBaMM
6867

examples/notebooks/Creating Models/1-an-ode-model.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
"name": "python",
272272
"nbconvert_exporter": "python",
273273
"pygments_lexer": "ipython3",
274-
"version": "3.6.9"
274+
"version": "3.7.5"
275275
}
276276
},
277277
"nbformat": 4,

examples/notebooks/Creating Models/2-a-pde-model.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
"name": "python",
299299
"nbconvert_exporter": "python",
300300
"pygments_lexer": "ipython3",
301-
"version": "3.6.9"
301+
"version": "3.7.5"
302302
}
303303
},
304304
"nbformat": 4,

examples/notebooks/Creating Models/3-negative-particle-problem.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
"name": "python",
317317
"nbconvert_exporter": "python",
318318
"pygments_lexer": "ipython3",
319-
"version": "3.6.9"
319+
"version": "3.7.5"
320320
}
321321
},
322322
"nbformat": 4,

examples/notebooks/Creating Models/4-comparing-full-and-reduced-order-models.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@
375375
"name": "python",
376376
"nbconvert_exporter": "python",
377377
"pygments_lexer": "ipython3",
378-
"version": "3.6.9"
378+
"version": "3.7.5"
379379
}
380380
},
381381
"nbformat": 4,

examples/notebooks/Creating Models/5-a-simple-SEI-model.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
"c_inf_dim = pybamm.Parameter(\"Bulk electrolyte solvent concentration\")\n",
250250
"\n",
251251
"def D_dim(cc):\n",
252-
" return pybamm.FunctionParameter(\"Diffusivity\", cc)\n",
252+
" return pybamm.FunctionParameter(\"Diffusivity\", {\"Solvent concentration [mol.m-3]\": cc})\n",
253253
"\n",
254254
"# dimensionless parameters\n",
255255
"k = k_dim * L_0_dim / D_dim(c_inf_dim)\n",
@@ -591,7 +591,7 @@
591591
{
592592
"data": {
593593
"application/vnd.jupyter.widget-view+json": {
594-
"model_id": "b2a5f649a3b64685ad9510649f130829",
594+
"model_id": "efe1fe18458a42d88056baf689f6da80",
595595
"version_major": 2,
596596
"version_minor": 0
597597
},
@@ -653,7 +653,7 @@
653653
"name": "python",
654654
"nbconvert_exporter": "python",
655655
"pygments_lexer": "ipython3",
656-
"version": "3.6.9"
656+
"version": "3.7.5"
657657
}
658658
},
659659
"nbformat": 4,

examples/notebooks/parameter-values.ipynb

+9-9
Large diffs are not rendered by default.

examples/scripts/create-model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
def D_dim(cc):
21-
return pybamm.FunctionParameter("Diffusivity", cc)
21+
return pybamm.FunctionParameter("Diffusivity", {"Concentration [mol.m-3]": cc})
2222

2323

2424
# dimensionless parameters

0 commit comments

Comments
 (0)