Skip to content

Commit

Permalink
Merge pull request pybamm-team#2980 from DrSOKane/degradation-example
Browse files Browse the repository at this point in the history
Degradation example
  • Loading branch information
valentinsulzer authored May 24, 2023
2 parents 4f4a66a + 6f17d6a commit 7e681e2
Show file tree
Hide file tree
Showing 4 changed files with 381 additions and 17 deletions.
363 changes: 363 additions & 0 deletions examples/notebooks/models/coupled-degradation.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/notebooks/models/lithium-plating.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "pybamm",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -349,7 +349,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.8.10"
},
"toc": {
"base_numbering": 1,
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/simulating-long-experiments.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.8.10"
},
"toc": {
"base_numbering": 1,
Expand Down
29 changes: 15 additions & 14 deletions pybamm/models/submodels/external_circuit/base_external_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,54 @@ def __init__(self, param, options):
def get_fundamental_variables(self):
Q_Ah = pybamm.Variable("Discharge capacity [A.h]")
Q_Ah.print_name = "Q_Ah"
# Throughput capacity (cumulative)
Qt_Ah = pybamm.Variable("Throughput capacity [A.h]")
Qt_Ah.print_name = "Qt_Ah"

variables = {"Discharge capacity [A.h]": Q_Ah}
variables = {
"Discharge capacity [A.h]": Q_Ah,
"Throughput capacity [A.h]": Qt_Ah,
}
if self.options["calculate discharge energy"] == "true":
Q_Wh = pybamm.Variable("Discharge energy [W.h]")

# Throughput capacity and energy (cumulative)
Qt_Ah = pybamm.Variable("Throughput capacity [A.h]")
# Throughput energy (cumulative)
Qt_Wh = pybamm.Variable("Throughput energy [W.h]")
variables.update(
{
"Discharge energy [W.h]": Q_Wh,
"Throughput energy [W.h]": Qt_Wh,
"Throughput capacity [A.h]": Qt_Ah,
}
)
else:
variables.update(
{
"Discharge energy [W.h]": pybamm.Scalar(0),
"Throughput energy [W.h]": pybamm.Scalar(0),
"Throughput capacity [A.h]": pybamm.Scalar(0),
}
)
return variables

def set_initial_conditions(self, variables):
Q_Ah = variables["Discharge capacity [A.h]"]
Qt_Ah = variables["Throughput capacity [A.h]"]
self.initial_conditions[Q_Ah] = pybamm.Scalar(0)
self.initial_conditions[Qt_Ah] = pybamm.Scalar(0)
if self.options["calculate discharge energy"] == "true":
Q_Wh = variables["Discharge energy [W.h]"]
Qt_Wh = variables["Throughput energy [W.h]"]
Qt_Ah = variables["Throughput capacity [A.h]"]
self.initial_conditions[Q_Wh] = pybamm.Scalar(0)
self.initial_conditions[Qt_Wh] = pybamm.Scalar(0)
self.initial_conditions[Qt_Ah] = pybamm.Scalar(0)

def set_rhs(self, variables):
# ODEs for discharge capacity and throughput capacity
Q_Ah = variables["Discharge capacity [A.h]"]
Qt_Ah = variables["Throughput capacity [A.h]"]
I = variables["Current [A]"]

self.rhs[Q_Ah] = I / 3600
self.rhs[Q_Ah] = I / 3600 # Returns to zero after a complete cycle
self.rhs[Qt_Ah] = abs(I) / 3600 # Increases with each cycle
if self.options["calculate discharge energy"] == "true":
Q_Wh = variables["Discharge energy [W.h]"]
Qt_Wh = variables["Throughput energy [W.h]"]
Qt_Ah = variables["Throughput capacity [A.h]"]
V = variables["Voltage [V]"]
self.rhs[Q_Wh] = I * V / 3600
self.rhs[Qt_Wh] = abs(I * V) / 3600
self.rhs[Qt_Ah] = abs(I) / 3600
self.rhs[Q_Wh] = I * V / 3600 # Returns to zero after a complete cycle
self.rhs[Qt_Wh] = abs(I * V) / 3600 # Increases with each cycle

0 comments on commit 7e681e2

Please sign in to comment.