Skip to content

Commit

Permalink
#579 add docs and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Nov 13, 2019
1 parent da30127 commit 9903249
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/source/models/submodels/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Submodels
particle/index
porosity/index
thermal/index
tortuosity/index
6 changes: 6 additions & 0 deletions docs/source/models/submodels/tortuosity/base_tortuosity.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Base Model
===========

.. autoclass:: pybamm.tortuosity.BaseModel
:members:

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bruggeman Model
===============

.. autoclass:: pybamm.tortuosity.Bruggeman
:members:



9 changes: 9 additions & 0 deletions docs/source/models/submodels/tortuosity/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Tortuosity
==========

.. toctree::
:maxdepth: 1

base_tortuosity
bruggeman_tortuosity

Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def get_coupled_variables(self, variables):
"X-averaged negative electrode surface potential difference"
]
phi_s_n_av = variables["X-averaged negative electrode potential"]
tor_n_av = variables["Leading-order x-averaged negative electrode tortuosity"]
tor_n_av = variables["Leading-order x-averaged negative electrolyte tortuosity"]
tor_s_av = variables["Leading-order x-averaged separator tortuosity"]
tor_p_av = variables["Leading-order x-averaged positive electrode tortuosity"]
tor_p_av = variables["Leading-order x-averaged positive electrolyte tortuosity"]

T_av = variables["X-averaged cell temperature"]
T_av_n = pybamm.PrimaryBroadcast(T_av, "negative electrode")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def get_coupled_variables(self, variables):
eps_n_0 = variables["Leading-order x-averaged negative electrode porosity"]
eps_s_0 = variables["Leading-order x-averaged separator porosity"]
eps_p_0 = variables["Leading-order x-averaged positive electrode porosity"]
tor_n_0 = variables["Leading-order x-averaged negative electrode tortuosity"]
tor_n_0 = variables["Leading-order x-averaged negative electrolyte tortuosity"]
tor_s_0 = variables["Leading-order x-averaged separator tortuosity"]
tor_p_0 = variables["Leading-order x-averaged positive electrode tortuosity"]
tor_p_0 = variables["Leading-order x-averaged positive electrolyte tortuosity"]
deps_n_0_dt = variables[
"Leading-order x-averaged negative electrode porosity change"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def get_coupled_variables(self, variables):

# Unpack
tor_s_0_av = variables["Leading-order x-averaged separator tortuosity"]
tor_p_0_av = variables["Leading-order x-averaged positive electrode tortuosity"]
tor_p_0_av = variables[
"Leading-order x-averaged positive electrolyte tortuosity"
]

# Diffusivities
D_ox_s = tor_s_0_av * param.curlyD_ox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def test_public_functions(self):
"Leading-order x-averaged negative electrode porosity": a,
"Leading-order x-averaged separator porosity": a,
"Leading-order x-averaged positive electrode porosity": a,
"Leading-order x-averaged negative electrolyte tortuosity": a,
"Leading-order x-averaged separator tortuosity": a,
"Leading-order x-averaged positive electrolyte tortuosity": a,
"X-averaged cell temperature": a,
}
submodel = pybamm.electrolyte.stefan_maxwell.conductivity.Composite(param)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def test_public_functions(self):
a, "current collector"
),
"Negative electrode porosity": a_n,
"Negative electrolyte tortuosity": a_n,
"Negative electrode tortuosity": a_n,
"Negative electrolyte concentration": a_n,
"Negative electrode interfacial current density": a_n,
"Electrolyte potential": pybamm.Concatenation(a_n, a_s, a_p),
Expand Down Expand Up @@ -55,6 +57,8 @@ def test_public_functions(self):
"Separator electrolyte potential": a_s,
"Separator electrolyte current density": a_s,
"Positive electrode porosity": a_p,
"Positive electrolyte tortuosity": a_p,
"Positive electrode tortuosity": a_p,
"Positive electrolyte concentration": a_p,
"Positive electrode interfacial current density": a_p,
"Positive electrode temperature": a_p,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def test_public_functions(self):
pybamm.FullBroadcast(a, "separator", "current collector"),
pybamm.FullBroadcast(a, "positive electrode", "current collector"),
),
"Electrolyte tortuosity": pybamm.Concatenation(
pybamm.FullBroadcast(a, "negative electrode", "current collector"),
pybamm.FullBroadcast(a, "separator", "current collector"),
pybamm.FullBroadcast(a, "positive electrode", "current collector"),
),
"Porosity change": pybamm.Concatenation(
pybamm.FullBroadcast(a, "negative electrode", "current collector"),
pybamm.FullBroadcast(a, "separator", "current collector"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

class TestBaseModel(unittest.TestCase):
def test_public_functions(self):
a = pybamm.Scalar(0)
variables = {"Negative electrode porosity": a, "Positive electrode porosity": a}
submodel = pybamm.porosity.BaseModel(None)
std_tests = tests.StandardSubModelTests(submodel)
std_tests = tests.StandardSubModelTests(submodel, variables)
std_tests.test_all()


Expand Down
12 changes: 9 additions & 3 deletions tests/unit/test_parameters/test_standard_parameters_lead_acid.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,15 @@ def test_update_initial_state_of_charge(self):
# Test that relevant parameters have changed as expected
self.assertLess(param_eval_update["q_init"], param_eval["q_init"])
self.assertLess(param_eval_update["c_e_init"], param_eval["c_e_init"])
self.assertLess(param_eval_update["eps_n_init"], param_eval["eps_n_init"])
self.assertEqual(param_eval_update["eps_s_init"], param_eval["eps_s_init"])
self.assertLess(param_eval_update["eps_p_init"], param_eval["eps_p_init"])
self.assertLess(
param_eval_update["epsilon_n_init"], param_eval["epsilon_n_init"]
)
self.assertEqual(
param_eval_update["epsilon_s_init"], param_eval["epsilon_s_init"]
)
self.assertLess(
param_eval_update["epsilon_p_init"], param_eval["epsilon_p_init"]
)
self.assertGreater(
param_eval_update["curlyU_n_init"], param_eval["curlyU_n_init"]
)
Expand Down

0 comments on commit 9903249

Please sign in to comment.