Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 492 potentiostatic #751

Merged
merged 38 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c16b916
#492 reformat constant current to be a submodel
valentinsulzer Nov 14, 2019
8ff9640
#492 merge master
valentinsulzer Nov 14, 2019
ab9d5a6
#492 fix bugs
valentinsulzer Nov 14, 2019
ee030ee
#492 constant voltage works for DFN
valentinsulzer Nov 14, 2019
049960d
#492 get potentiostatic working for 1D lithium-ion
valentinsulzer Nov 14, 2019
7ee11c5
#492 get working for 3d (in theory)
valentinsulzer Nov 14, 2019
c2b7e38
#492 reorganise and add power
valentinsulzer Nov 15, 2019
8561598
#492 add charging strategies example
valentinsulzer Nov 18, 2019
e968272
#492 add docs and unit tests
valentinsulzer Nov 19, 2019
d63f838
#492 merge master
valentinsulzer Nov 21, 2019
db3ebbb
#492 add integration test - wrong current
valentinsulzer Nov 21, 2019
a24543c
#492 trying to get charging strategies working
valentinsulzer Nov 22, 2019
e14811d
#492 more reformatting, need to figure out currents still
valentinsulzer Nov 23, 2019
3c5cbc0
Merge branch 'master' into issue-492-potentiostatic
valentinsulzer Nov 26, 2019
e678d23
#492 get direct voltage model working
valentinsulzer Nov 29, 2019
172f1ec
#492 add discharge capacity as a variable with ODE
valentinsulzer Nov 29, 2019
a3b302e
#492 updating current function and C-rate
valentinsulzer Nov 29, 2019
120178b
#492 change solver times in examples
valentinsulzer Nov 29, 2019
4238ad1
#492 fixing some tests
valentinsulzer Nov 30, 2019
194c707
#492 fixing more tests and examples
valentinsulzer Nov 30, 2019
2cd3f44
#492 fix easy tests
valentinsulzer Dec 3, 2019
6e723a2
#492 debugging composite models
valentinsulzer Dec 3, 2019
b6393ee
#492 flake8
valentinsulzer Dec 3, 2019
8710f5e
#492 remove debug
valentinsulzer Dec 3, 2019
f113293
#492 remove direct voltage control, too much effort
valentinsulzer Dec 3, 2019
5f3bd18
#492 clean up setting external variables for potentials
valentinsulzer Dec 4, 2019
7d156dd
#492 fix unit tests
valentinsulzer Dec 4, 2019
e638b1b
#492 fixing integration tests and examples
valentinsulzer Dec 4, 2019
7597712
#492 tests and coverage
valentinsulzer Dec 4, 2019
2fd4883
#492 merge master
valentinsulzer Dec 6, 2019
55c5e88
#492 don't print casadi warnings in test
valentinsulzer Dec 6, 2019
7eb60ec
#492 fix composite
valentinsulzer Dec 6, 2019
c13d8b9
#492 coverage for parameter values
valentinsulzer Dec 7, 2019
fed0bbb
#492 change to casadi solver for broken test
valentinsulzer Dec 7, 2019
b3e0151
#492 merge master
valentinsulzer Dec 13, 2019
84867e1
#492 rob comments
valentinsulzer Dec 13, 2019
cee062c
#492 merge master
valentinsulzer Dec 14, 2019
b54eb0e
#492 fix test
valentinsulzer Dec 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
- 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))
- Added submodels for tortuosity ([#726](https://github.com/pybamm-team/PyBaMM/pull/726))
Expand Down Expand Up @@ -32,6 +33,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 @@ -47,6 +49,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