Skip to content

Commit

Permalink
Merge pull request pybamm-team#931 from pybamm-team/develop
Browse files Browse the repository at this point in the history
Version 0.2.1 develop -> master
  • Loading branch information
valentinsulzer authored Mar 31, 2020
2 parents 801492b + 4cc26b1 commit 105714c
Show file tree
Hide file tree
Showing 327 changed files with 8,649 additions and 4,031 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exclude=
share,
pyvenv.cfg,
third-party,
sundials-5.0.0,
ignore=
# False positive for white space before ':' on list slice
# black should format these correctly
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ input/*
!input/comsol_results/
!input/drive_cycles

# keep images required by notebooks
!examples/notebooks/Creating%20Models/SEI.png

# simulation outputs
out/
config.py
Expand All @@ -59,6 +62,7 @@ htmlcov/
pyproject.toml

# virtual enviroment
env/
venv/
venv3.5/
PyBaMM-env/
Expand Down
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
# [v0.2.1](https://github.com/pybamm-team/PyBaMM/tree/v0.2.1) - 2020-03-31

New expression tree node types, models, parameter sets and solvers, as well as general bug fixes and new examples.

## Features

- Store variable slices in model for inspection ([#925](https://github.com/pybamm-team/PyBaMM/pull/925))
- Added LiNiCoO2 parameter set from Ecker et. al. ([#922](https://github.com/pybamm-team/PyBaMM/pull/922))
- Made t_plus (optionally) a function of electrolyte concentration, and added (1 + dlnf/dlnc) to models ([#921](https://github.com/pybamm-team/PyBaMM/pull/921))
- Added `DummySolver` for empty models ([#915](https://github.com/pybamm-team/PyBaMM/pull/915))
- 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))

## Bug fixes

- Fixed tight layout for QuickPlot in jupyter notebooks ([#930](https://github.com/pybamm-team/PyBaMM/pull/930))
- Fixed bug raised if function returns a scalar ([#919](https://github.com/pybamm-team/PyBaMM/pull/919))
- Fixed event handling in `ScipySolver` ([#905](https://github.com/pybamm-team/PyBaMM/pull/905))
- Made input handling clearer in solvers ([#905](https://github.com/pybamm-team/PyBaMM/pull/905))
- Updated Getting started notebook 2 ([#903](https://github.com/pybamm-team/PyBaMM/pull/903))
- Reformatted external circuit submodels ([#879](https://github.com/pybamm-team/PyBaMM/pull/879))
- Some bug fixes to generalize specifying models that aren't battery models, see [#846](https://github.com/pybamm-team/PyBaMM/issues/846)
- Reformatted interface submodels to be more readable ([#866](https://github.com/pybamm-team/PyBaMM/pull/866))
- Removed double-counted "number of electrodes connected in parallel" from simulation ([#864](https://github.com/pybamm-team/PyBaMM/pull/864))

## Breaking changes

- Changed keyword argument `u` for inputs (when evaluating an object) to `inputs` ([#905](https://github.com/pybamm-team/PyBaMM/pull/905))
- Removed "set external temperature" and "set external potential" options. Use "external submodels" option instead ([#862](https://github.com/pybamm-team/PyBaMM/pull/862))

# [v0.2.0](https://github.com/pybamm-team/PyBaMM/tree/v0.2.0) - 2020-02-26

This release introduces many new features and optimizations. All models can now be solved using the pip installation - in particular, the DFN can be solved in around 0.1s. Other highlights include an improved user interface, simulations of experimental protocols (GITT, CCCV, etc), new parameter sets for NCA and LGM50, drive cycles, "input parameters" and "external variables" for quickly solving models with different parameter values and coupling with external software, and general bug fixes and optimizations.
Expand Down
46 changes: 46 additions & 0 deletions CODE-OF-CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# PyBaMM Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
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 docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# The short X.Y version
version = "0.2"
# The full version, including alpha/beta/rc tags
release = "0.2.0"
release = "0.2.1"


# -- General configuration ---------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ Contents
source/spatial_methods/index
source/solvers/index
source/experiments/index
source/simulation
source/quick_plot
source/processed_variable
source/util
source/simulation
source/citations
source/parameters_cli

Expand Down
16 changes: 16 additions & 0 deletions docs/source/expression_tree/binary_operator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,20 @@ Binary Operators
.. autoclass:: pybamm.Heaviside
:members:

.. autoclass:: pybamm.EqualHeaviside
:members:

.. autoclass:: pybamm.NotEqualHeaviside
:members:

.. autoclass:: pybamm.Minimum
:members:

.. autoclass:: pybamm.Maximum
:members:

.. autofunction:: pybamm.minimum

.. autofunction:: pybamm.maximum

.. autofunction:: pybamm.source
Loading

0 comments on commit 105714c

Please sign in to comment.