Skip to content

Commit

Permalink
#692 merged from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmar93 committed Nov 12, 2019
2 parents 1b9d527 + 7f7254c commit 9deb90c
Show file tree
Hide file tree
Showing 105 changed files with 2,459 additions and 1,887 deletions.
29 changes: 16 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,32 @@
## Features

- Added Simulation class ([#693](https://github.com/pybamm-team/PyBaMM/pull/693))
- Add interface to CasADi solver ([#687](https://github.com/pybamm-team/PyBaMM/pull/687))
- Add option to use CasADi's Algorithmic Differentiation framework to calculate Jacobians ([#687](https://github.com/pybamm-team/PyBaMM/pull/687))
- Add method to evaluate parameters more easily ([#669](https://github.com/pybamm-team/PyBaMM/pull/669))
- Add `Jacobian` class to reuse known Jacobians of expressions ([#665](https://github.com/pybamm-team/PyBaMM/pull/670))
- Add `Interpolant` class to interpolate experimental data (e.g. OCP curves) ([#661](https://github.com/pybamm-team/PyBaMM/pull/661))
- Added interface to CasADi solver ([#687](https://github.com/pybamm-team/PyBaMM/pull/687), [#691](https://github.com/pybamm-team/PyBaMM/pull/691), [#714](https://github.com/pybamm-team/PyBaMM/pull/714)). This makes the SUNDIALS DAE solvers (Scikits and KLU) truly optional (though IDA KLU is recommended for solving the DFN).
- Added option to use CasADi's Algorithmic Differentiation framework to calculate Jacobians ([#687](https://github.com/pybamm-team/PyBaMM/pull/687))
- Added method to evaluate parameters more easily ([#669](https://github.com/pybamm-team/PyBaMM/pull/669))
- Added `Jacobian` class to reuse known Jacobians of expressions ([#665](https://github.com/pybamm-team/PyBaMM/pull/670))
- Added `Interpolant` class to interpolate experimental data (e.g. OCP curves) ([#661](https://github.com/pybamm-team/PyBaMM/pull/661))
- Added interface (via pybind11) to sundials with the IDA KLU sparse linear solver ([#657](https://github.com/pybamm-team/PyBaMM/pull/657))
- Allow parameters to be set by material or by specifying a particular paper ([#647](https://github.com/pybamm-team/PyBaMM/pull/647))
- Allowed parameters to be set by material or by specifying a particular paper ([#647](https://github.com/pybamm-team/PyBaMM/pull/647))
- Set relative and absolute tolerances independently in solvers ([#645](https://github.com/pybamm-team/PyBaMM/pull/645))
- Add basic method to allow (a part of) the State Vector to be updated with results obtained from another solution or package ([#624](https://github.com/pybamm-team/PyBaMM/pull/624))
- Add some non-uniform meshes in 1D and 2D ([#617](https://github.com/pybamm-team/PyBaMM/pull/617))
- Added basic method to allow (a part of) the State Vector to be updated with results obtained from another solution or package ([#624](https://github.com/pybamm-team/PyBaMM/pull/624))
- Added some non-uniform meshes in 1D and 2D ([#617](https://github.com/pybamm-team/PyBaMM/pull/617))

## Optimizations

- Use CasADi's automatic differentation algorithms by default when solving a model ([#714](https://github.com/pybamm-team/PyBaMM/pull/714))
- Avoid re-checking size when making a copy of an `Index` object ([#656](https://github.com/pybamm-team/PyBaMM/pull/656))
- Avoid recalculating `_evaluation_array` when making a copy of a `StateVector` object ([#653](https://github.com/pybamm-team/PyBaMM/pull/653))

## Bug fixes

- Pass the correct dimensional temperature to open circuit potential ([#702](https://github.com/pybamm-team/PyBaMM/pull/702))
- Adds missing temperature dependence in electrolyte and interface submodels ([#698](https://github.com/pybamm-team/PyBaMM/pull/698))
- Fix differentiation of functions that have more than one argument ([#687](https://github.com/pybamm-team/PyBaMM/pull/687))
- Add warning if `ProcessedVariable` is called outside its interpolation range ([#681](https://github.com/pybamm-team/PyBaMM/pull/681))
- Improve the way `ProcessedVariable` objects are created in higher dimensions ([#581](https://github.com/pybamm-team/PyBaMM/pull/581))
- Fixed a bug where boundary conditions were sometimes handled incorrectly in 1+1D models ([#713](https://github.com/pybamm-team/PyBaMM/pull/713))
- Corrected a sign error in Dirichlet boundary conditions in the Finite Element Method ([#706](https://github.com/pybamm-team/PyBaMM/pull/706))
- Passed the correct dimensional temperature to open circuit potential ([#702](https://github.com/pybamm-team/PyBaMM/pull/702))
- Added missing temperature dependence in electrolyte and interface submodels ([#698](https://github.com/pybamm-team/PyBaMM/pull/698))
- Fixed differentiation of functions that have more than one argument ([#687](https://github.com/pybamm-team/PyBaMM/pull/687))
- Added warning if `ProcessedVariable` is called outside its interpolation range ([#681](https://github.com/pybamm-team/PyBaMM/pull/681))
- Improved the way `ProcessedVariable` objects are created in higher dimensions ([#581](https://github.com/pybamm-team/PyBaMM/pull/581))

# [v0.1.0](https://github.com/pybamm-team/PyBaMM/tree/v0.1.0) - 2019-10-08

Expand Down
16 changes: 8 additions & 8 deletions INSTALL-LINUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,25 @@ Before installing scikits.odes, you need to have installed:
- Fortran compiler (e.g. gfortran)
- BLAS/LAPACK install (OpenBLAS is recommended by the scikits.odes developers)
- CMake (for building Sundials)
- Sundials 3.1.1
- Sundials 4.1.0

You can install these on Ubuntu or Debian using apt-get:

```bash
sudo apt-get install python3-dev gfortran gcc cmake libopenblas-dev
```

To install Sundials 3.1.1, on the command-line type:
To install Sundials 4.1.0, on the command-line type:

```bash
INSTALL_DIR=`pwd`/sundials
wget https://computation.llnl.gov/projects/sundials/download/sundials-3.1.1.tar.gz
tar -xvf sundials-3.1.1.tar.gz
mkdir build-sundials-3.1.1
cd build-sundials-3.1.1/
cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_TYPE=int32_t -DBUILD_ARKODE:BOOL=OFF -DEXAMPLES_ENABLE:BOOL=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ../sundials-3.1.1/
wget https://computation.llnl.gov/projects/sundials/download/sundials-4.1.0.tar.gz
tar -xvf sundials-4.1.0.tar.gz
mkdir build-sundials-4.1.0
cd build-sundials-4.1.0/
cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_TYPE=int32_t -DBUILD_ARKODE:BOOL=OFF -DEXAMPLES_ENABLE:BOOL=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ../sundials-4.1.0/
make install
rm -r ../sundials-3.1.1
rm -r ../sundials-4.1.0
```

Then install [scikits.odes](https://github.com/bmcage/odes), letting it know the sundials install location:
Expand Down
78 changes: 21 additions & 57 deletions examples/notebooks/change-input-current.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"\n",
"In this notebook we will use the SPM as the example model, and change the input current from the default option. If you are not familiar with running a model in PyBaMM, please see [this](./models/SPM.ipynb) notebook for more details.\n",
"\n",
"In PyBaMM, the current function is set using the parameter \"Current function\". By default this is set to be a constant current provided by the class [`pybamm.GetConstantCurrent`](https://pybamm.readthedocs.io/en/latest/source/parameters/standard_current_functions/get_constant_current.html). This class takes a single optional argument \"current\" which is the size of the current in Amperes. If no argument is passed, the value of the current is set by the parameter \"Typical current [A]\" (see [this](parameter-values.ipynb) notebook for more information about parameters).\n",
"In PyBaMM, the current function is set using the parameter \"Current function\". By default this is set to be a constant current provided by the class [`pybamm.ConstantCurrent`](https://pybamm.readthedocs.io/en/latest/source/parameters/standard_current_functions/get_constant_current.html). This class takes a single optional argument \"current\" which is the size of the current in Amperes. If no argument is passed, the value of the current is set by the parameter \"Typical current [A]\" (see [this](parameter-values.ipynb) notebook for more information about parameters).\n",
"\n",
"In general it is recommended to change the size of a constant current input by changing the parameter \"Typical current [A]\", since this value is used to non-dimensionlise the model. Below we load the SPM with the default parameters, and then change the the typical current 16A. We then explicilty set the current function to be a constant current."
]
Expand All @@ -49,14 +49,14 @@
"\n",
"# change the typical current and set a constant discharge using the typical current value\n",
"param[\"Typical current [A]\"] = 16\n",
"param[\"Current function\"] = pybamm.GetConstantCurrent()\n"
"param[\"Current function\"] = pybamm.ConstantCurrent()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"However, you may wish to change the value of the constant current without altering the typical current value used for non-dimensionlidation. For instance, the current function could be change to draw a current of 8A by updating the current function and passing the optional argument \"current\" to the class `GetConstantCurrent`"
"However, you may wish to change the value of the constant current without altering the typical current value used for non-dimensionlidation. For instance, the current function could be change to draw a current of 8A by updating the current function and passing the optional argument \"current\" to the class `ConstantCurrent`"
]
},
{
Expand All @@ -66,7 +66,7 @@
"outputs": [],
"source": [
"# update the value of the current profile *without* changing the typical current used for non-dimensionlisation\n",
"param[\"Current function\"] = pybamm.GetConstantCurrent(current=pybamm.Scalar(8))"
"param[\"Current function\"] = pybamm.ConstantCurrent(current=pybamm.Scalar(8))"
]
},
{
Expand All @@ -84,7 +84,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fc997d14787542f69f2cba123ce0b994",
"model_id": "b900a39a72704c88927058510b7913b2",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -127,11 +127,7 @@
"source": [
"## Loading in current data <a name=\"data\"></a>\n",
"\n",
"Data can be loaded in from a csv file using the class [`pybamm.GetCurrentData`](https://pybamm.readthedocs.io/en/latest/source/parameters/standard_current_functions/get_current_data). Data should be given as a function of time (in seconds) and may be dimensional (in Amperes) or non-diemsnional (e.g. C-rate). Optionally, voltage data (in Volts) may be loaded in for convinient plotting and comparison. \n",
"\n",
"The input csv files should be stored in PyBaMM/input/drive_cycles and have the headings: \"time [s]\"; either \"current [A]\" for dimensional data, or \"current []\" for dimensionless data; and, optionally, \"voltage [V]\". \n",
"\n",
"To load in dimensional data we simply provide the filename and set the units to \"[A]\", e.g."
"Data can be loaded in from a csv file by specifying the path to that file and using the prefix \"[current data]\"."
]
},
{
Expand All @@ -140,54 +136,30 @@
"metadata": {},
"outputs": [],
"source": [
"param[\"Current function\"] = pybamm.GetCurrentData(\"US06.csv\", units=\"[A]\")"
"param[\"Current function\"] = \"[current data]US06\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For non dimensional data, you also need to provide a current scale. For instance, if the data were C-rate then you would set the current scale to the 1C discharge current. If the 1C discharge current were 24 A and we had some C-rate data in the file car_current.csv, this would be loaded in as"
"As an example, we show how to solve the SPM using the US06 drive cycle"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"param[\"Current function\"] = pybamm.GetCurrentData(\"car_current.csv\", units=\"[]\", current_scale=24)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As an example, we how to solve the SPM using the US06 drive cycle"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/user/Documents/PyBaMM/pybamm/parameters/standard_current_functions/get_current_data.py:88: ModelWarning: Requested time (2387.404004088835) is outside of the data range [0, 600]\n",
" pybamm.ModelWarning,\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3f4c99601ab8417ba2186987cb532600",
"model_id": "26e7b28104b34991b3ebac266dab4934",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.03900922998674932, step=0.001), Output()),"
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.026526276390989537, step=0.001), Output())…"
]
},
"metadata": {},
Expand All @@ -202,7 +174,7 @@
"\n",
"# load parameter values and process model and geometry\n",
"param = model.default_parameter_values\n",
"param[\"Current function\"] = pybamm.GetCurrentData(\"US06.csv\", units=\"[A]\")\n",
"param[\"Current function\"] = \"[current data]US06\"\n",
"param.process_model(model)\n",
"param.process_geometry(geometry)\n",
"\n",
Expand Down Expand Up @@ -240,14 +212,14 @@
"source": [
"## Adding your own current function <a name=\"function\"></a>\n",
"\n",
"A user defined current function can be passed to any model using the class [`pybamm.GetUserCurrent`](https://pybamm.readthedocs.io/en/latest/source/parameters/standard_current_functions/get_user_current). The class takes in a method, which returns the current as a function of time, followed by any keyword arguments required by the method. \n",
"A user defined current function can be passed to any model using the class [`pybamm.UserCurrent`](https://pybamm.readthedocs.io/en/latest/source/parameters/standard_current_functions/get_user_current). The class takes in a method, which returns the current as a function of time, followed by any keyword arguments required by the method. \n",
"\n",
"For example, you may want to simulate a sinusoidal current with amplitude A and freqency omega. In order to do so you must first define the method"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -262,12 +234,12 @@
"source": [
"Note that time *must* me the first arguemnt of the function. The parameters may either be provided as floats, or may be one of the standard parameters provided in PyBaMM (see [here](https://pybamm.readthedocs.io/en/latest/source/parameters)). \n",
"\n",
"The the model may be loaded and the \"Current function\" parameter updated to be a `GetUserCurrent` class which calls `my_fun`"
"The the model may be loaded and the \"Current function\" parameter updated to be a `UserCurrent` class which calls `my_fun`"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -282,7 +254,7 @@
"# set user defined current function\n",
"A = pybamm.electrical_parameters.I_typ\n",
"omega = 0.1\n",
"param[\"Current function\"] = pybamm.GetUserCurrent(my_fun, A=A, omega=omega)\n",
"param[\"Current function\"] = pybamm.UserCurrent(my_fun, A=A, omega=omega)\n",
"\n",
"# process model and geometry\n",
"param.process_model(model)\n",
Expand All @@ -293,31 +265,23 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that the parameters in `my_fun` were passed as keyword arguments to the `GetUserCurrent` class. The model may then be solved in the usual way"
"Note that the parameters in `my_fun` were passed as keyword arguments to the `UserCurrent` class. The model may then be solved in the usual way"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/user/Documents/PyBaMM/venv/lib/python3.6/site-packages/ipykernel_launcher.py:12: DeprecationWarning: object of type <class 'float'> cannot be safely interpreted as an integer.\n",
" if sys.path[0] == '':\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "913efe4e3e9e4b37bad2ded9c71b975e",
"model_id": "629672e99152464dad01e57ff152347a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.0019504614993374662, step=9.75230749668733"
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.0013263138195494769, step=6.63156909774738"
]
},
"metadata": {},
Expand Down Expand Up @@ -372,7 +336,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 9deb90c

Please sign in to comment.