Skip to content

Commit 2cd0bb3

Browse files
#1456 debugging
1 parent 4522c05 commit 2cd0bb3

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

examples/scripts/compare_lithium_ion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# load models
99
models = [
1010
# pybamm.lithium_ion.SPM(),
11-
pybamm.lithium_ion.SPMe(),
12-
# pybamm.lithium_ion.DFN(),
11+
# pybamm.lithium_ion.SPMe(),
12+
pybamm.lithium_ion.DFN(),
1313
# pybamm.lithium_ion.NewmanTobias(),
1414
]
1515

pybamm/models/base_model.py

-19
Original file line numberDiff line numberDiff line change
@@ -653,25 +653,6 @@ def check_ics_bcs(self):
653653
"""no initial condition given for variable '{}'""".format(var)
654654
)
655655

656-
# Boundary conditions
657-
for var, eqn in {**self.rhs, **self.algebraic}.items():
658-
if eqn.has_symbol_of_classes(
659-
(pybamm.Gradient, pybamm.Divergence)
660-
) and not eqn.has_symbol_of_classes(pybamm.Integral):
661-
# I have relaxed this check for now so that the lumped temperature
662-
# equation doesn't raise errors (this has and average in it)
663-
664-
# Variable must be in the boundary conditions
665-
if not any(
666-
var.id == x.id
667-
for symbol in self.boundary_conditions.keys()
668-
for x in symbol.pre_order()
669-
):
670-
raise pybamm.ModelError(
671-
"no boundary condition given for "
672-
"variable '{}' with equation '{}'.".format(var, eqn)
673-
)
674-
675656
def check_default_variables_dictionaries(self):
676657
"""Check that the right variables are provided."""
677658
missing_vars = []

pybamm/models/standard_variables.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,27 @@
3333

3434
# Electrolyte porosity times concentration
3535
eps_c_e_n = pybamm.Variable(
36-
"Negative electrolyte porosity times concentration",
36+
"Negative electrode porosity times concentration",
3737
domain="negative electrode",
3838
auxiliary_domains={"secondary": "current collector"},
3939
bounds=(0, np.inf),
4040
)
4141
eps_c_e_s = pybamm.Variable(
42-
"Separator electrolyte porosity times concentration",
42+
"Separator porosity times concentration",
4343
domain="separator",
4444
auxiliary_domains={"secondary": "current collector"},
4545
bounds=(0, np.inf),
4646
)
4747
eps_c_e_p = pybamm.Variable(
48-
"Positive electrolyte porosity times concentration",
48+
"Positive electrode porosity times concentration",
4949
domain="positive electrode",
5050
auxiliary_domains={"secondary": "current collector"},
5151
bounds=(0, np.inf),
5252
)
5353
eps_c_e = pybamm.concatenation(eps_c_e_n, eps_c_e_s, eps_c_e_p)
5454

5555
eps_c_e_av = pybamm.Variable(
56-
"X-averaged electrolyte porosity times concentration",
56+
"X-averaged porosity times concentration",
5757
domain="current collector",
5858
bounds=(0, np.inf),
5959
)

pybamm/models/submodels/electrolyte_diffusion/full_diffusion.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def get_fundamental_variables(self):
3232
eps_c_e = pybamm.concatenation(eps_c_e_n, eps_c_e_s, eps_c_e_p)
3333

3434
variables = {
35-
"Electrode porosity times concentration": eps_c_e,
35+
"Porosity times concentration": eps_c_e,
3636
"Negative electrode porosity times concentration": eps_c_e_n,
37-
"Separator electrode porosity times concentration": eps_c_e_s,
37+
"Separator porosity times concentration": eps_c_e_s,
3838
"Positive electrode porosity times concentration": eps_c_e_p,
3939
}
4040

@@ -53,13 +53,14 @@ def get_coupled_variables(self, variables):
5353
c_e_s = eps_c_e_s / eps_s
5454
c_e_p = eps_c_e_p / eps_p
5555

56+
eps = variables["Porosity"]
57+
c_e = variables["Porosity times concentration"] / eps
5658
variables.update(
5759
self._get_standard_concentration_variables(c_e_n, c_e_s, c_e_p)
5860
)
61+
variables["Electrolyte concentration"] = c_e
5962

6063
tor = variables["Electrolyte tortuosity"]
61-
eps = variables["Porosity"]
62-
c_e = variables["Electrolyte concentration"]
6364
i_e = variables["Electrolyte current density"]
6465
v_box = variables["Volume-averaged velocity"]
6566
T = variables["Cell temperature"]
@@ -82,7 +83,7 @@ def set_rhs(self, variables):
8283
param = self.param
8384

8485
eps = variables["Porosity"]
85-
eps_c_e = variables["Electrolyte porosity times concentration"]
86+
eps_c_e = variables["Porosity times concentration"]
8687
c_e = variables["Electrolyte concentration"]
8788
N_e = variables["Electrolyte flux"]
8889
div_Vbox = variables["Transverse volume-averaged acceleration"]
@@ -96,7 +97,7 @@ def set_rhs(self, variables):
9697

9798
def set_initial_conditions(self, variables):
9899

99-
eps_c_e = variables["Electrolyte porosity times concentration"]
100+
eps_c_e = variables["Porosity times concentration"]
100101

101102
self.initial_conditions = {
102103
eps_c_e: self.param.epsilon_init * self.param.c_e_init
@@ -105,10 +106,17 @@ def set_initial_conditions(self, variables):
105106
def set_boundary_conditions(self, variables):
106107

107108
c_e = variables["Electrolyte concentration"]
109+
c_e_n = variables["Negative electrolyte concentration"]
110+
c_e_s = variables["Separator electrolyte concentration"]
111+
c_e_p = variables["Positive electrolyte concentration"]
108112

109113
self.boundary_conditions = {
110114
c_e: {
111115
"left": (pybamm.Scalar(0), "Neumann"),
112116
"right": (pybamm.Scalar(0), "Neumann"),
113-
}
117+
},
118+
pybamm.concatenation(c_e_n, c_e_s, c_e_p): {
119+
"left": (pybamm.Scalar(0), "Neumann"),
120+
"right": (pybamm.Scalar(0), "Neumann"),
121+
},
114122
}

0 commit comments

Comments
 (0)