forked from pybamm-team/PyBaMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pybamm-team#3995 from pybamm-team/basic-experiments
Make basic models compatible with experiments
- Loading branch information
Showing
23 changed files
with
212 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
docs/source/api/models/submodels/external_circuit/discharge_throughput.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Discharge and throughput variables | ||
================================== | ||
|
||
Calculates the discharge and throughput variables (capacity and power) for the battery. | ||
|
||
.. autoclass:: pybamm.external_circuit.DischargeThroughput | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
pybamm/models/submodels/external_circuit/discharge_throughput.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# | ||
# Variables related to discharge and throughput capacity and energy | ||
# | ||
import pybamm | ||
from .base_external_circuit import BaseModel | ||
|
||
|
||
class DischargeThroughput(BaseModel): | ||
"""Model calculate discharge and throughput capacity and energy.""" | ||
|
||
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, | ||
"Throughput capacity [A.h]": Qt_Ah, | ||
} | ||
if self.options["calculate discharge energy"] == "true": | ||
Q_Wh = pybamm.Variable("Discharge energy [W.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, | ||
} | ||
) | ||
else: | ||
variables.update( | ||
{ | ||
"Discharge energy [W.h]": pybamm.Scalar(0), | ||
"Throughput energy [W.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]"] | ||
self.initial_conditions[Q_Wh] = pybamm.Scalar(0) | ||
self.initial_conditions[Qt_Wh] = 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 # 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]"] | ||
V = variables["Voltage [V]"] | ||
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 |
Oops, something went wrong.