Skip to content

Commit 4817075

Browse files
#623 edit r_average to accept electrode domains (returns unchanged copy)
1 parent e9e82fe commit 4817075

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

pybamm/expression_tree/unary_operators.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,7 @@ def __init__(self, child, region="entire"):
595595
def set_id(self):
596596
""" See :meth:`pybamm.Symbol.set_id()` """
597597
self._id = hash(
598-
(self.__class__, self.name)
599-
+ (self.children[0].id,)
600-
+ tuple(self.domain)
598+
(self.__class__, self.name) + (self.children[0].id,) + tuple(self.domain)
601599
)
602600

603601
def _unary_simplify(self, simplified_child):
@@ -798,6 +796,7 @@ def grad_squared(expression):
798796

799797
return Gradient_Squared(expression)
800798

799+
801800
#
802801
# Method to call SurfaceValue
803802
#
@@ -1009,17 +1008,8 @@ def r_average(symbol):
10091008
:class:`Symbol`
10101009
the new averaged symbol
10111010
"""
1012-
ok_domains = [['positive particle'], ['negative particle'], []]
1013-
# Symbol must have domain [] or ["current collector"]
1014-
if symbol.domain not in ok_domains:
1015-
raise pybamm.DomainError(
1016-
"""r-average only implemented in the 'particle' domain,
1017-
but symbol has domains {}""".format(
1018-
symbol.domain
1019-
)
1020-
)
1021-
# If symbol doesn't have a domain, its average value is itself
1022-
elif symbol.domain == []:
1011+
# If symbol doesn't have a particle domain, its r-averaged value is itself
1012+
if symbol.domain not in [["positive particle"], ["negative particle"]]:
10231013
new_symbol = symbol.new_copy()
10241014
new_symbol.parent = None
10251015
return new_symbol

pybamm/models/submodels/particle/fickian/fickian_many_particles.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def get_fundamental_variables(self):
3030
elif self.domain == "Positive":
3131
c_s = pybamm.standard_variables.c_s_p
3232

33+
# TODO: implement c_s_xav for Fickian many particles (tricky because this
34+
# requires averaging a secondary domain)
3335
variables = self._get_standard_concentration_variables(c_s, c_s)
3436

3537
return variables

0 commit comments

Comments
 (0)