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 658 experiment #807

Merged
merged 37 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
27d711e
#658 start experiment class
valentinsulzer Dec 11, 2019
bb22c38
Merge branch 'master' into issue-658-experiment
valentinsulzer Dec 12, 2019
f2a043f
#658 processing strings works
valentinsulzer Dec 12, 2019
b4b3420
Merge branch 'master' into issue-658-experiment
valentinsulzer Jan 13, 2020
2f4ce32
Merge branch 'issue-760-better-processed-variable' into issue-658-exp…
valentinsulzer Jan 13, 2020
8c43f75
#658 updating protocol
valentinsulzer Jan 13, 2020
311a269
Merge branch 'master' into issue-658-experiment
valentinsulzer Jan 21, 2020
dbf1805
reformat experiment class string interpretation
valentinsulzer Jan 21, 2020
d55c147
#685 add parameters and frequency as inputs
valentinsulzer Jan 21, 2020
bdfff91
#658 start setting up simulation for experiment
valentinsulzer Jan 22, 2020
257fd72
Merge branch 'master' into issue-658-experiment
valentinsulzer Jan 26, 2020
e4554eb
Merge branch 'issue-784-simplify-solver' into issue-658-experiment
valentinsulzer Jan 26, 2020
fd84280
#658 get a basic experiment simulation working
valentinsulzer Jan 26, 2020
7ae50d5
#658 merge 784
valentinsulzer Jan 27, 2020
7705b0e
#658 start adding events
valentinsulzer Jan 27, 2020
6833ec3
#658 merge 709
valentinsulzer Feb 3, 2020
cec86fe
#658 trying to do events
valentinsulzer Feb 3, 2020
c6952bc
#658 debugging
valentinsulzer Feb 4, 2020
a3b755c
Merge branch 'issue-784-simplify-solver' into issue-658-experiment
valentinsulzer Feb 4, 2020
19ef609
#658 adding some bells and whistles
valentinsulzer Feb 4, 2020
bf4f688
Merge branch 'master' into issue-658-experiment
valentinsulzer Feb 4, 2020
9887677
#658 start adding tests for simulation + experiment
valentinsulzer Feb 4, 2020
58622bc
#658 add more tests and examples
valentinsulzer Feb 6, 2020
df5df79
#658 changelog
valentinsulzer Feb 6, 2020
a8f43b5
revert dfn changes
valentinsulzer Feb 6, 2020
59528bd
#658 remove gitt class
valentinsulzer Feb 6, 2020
5587028
erge branch 'master' into issue-658-experiment
valentinsulzer Feb 6, 2020
f1e1aa8
#658 fix init
valentinsulzer Feb 6, 2020
2e36a8b
#658 add sub-solutions and individual periods
valentinsulzer Feb 6, 2020
9f912bd
#658 added example using sub solutions
valentinsulzer Feb 6, 2020
e6ec810
#658 coverage
valentinsulzer Feb 6, 2020
9547f52
#658 docs
valentinsulzer Feb 7, 2020
3c6dda7
#658 remove example in docs
valentinsulzer Feb 7, 2020
4a9cb07
#658 merge master
valentinsulzer Feb 9, 2020
b304425
#658 update events
valentinsulzer Feb 10, 2020
bd047e5
#658 rob comments and more operating conditions options
valentinsulzer Feb 10, 2020
0a3517f
#658 flake8
valentinsulzer Feb 10, 2020
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 @@ -2,6 +2,8 @@

## Features

