Skip to content

Commit

Permalink
#984 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed May 14, 2020
1 parent ae0c9e8 commit 09c9f95
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 82 deletions.
173 changes: 103 additions & 70 deletions examples/notebooks/using-submodels.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
models = [
pb.lithium_ion.SPM({"sei": "reaction limited"}),
pb.lithium_ion.SPM(
{
"sei": "reaction limited",
# "sei film resistance": "average",
"surface form": "algebraic",
},
name="Algebraic SPM",
{"sei": "reaction limited", "surface form": "algebraic"}, name="Algebraic SPM",
),
pb.lithium_ion.DFN({"sei": "reaction limited"}),
]
Expand Down
4 changes: 4 additions & 0 deletions examples/scripts/compare_lead_acid.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"Porosity",
"Electrolyte potential [V]",
"Terminal voltage [V]",
"Negative electrode reaction overpotential",
"Positive electrode reaction overpotential",
"Sum of interfacial current densities",
"Sum of electrolyte reaction source terms",
]
plot = pybamm.QuickPlot(solutions, output_variables, linestyles=[":", "--", "-"])
plot.dynamic_plot()
12 changes: 12 additions & 0 deletions examples/scripts/custom_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@
model.submodels["positive interface"] = pybamm.interface.InverseButlerVolmer(
model.param, "Positive", "lithium-ion main"
)
model.submodels[
"negative interface current"
] = pybamm.interface.CurrentForInverseButlerVolmer(
model.param, "Negative", "lithium-ion main"
)
model.submodels[
"positive interface current"
] = pybamm.interface.CurrentForInverseButlerVolmer(
model.param, "Positive", "lithium-ion main"
)
model.submodels[
"electrolyte diffusion"
] = pybamm.electrolyte_diffusion.ConstantConcentration(model.param)
model.submodels[
"electrolyte conductivity"
] = pybamm.electrolyte_conductivity.LeadingOrder(model.param)
model.submodels["negative sei"] = pybamm.sei.NoSEI(model.param, "Negative")
model.submodels["positive sei"] = pybamm.sei.NoSEI(model.param, "Positive")

# build model
model.build_model()
Expand Down
4 changes: 2 additions & 2 deletions pybamm/models/full_battery_models/lead_acid/loqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ def set_interfacial_submodel(self):
self.submodels[
"negative interface current"
] = pybamm.interface.CurrentForInverseButlerVolmer(
self.param, "Negative", "lithium-ion main"
self.param, "Negative", "lead-acid main"
)
self.submodels[
"positive interface current"
] = pybamm.interface.CurrentForInverseButlerVolmer(
self.param, "Positive", "lithium-ion main"
self.param, "Positive", "lead-acid main"
)
else:
self.submodels[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InverseButlerVolmer(BaseInterface):
A dictionary of options to be passed to the model. In this case "sei film
resistance" is the important option. See :class:`pybamm.BaseBatteryModel`
**Extends:** :class:`pybamm.interface.kinetics.ButlerVolmer`
**Extends:** :class:`pybamm.interface.BaseInterface`
"""

Expand Down Expand Up @@ -118,7 +118,7 @@ class CurrentForInverseButlerVolmer(BaseInterface):
reaction : str
The name of the reaction being implemented
**Extends:** :class:`pybamm.interface.kinetics.ButlerVolmer`
**Extends:** :class:`pybamm.interface.BaseInterface`
"""

Expand Down
16 changes: 14 additions & 2 deletions tests/integration/test_models/standard_output_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@ def __init__(self, model, param, disc, solution, operating_condition):
self.j_p_av = solution[
"X-averaged positive electrode interfacial current density"
]
self.j_n_sei = solution["Negative electrode sei interfacial current density"]
self.j_p_sei = solution["Positive electrode sei interfacial current density"]
self.j_n_sei_av = solution[
"X-averaged negative electrode sei interfacial current density"
]
self.j_p_sei_av = solution[
"X-averaged positive electrode sei interfacial current density"
]

self.j0_n = solution["Negative electrode exchange current density"]
self.j0_p = solution["Positive electrode exchange current density"]
Expand All @@ -543,10 +551,14 @@ def test_interfacial_current_average(self):
"""Test that average of the interfacial current density is equal to the true
value."""
np.testing.assert_array_almost_equal(
self.j_n_av(self.t), self.i_cell / self.l_n, decimal=4
self.j_n_av(self.t) + self.j_n_sei_av(self.t),
self.i_cell / self.l_n,
decimal=4,
)
np.testing.assert_array_almost_equal(
self.j_p_av(self.t), -self.i_cell / self.l_p, decimal=4
self.j_p_av(self.t) + self.j_p_sei_av(self.t),
-self.i_cell / self.l_p,
decimal=4,
)

def test_conservation(self):
Expand Down

0 comments on commit 09c9f95

Please sign in to comment.