Skip to content

Commit

Permalink
Merge pull request #751 from pybamm-team/issue-492-potentiostatic
Browse files Browse the repository at this point in the history
Issue 492 potentiostatic
  • Loading branch information
valentinsulzer authored Dec 14, 2019
2 parents c75de8c + b54eb0e commit 2ca2598
Show file tree
Hide file tree
Showing 96 changed files with 1,095 additions and 531 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Features

- Added `InputParameter` node for quickly changing parameter values ([#752](https://github.com/pybamm-team/PyBaMM/pull/752))
- Added submodels for operating modes other than current-controlled ([#751](https://github.com/pybamm-team/PyBaMM/pull/751))
- Added optional R(x) distribution in particle models ([#745](https://github.com/pybamm-team/PyBaMM/pull/745))
- Generalized importing of external variables ([#728](https://github.com/pybamm-team/PyBaMM/pull/728))
- Separated active and inactive material volume fractions ([#726](https://github.com/pybamm-team/PyBaMM/pull/726))
Expand Down Expand Up @@ -33,6 +34,7 @@

## Bug fixes

- Improved automatic broadcasting ([#747](https://github.com/pybamm-team/PyBaMM/pull/747))
- Fixed bug with wrong temperature in initial conditions ([#737](https://github.com/pybamm-team/PyBaMM/pull/737))
- Improved flexibility of parameter values so that parameters (such as diffusivity or current) can be set as functions or scalars ([#723](https://github.com/pybamm-team/PyBaMM/pull/723))
- Fixed a bug where boundary conditions were sometimes handled incorrectly in 1+1D models ([#713](https://github.com/pybamm-team/PyBaMM/pull/713))
Expand All @@ -49,6 +51,7 @@
- The parameters "Bruggeman coefficient" must now be specified separately as "Bruggeman coefficient (electrolyte)" and "Bruggeman coefficient (electrode)"
- The current classes (`GetConstantCurrent`, `GetUserCurrent` and `GetUserData`) have now been removed. Please refer to the [`change-input-current` notebook](https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/change-input-current.ipynb) for information on how to specify an input current
- Parameter functions must now use pybamm functions instead of numpy functions (e.g. `pybamm.exp` instead of `numpy.exp`), as these are then used to construct the expression tree directly. Generally, pybamm syntax follows numpy syntax; please get in touch if a function you need is missing.
- The current must now be updated by changing "Current function [A]" or "C-rate" instead of "Typical current [A]"


# [v0.1.0](https://github.com/pybamm-team/PyBaMM/tree/v0.1.0) - 2019-10-08
Expand Down
1 change: 0 additions & 1 deletion docs/source/models/submodels/current_collector/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ Current Collector
homogeneous_current_collector
potential_pair
quite_conductive_potential_pair
single_particle_potential_pair
set_potential_single_particle

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Current control external circuit
================================

.. autoclass:: pybamm.external_circuit.CurrentControl
:members:

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Function control external circuit
=================================

.. autoclass:: pybamm.external_circuit.FunctionControl
:members:

.. autoclass:: pybamm.external_circuit.VoltageFunctionControl
:members:

.. autoclass:: pybamm.external_circuit.PowerFunctionControl
:members:
15 changes: 15 additions & 0 deletions docs/source/models/submodels/external_circuit/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
External circuit
================

Models to enforce different boundary conditions (as imposed by an imaginary external
circuit) such as constant current, constant voltage, constant power, or any other
relationship between the current and voltage. "Current control" enforces these directly
through boundary conditions, while "Function control"
submodels add an algebraic equation (for the current) and hence can be used to set any
variable to be constant.

.. toctree::
:maxdepth: 1

current_control_external_circuit
function_control_external_circuit
1 change: 1 addition & 0 deletions docs/source/models/submodels/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Submodels
convection/index
electrode/index
electrolyte/index
external_circuit/index
interface/index
oxygen_diffusion/index
particle/index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@
" 'Volume-averaged total heating',\n",
" 'Volume-averaged total heating [W.m-3]',\n",
" 'Positive current collector potential [V]',\n",
" 'Local current collector potential difference',\n",
" 'Local current collector potential difference [V]',\n",
" 'Local voltage',\n",
" 'Local voltage [V]',\n",
" 'X-averaged open circuit voltage',\n",
" 'Measured open circuit voltage',\n",
" 'X-averaged open circuit voltage [V]',\n",
Expand Down
75 changes: 19 additions & 56 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\". This can be a scalar, but only accepts values 0 and 1. By default this is set to be a constant current by setting it to '1'. The size of a constant current input is changed by changing the parameter \"Typical current [A]\". Below we load the SPM with the default parameters, and then change the the typical current 16A. We then explicitly set the current function to be a constant current."
"In PyBaMM, the current function is set using the parameter \"Current function [A]\". Below we load the SPM with the default parameters, and then change the the current function to 16A."
]
},
{
Expand All @@ -45,9 +45,8 @@
"# set the default model parameters\n",
"param = model.default_parameter_values\n",
"\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\"] = \"[constant]\"\n"
"# change the current function\n",
"param[\"Current function [A]\"] = 16"
]
},
{
Expand All @@ -67,12 +66,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "26ae7952fb10438ebbf83297fe284014",
"model_id": "118979747d4f418982a358d3769dc257",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.02, step=0.005), Output()), _dom_classes=("
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.00787878787878788, step=0.005), Output()),…"
]
},
"metadata": {},
Expand Down Expand Up @@ -117,7 +116,7 @@
"metadata": {},
"outputs": [],
"source": [
"param[\"Current function\"] = \"[zero]\""
"param[\"Current function [A]\"] = 0"
]
},
{
Expand All @@ -131,31 +130,11 @@
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"param[\"Current function\"]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "630250e18bf6416089e4bed2a883c10e",
"model_id": "397b778427504eb8ac88b53de8397683",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -187,39 +166,23 @@
"source": [
"## Loading in current data <a name=\"data\"></a>\n",
"\n",
"Data can be loaded in from a csv file by specifying the path to that file and using the prefix \"[current data]\"."
"Data can be loaded in from a csv file by putting the file in the folder 'input/drive_cycles' and using the prefix \"[current data]\". As an example, we show how to solve the SPM using the US06 drive cycle"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"param[\"Current function\"] = \"[current data]US06\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As an example, we show how to solve the SPM using the US06 drive cycle"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "18118e75c01e4fb1ba9a00134298b5fd",
"model_id": "4acb95c01295406db377f5dd1593e014",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.026526276390989537, step=0.001), Output())…"
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.057314594406781015, step=0.001), Output())…"
]
},
"metadata": {},
Expand All @@ -234,7 +197,7 @@
"\n",
"# load parameter values and process model and geometry\n",
"param = model.default_parameter_values\n",
"param[\"Current function\"] = \"[current data]US06\"\n",
"param[\"Current function [A]\"] = \"[current data]US06\"\n",
"param.process_model(model)\n",
"param.process_geometry(geometry)\n",
"\n",
Expand Down Expand Up @@ -279,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -301,7 +264,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -316,7 +279,7 @@
"# set user defined current function\n",
"A = pybamm.electrical_parameters.I_typ\n",
"omega = 0.1\n",
"param[\"Current function\"] = my_fun(A,omega)\n",
"param[\"Current function [A]\"] = my_fun(A,omega)\n",
"\n",
"# process model and geometry\n",
"param.process_model(model)\n",
Expand All @@ -332,18 +295,18 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b6fae116be424e22955be046e20a6211",
"model_id": "19720a31f3964e55b01905476f50393a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.0013263138195494769, step=6.63156909774738"
"interactive(children=(FloatSlider(value=0.0, description='t', max=0.0028657297203390506, step=0.00014328648601"
]
},
"metadata": {},
Expand Down Expand Up @@ -398,7 +361,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
25 changes: 7 additions & 18 deletions examples/notebooks/compare-comsol-discharge-curve.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/notebooks/models/SPM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@
"\t- Volume-averaged total heating\n",
"\t- Volume-averaged total heating [W.m-3]\n",
"\t- Positive current collector potential [V]\n",
"\t- Local current collector potential difference\n",
"\t- Local current collector potential difference [V]\n",
"\t- Local voltage\n",
"\t- Local voltage [V]\n",
"\t- X-averaged open circuit voltage\n",
"\t- Measured open circuit voltage\n",
"\t- X-averaged open circuit voltage [V]\n",
Expand Down
Binary file modified examples/notebooks/models/spm1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/notebooks/models/spm2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2ca2598

Please sign in to comment.