- Added functionality to solve DAE models with non-smooth current inputs ([#808](https://github.com/pybamm-team/PyBaMM/pull/808))
- Added functionality to simulate experiments and testing protocols ([#807](https://github.com/pybamm-team/PyBaMM/pull/807))
- Added fuzzy string matching for parameters and variables ([#796](https://github.com/pybamm-team/PyBaMM/pull/796))
- Changed ParameterValues to raise an error when a parameter that wasn't previously defined is updated ([#796](https://github.com/pybamm-team/PyBaMM/pull/796))
- Added some basic models (BasicSPM and BasicDFN) in order to clearly demonstrate the PyBaMM model structure for battery models ([#795](https://github.com/pybamm-team/PyBaMM/pull/795))
Expand Down Expand Up @@ -63,6 +65,7 @@

## Breaking changes

- Removed `ParameterValues.update_model`, whose functionality is now replaced by `InputParameter` ([#801](https://github.com/pybamm-team/PyBaMM/pull/801))
- Removed `Outer` and `Kron` nodes as no longer used ([#777](https://github.com/pybamm-team/PyBaMM/pull/777))
- Moved `results` to separate repositories ([#761](https://github.com/pybamm-team/PyBaMM/pull/761))
- The parameters "Bruggeman coefficient" must now be specified separately as "Bruggeman coefficient (electrolyte)" and "Bruggeman coefficient (electrode)"
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Contents
source/meshes/index
source/spatial_methods/index
source/solvers/index
source/experiments/index
source/processed_variable
source/util
source/simulation
Expand Down
5 changes: 5 additions & 0 deletions docs/source/experiments/experiment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Base Experiment Class
=====================

.. autoclass:: pybamm.Experiment
:members:
8 changes: 8 additions & 0 deletions docs/source/experiments/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Experiments
===========

Classes to help set operating conditions for some standard battery modelling experiments

.. toctree::

experiment
3 changes: 3 additions & 0 deletions docs/source/solvers/solution.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Solution
========

.. autoclass:: pybamm._BaseSolution
:members:

.. autoclass:: pybamm.Solution
:members:
4 changes: 2 additions & 2 deletions examples/scripts/DFN.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

pybamm.set_logging_level("INFO")


# load model
model = pybamm.lithium_ion.DFN({"operating mode": "voltage"})
model = pybamm.lithium_ion.DFN()

# create geometry
geometry = model.default_geometry

# load parameter values and process model and geometry
param = model.default_parameter_values
param.update({"Voltage function [V]": 4.1}, check_already_exists=False)
param.process_model(model)
param.process_geometry(geometry)

Expand Down
39 changes: 39 additions & 0 deletions examples/scripts/experimental_protocols/cccv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Constant-current constant-voltage charge
#
import pybamm
import matplotlib.pyplot as plt

pybamm.set_logging_level("INFO")
experiment = pybamm.Experiment(
[
"Discharge at C/10 for 13 hours or until 3.3 V",
"Rest for 1 hour",
"Charge at 1 A until 4.1 V",
"Hold at 4.1 V until 50 mA",
"Rest for 1 hour",
]
* 3,
period="2 minutes",
)
model = pybamm.lithium_ion.DFN()
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver())
sim.solve()

# Plot voltages from the discharge segments only
fig, ax = plt.subplots()
for i in range(3):
# Extract sub solutions
sol = sim.solution.sub_solutions[i * 5]
# Extract variables
t = sol["Time [h]"].entries
V = sol["Terminal voltage [V]"].entries
# Plot
ax.plot(t - t[0], V, label="Discharge {}".format(i + 1))
ax.set_xlabel("Time [h]")
ax.set_ylabel("Voltage [V]")
ax.set_xlim([0, 13])
ax.legend()

# Show all plots
sim.plot()
19 changes: 19 additions & 0 deletions examples/scripts/experimental_protocols/cccv_lead_acid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Constant-current constant-voltage charge
#
import pybamm

pybamm.set_logging_level("INFO")
experiment = pybamm.Experiment(
[
"Discharge at C/2 until 11 V",
"Rest for 1 hour",
"Charge at C/2 until 14.5 V",
"Hold at 14.5 V until 200 mA",
"Rest for 1 hour",
]
)
model = pybamm.lead_acid.Full()
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver())
sim.solve()
sim.plot()
13 changes: 13 additions & 0 deletions examples/scripts/experimental_protocols/gitt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# GITT discharge
#
import pybamm

pybamm.set_logging_level("INFO")
experiment = pybamm.Experiment(
["Discharge at C/20 for 1 hour", "Rest for 1 hour"] * 20,
)
model = pybamm.lithium_ion.DFN()
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver())
sim.solve()
sim.plot()
8 changes: 7 additions & 1 deletion pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def version(formatted=False):
#
# Solver classes
#
from .solvers.solution import Solution
from .solvers.solution import Solution, _BaseSolution
from .solvers.base_solver import BaseSolver
from .solvers.algebraic_solver import AlgebraicSolver
from .solvers.casadi_solver import CasadiSolver
Expand All @@ -246,6 +246,12 @@ def version(formatted=False):
from .solvers.scipy_solver import ScipySolver
from .solvers.idaklu_solver import IDAKLUSolver, have_idaklu

#
# Experiments
#
from .experiments.experiment import Experiment
from . import experiments

#
# other
#
Expand Down
Empty file added pybamm/experiments/__init__.py
Empty file.
Loading