Skip to content

Commit

Permalink
#546 merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Mar 30, 2020
2 parents 50c4f8c + bed4ae3 commit 6f454f2
Show file tree
Hide file tree
Showing 29 changed files with 478 additions and 185 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
- Added functionality to broadcast to edges ([#891](https://github.com/pybamm-team/PyBaMM/pull/891))
- Reformatted and cleaned up `QuickPlot` ([#886](https://github.com/pybamm-team/PyBaMM/pull/886))
- Added thermal effects to lead-acid models ([#885](https://github.com/pybamm-team/PyBaMM/pull/885))
- Add new symbols `VariableDot`, representing the derivative of a variable wrt time,
and `StateVectorDot`, representing the derivative of a state vector wrt time
([#858](https://github.com/pybamm-team/PyBaMM/issues/858))
- Added a helper function for info on function parameters ([#881](https://github.com/pybamm-team/PyBaMM/pull/881))
- Added additional notebooks showing how to create and compare models ([#877](https://github.com/pybamm-team/PyBaMM/pull/877))
- Added `Minimum`, `Maximum` and `Sign` operators
([#876](https://github.com/pybamm-team/PyBaMM/pull/876))
- Added a search feature to `FuzzyDict` ([#875](https://github.com/pybamm-team/PyBaMM/pull/875))
- Add ambient temperature as a function of time ([#872](https://github.com/pybamm-team/PyBaMM/pull/872))
- Added `CasadiAlgebraicSolver` for solving algebraic systems with CasADi ([#868](https://github.com/pybamm-team/PyBaMM/pull/868))
- Added electrolyte functions from Landesfeind ([#860](https://github.com/pybamm-team/PyBaMM/pull/860))
- Add new symbols `VariableDot`, representing the derivative of a variable wrt time,
and `StateVectorDot`, representing the derivative of a state vector wrt time
([#858](https://github.com/pybamm-team/PyBaMM/issues/858))

## Optimizations

Expand Down
89 changes: 89 additions & 0 deletions INSTALL-WINDOWS-WSL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
We recommend the use of Windows Subsystem for Linux (WSL) to install PyBaMM, see the
instructions below to get PyBaMM working using Windows, WSL and VSCode.

## Install WSL

Follow the instructions from Microsoft
[here](https://docs.microsoft.com/en-us/windows/wsl/install-win10). When given the
option, choose the Ubuntu 18.04 LTS distribution to install. Don't forget to initialise
the Ubuntu installation using the instructions given
[here](https://docs.microsoft.com/en-us/windows/wsl/initialize-distro).

## Install PyBaMM

Open a terminal window in your installed Ubuntu distribution by selecting "Ubuntu" from
the start menu. This should give you a bash prompt in your home directory.

To download the PyBaMM source code, you first need to install git, which you can do by
typing

```bash
sudo apt install git-core
```

For easier integration with WSL, we recommend that you install PyBaMM in your *Windows*
Documents folder, for example by first navigating to

```bash
$ cd /mnt/c/Users/USER_NAME/Documents
```

where USER_NAME is your username. Exact path to Windows documents may vary. Now use git to clone the PyBaMM repository:

```bash
git clone https://github.com/pybamm-team/PyBaMM.git
```

This will create a new directly called `PyBaMM`, you can move to this directory in bash
using the `cd` command:

```bash
cd PyBaMM
```

If you are unfamiliar with the linux command line, you might find it useful to work through this
[tutorial](https://tutorials.ubuntu.com/tutorial/command-line-for-beginners) provided by Ubuntu.

Now head over and follow the installation instructions for PyBaMM for linux
[here](INSTALL-LINUX-MAC.md).

## Use Visual Studio Code to run PyBaMM

You will probably want to use a native Windows IDE such as Visual Studio Code or the
full Microsoft Visual Studio IDE. Both of these packages can connect to WSL so that you
can write python code in a native windows environment, while at the same time using WSL
to run the code using your installed Ubuntu distribution. The following instructions
assume that you are using Visual Studio Code.

First, setup VSCode to run within the `PyBaMM` directory that you created above, using
the instructions provided [here](https://code.visualstudio.com/docs/remote/wsl).

Once you have opened the `PyBaMM` folder in vscode, use the `Extensions` panel to
install the `Python` extension from Microsoft. Note that extensions are either installed
on the Windows (Local) or on in WSL (WSL:Ubuntu), so even if you have used VSCode
previously with the Python extension, you probably haven't installed it in WSL. Make
sure to reload after installing the Python extension so that it is available.

If you have installed PyBaMM into the virtual environment `env` as in the PyBaMM linux
install guide, then VSCode should automatically start using this environment and you
should see something similar to "Python 3.6.8 64-bit ('env': venv)" in the bottom bar.

To test that vscode can run a PyBaMM script, navigate to the `examples/scripts` folder
and right click on the `create-model.py` script. Select "Run current file in Python
Interactive Window". This should run the script, which sets up and solves a model of SEI
thickness using PyBaMM. You should see a plot of SEI thickness versus time pop up in the
interactive window.

The Python Interactive Window in VSCode can be used to view plots, but is restricted in
functionality and cannot, for example, launch separate windows to show plot. To setup an
xserver on windows and use this to launch windows for plotting, follow these
instructions:

1. Install VcXsrv from [here](https://sourceforge.net/projects/vcxsrv/).
1. Set the display port in the WSL command-line: `echo "export DISPLAY=localhost:0.0" >>
~/.bashrc`
1. Install python3-tk in WSL: `sudo apt-get install python3-tk`
1. Set the matplotlib backend to TKAgg in WSL: `echo "backend : TKAgg" >>
~/.config/matplotlib/matplotlibrc`
1. Before running the code, just launch XLaunch (with the default settings) from within
Windows. Then the code works as usual.
103 changes: 34 additions & 69 deletions INSTALL-WINDOWS.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,54 @@
We recommend the use of Windows Subsystem for Linux (WSL) to install PyBaMM, see the
instructions below to get PyBaMM working using Windows, WSL and VSCode.
## Prerequisites

## Install WSL
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).

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

## Install PyBaMM

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

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

```bash
sudo apt install git-core
```

For easier integration with WSL, we recommend that you install PyBaMM in your *Windows*
Documents folder, for example by first navigating to
To create a virtual environment `env` within your current directory type:

```bash
$ cd /mnt/c/Users/USER_NAME/Documents
python -m venv env
```

where USER_NAME is your username. Exact path to Windows documents may vary. Now use git to clone the PyBaMM repository:
You can then "activate" the environment using:

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

This will create a new directly called `PyBaMM`, you can move to this directory in bash
using the `cd` command:

```bash
cd PyBaMM
```bash
deactivate
```

If you are unfamiliar with the linux command line, you might find it useful to work through this
[tutorial](https://tutorials.ubuntu.com/tutorial/command-line-for-beginners) provided by Ubuntu.

Now head over and follow the installation instructions for PyBaMM for linux
[here](INSTALL-LINUX-MAC.md).

## Use Visual Studio Code to run PyBaMM

You will probably want to use a native Windows IDE such as Visual Studio Code or the
full Microsoft Visual Studio IDE. Both of these packages can connect to WSL so that you
can write python code in a native windows environment, while at the same time using WSL
to run the code using your installed Ubuntu distribution. The following instructions
assume that you are using Visual Studio Code.

First, setup VSCode to run within the `PyBaMM` directory that you created above, using
the instructions provided [here](https://code.visualstudio.com/docs/remote/wsl).

Once you have opened the `PyBaMM` folder in vscode, use the `Extensions` panel to
install the `Python` extension from Microsoft. Note that extensions are either installed
on the Windows (Local) or on in WSL (WSL:Ubuntu), so even if you have used VSCode
previously with the Python extension, you probably haven't installed it in WSL. Make
sure to reload after installing the Python extension so that it is available.
PyBaMM can be installed via pip:
```bash
pip install pybamm
```

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

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

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

1. Install VcXsrv from [here](https://sourceforge.net/projects/vcxsrv/).
1. Set the display port in the WSL command-line: `echo "export DISPLAY=localhost:0.0" >>
~/.bashrc`
1. Install python3-tk in WSL: `sudo apt-get install python3-tk`
1. Set the matplotlib backend to TKAgg in WSL: `echo "backend : TKAgg" >>
~/.config/matplotlib/matplotlibrc`
1. Before running the code, just launch XLaunch (with the default settings) from within
Windows. Then the code works as usual.
## Installation using WSL
If you want to install the optional PyBaMM solvers, you have to use the Windows Subsystem for Linux (WSL). You can find
the installation instructions [here](INSTALL-WINDOWS-WSL.md).
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@ For further examples, see the list of repositories that use PyBaMM [here](https:

### Linux

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

### Mac OS

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

### Windows

We recommend using Windows Subsystem for Linux to install PyBaMM on a Windows OS, for
instructions please see [here](INSTALL-WINDOWS.md)
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)

## Citing PyBaMM

Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/Creating Models/1-an-ode-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/Creating Models/2-a-pde-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.5"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.5"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/Creating Models/5-a-simple-SEI-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
"c_inf_dim = pybamm.Parameter(\"Bulk electrolyte solvent concentration\")\n",
"\n",
"def D_dim(cc):\n",
" return pybamm.FunctionParameter(\"Diffusivity\", cc)\n",
" return pybamm.FunctionParameter(\"Diffusivity\", {\"Solvent concentration [mol.m-3]\": cc})\n",
"\n",
"# dimensionless parameters\n",
"k = k_dim * L_0_dim / D_dim(c_inf_dim)\n",
Expand Down Expand Up @@ -591,7 +591,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b2a5f649a3b64685ad9510649f130829",
"model_id": "efe1fe18458a42d88056baf689f6da80",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -653,7 +653,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.5"
}
},
"nbformat": 4,
Expand Down
18 changes: 9 additions & 9 deletions examples/notebooks/parameter-values.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/scripts/create-model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


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


# dimensionless parameters
Expand Down
Loading

0 comments on commit 6f454f2

Please sign in to comment.