Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Integrated electrolyte conductivity #1188

Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
92de548
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
e5d7c14
#884 debugging new submodel
brosaplanella May 16, 2020
fb667b3
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
7899fdd
#884 debugging new submodel
brosaplanella May 16, 2020
7b3df30
Merge branch 'issue-884-electrolyte-integrated-conductivity' of https…
brosaplanella May 19, 2020
573db34
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
eec8354
#884 debugging new submodel
brosaplanella May 16, 2020
5d7ca5d
Merge branch 'issue-884-electrolyte-integrated-conductivity' of https…
brosaplanella May 20, 2020
334dd17
flake8
brosaplanella May 20, 2020
3eb9c68
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
4a3ebf7
#884 debugging new submodel
brosaplanella May 16, 2020
5c5b7fa
flake8
brosaplanella May 20, 2020
00bfd7c
added tab parameters (set to zero) so thermal model runs
brosaplanella May 21, 2020
a8496db
debugged conductivity
brosaplanella May 26, 2020
34b94f3
added new SPMe model
brosaplanella May 26, 2020
e439182
fix merge conflict
brosaplanella May 26, 2020
3ebae0b
flake8
brosaplanella May 26, 2020
5548930
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
4c10748
#884 debugging new submodel
brosaplanella May 16, 2020
7e3c823
flake8
brosaplanella May 20, 2020
3f76b27
debugged conductivity
brosaplanella May 26, 2020
577f5fc
added new SPMe model
brosaplanella May 26, 2020
a39ac10
flake8
brosaplanella May 26, 2020
9d30d37
solved merge conflict
brosaplanella May 28, 2020
e7897be
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
428e4aa
#884 debugging new submodel
brosaplanella May 16, 2020
e30ddf9
flake8
brosaplanella May 20, 2020
f5bef85
debugged conductivity
brosaplanella May 26, 2020
7ebf86a
added new SPMe model
brosaplanella May 26, 2020
f0aa087
flake8
brosaplanella May 26, 2020
57c856b
Merge branch 'issue-884-electrolyte-integrated-conductivity' of https…
brosaplanella Jun 10, 2020
320804b
#884 fixed the new SPMe model to work with the new geometry
brosaplanella Jun 11, 2020
bf92330
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
44bdd41
#884 debugging new submodel
brosaplanella May 16, 2020
a0d17b5
flake8
brosaplanella May 20, 2020
90eb3ee
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
bef6b8c
flake8
brosaplanella May 20, 2020
80dc52d
debugged conductivity
brosaplanella May 26, 2020
3866e20
added new SPMe model
brosaplanella May 26, 2020
a5c51cd
flake8
brosaplanella May 26, 2020
7b55d57
#884 debugging new submodel
brosaplanella May 16, 2020
06674fa
debugged conductivity
brosaplanella May 26, 2020
a923ca7
#884 fixed the new SPMe model to work with the new geometry
brosaplanella Jun 11, 2020
593ddd4
Merge branch 'issue-884-electrolyte-integrated-conductivity' of https…
brosaplanella Jun 22, 2020
764fcec
#884 cleaned code
brosaplanella Jun 22, 2020
96eb696
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
183a765
#884 debugging new submodel
brosaplanella May 16, 2020
c0448ca
flake8
brosaplanella May 20, 2020
d790866
debugged conductivity
brosaplanella May 26, 2020
c135494
added new SPMe model
brosaplanella May 26, 2020
1cee889
flake8
brosaplanella May 26, 2020
a92fcf8
#884 fixed the new SPMe model to work with the new geometry
brosaplanella Jun 11, 2020
8dc661f
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
40b12c3
flake8
brosaplanella May 20, 2020
fb4f6d9
#884 debugging new submodel
brosaplanella May 16, 2020
9e0d807
debugged conductivity
brosaplanella May 26, 2020
71d7a03
#884 cleaned code
brosaplanella Jun 22, 2020
d8108e8
#884 renamed model
brosaplanella Jun 23, 2020
4e47666
Merge branch 'issue-884-electrolyte-integrated-conductivity' of https…
brosaplanella Jun 23, 2020
6ec5ce6
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
4a6874f
#884 debugging new submodel
brosaplanella May 16, 2020
b6626c0
flake8
brosaplanella May 20, 2020
93eefae
debugged conductivity
brosaplanella May 26, 2020
679ffbe
added new SPMe model
brosaplanella May 26, 2020
0a6dfd9
flake8
brosaplanella May 26, 2020
51f71c4
#884 fixed the new SPMe model to work with the new geometry
brosaplanella Jun 11, 2020
02ee792
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
2b77066
flake8
brosaplanella May 20, 2020
a91053d
#884 debugging new submodel
brosaplanella May 16, 2020
7e6de9d
debugged conductivity
brosaplanella May 26, 2020
466e502
#884 cleaned code
brosaplanella Jun 22, 2020
d11e266
#884 debugging new submodel
brosaplanella May 16, 2020
a15c8d5
debugged conductivity
brosaplanella May 26, 2020
1521a3f
#884 added integrated conductivity model
brosaplanella Apr 22, 2020
73a5bfa
flake8
brosaplanella May 20, 2020
85c77e7
#884 debugging new submodel
brosaplanella May 16, 2020
3904114
debugged conductivity
brosaplanella May 26, 2020
1ae86bb
#884 cleaned code
brosaplanella Jun 22, 2020
62c52ea
#884 renamed model
brosaplanella Jun 23, 2020
9999775
Merge branch 'issue-884-electrolyte-integrated-conductivity' of https…
brosaplanella Jun 23, 2020
b55ede7
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Sep 15, 2020
dd8e174
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Oct 7, 2020
f4ba84e
#884 tidy up for merge
brosaplanella Oct 13, 2020
cf39650
#884 removed SPME_FBP (for development only)
brosaplanella Oct 13, 2020
756e093
#884 add preliminary citation
brosaplanella Oct 13, 2020
9d08f5e
#884 add test
brosaplanella Oct 13, 2020
0d19dbc
#884 removed activation energy from Nyman2008
brosaplanella Oct 13, 2020
48ca85c
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Oct 14, 2020
5eee5be
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Oct 19, 2020
e615e4a
#884 update CHANGELOG
brosaplanella Oct 19, 2020
08d191c
#884 add docs
brosaplanella Oct 19, 2020
6a89b7d
#884 removed arrhenius term
brosaplanella Oct 20, 2020
3f04c15
#884 included docstring reference
brosaplanella Oct 20, 2020
86051b9
#884 removed redundant right boundary integrals
brosaplanella Oct 20, 2020
a019e6b
#884 added SPMe tests
brosaplanella Oct 20, 2020
8341306
flake8
brosaplanella Oct 20, 2020
4890bab
#884 fixed typo in docs
brosaplanella Oct 20, 2020
f35dd26
#884 fix documentation
brosaplanella Oct 20, 2020
30ab27c
#884 added options to set integrated conductivity
brosaplanella Oct 22, 2020
6aa1bb3
#884 #1207 implemented option to choose electrolyte conductivity and …
brosaplanella Oct 23, 2020
0308466
#1207 update CHANGELOG
brosaplanella Oct 23, 2020
ddb5ac5
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Oct 23, 2020
006dc25
#884 set SPMe surface form to NotImplemented for the moment
brosaplanella Oct 23, 2020
480765f
#884 update CHANGELOG
brosaplanella Oct 23, 2020
9818f21
flake8
brosaplanella Oct 23, 2020
3afea4e
#884 removed SPMe from test_compare_outputs for surface form
brosaplanella Oct 23, 2020
8672eff
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Oct 24, 2020
e286ce0
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Oct 27, 2020
c301814
#884 fix typo CITATIONS.txt
brosaplanella Oct 27, 2020
f67357b
#884 add test citation Brosa Planella 2020
brosaplanella Nov 3, 2020
5d4bd51
#884 update citation TSPMe
brosaplanella Nov 4, 2020
49fa413
Merge branch 'develop' into issue-884-electrolyte-integrated-conducti…
brosaplanella Nov 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions pybamm/CITATIONS.txt
Expand Up @@ -204,3 +204,13 @@ primaryClass={physics.app-ph},
year={2005},
publisher={IOP Publishing}
}

@article{brosaplanella2020TSPMe,
title={Systematic derivation and validation of reduced thermal-electrochemical for Li-ion batteries using asymptotic methods}
journal={Submitted for publication},
author={Brosa Planella, Ferran and Sheikh, Muhammad and Widanage, Dhammika W},
year={2020},
eprint={},
archivePrefix={arXiv},
primaryClass={},
}
Expand Up @@ -27,7 +27,7 @@ def electrolyte_conductivity_Nyman2008(c_e, T):
0.1297 * (c_e / 1000) ** 3 - 2.51 * (c_e / 1000) ** 1.5 + 3.329 * (c_e / 1000)
)

E_k_e = 34700
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this a mistake in the original implementation?
you could argue we should just not have the arrhenius term in this case

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if a mistake, or we decided to keep the Arrhenius term from the Marquis2019 set (originally it all was in parameters.csv. However, if now it is specified as a function I think it would be good to stick to what the paper provides, and it this case, Nyman et al. 2008, does not provide temperature dependence so I removed it.

If that makes sense, I will remove the whole Arrhenius term so it is clearer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that makes sense, just remove the arrhenius term and put in a comment

E_k_e = 0 # no activation energy provided
arrhenius = exp(E_k_e / constants.R * (1 / 298.15 - 1 / T))

return sigma_e * arrhenius
Expand Up @@ -24,7 +24,7 @@ def electrolyte_diffusivity_Nyman2008(c_e, T):
"""

D_c_e = 8.794e-11 * (c_e / 1000) ** 2 - 3.972e-10 * (c_e / 1000) + 4.862e-10
E_D_e = 37040
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

E_D_e = 0 # no activation energy provided
arrhenius = exp(E_D_e / constants.R * (1 / 298.15 - 1 / T))

return D_c_e * arrhenius
Expand Up @@ -2,5 +2,6 @@
from .leading_order_conductivity import LeadingOrder
from .composite_conductivity import Composite
from .full_conductivity import Full
from .integrated_conductivity import Integrated

from . import surface_potential_form
@@ -0,0 +1,173 @@
#
# Composite electrolyte potential employing integrated Stefan-Maxwell
#
import pybamm
from .base_electrolyte_conductivity import BaseElectrolyteConductivity


class Integrated(BaseElectrolyteConductivity):
"""Integrated model for conservation of charge in the electrolyte derived from
integrating the Stefan-Maxwell constitutive equations.

Parameters
----------
param : parameter class
The parameters to use for this submodel
higher_order_terms : str
What kind of higher-order terms to use ('composite' or 'first-order')
domain : str, optional
The domain in which the model holds

**Extends:** :class:`pybamm.electrolyte_conductivity.BaseElectrolyteConductivity`
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add reference to your paper in the docstring


def __init__(self, param, domain=None):
pybamm.citations.register("brosaplanella2020TSPMe")
super().__init__(param, domain)

def _higher_order_macinnes_function(self, x):
return pybamm.log(x)

def get_coupled_variables(self, variables):
c_e_av = variables["X-averaged electrolyte concentration"]

i_boundary_cc_0 = variables["Leading-order current collector current density"]
c_e_n = variables["Negative electrolyte concentration"]
c_e_s = variables["Separator electrolyte concentration"]
c_e_p = variables["Positive electrolyte concentration"]
c_e_n0 = pybamm.boundary_value(c_e_n, "left")

delta_phi_n_av = variables[
"X-averaged negative electrode surface potential difference"
]
phi_s_n_av = variables["X-averaged negative electrode potential"]

tor_n = variables["Negative electrolyte tortuosity"]
tor_s = variables["Separator tortuosity"]
tor_p = variables["Positive electrolyte tortuosity"]

T_av = variables["X-averaged cell temperature"]
T_av_n = pybamm.PrimaryBroadcast(T_av, "negative electrode")
T_av_s = pybamm.PrimaryBroadcast(T_av, "separator")
T_av_p = pybamm.PrimaryBroadcast(T_av, "positive electrode")

param = self.param
l_n = param.l_n
l_p = param.l_p
x_n = pybamm.standard_spatial_vars.x_n
x_s = pybamm.standard_spatial_vars.x_s
x_p = pybamm.standard_spatial_vars.x_p
x_n_edge = pybamm.standard_spatial_vars.x_n_edge
x_p_edge = pybamm.standard_spatial_vars.x_p_edge

chi_av = param.chi(c_e_av)
chi_av_n = pybamm.PrimaryBroadcast(chi_av, "negative electrode")
chi_av_s = pybamm.PrimaryBroadcast(chi_av, "separator")
chi_av_p = pybamm.PrimaryBroadcast(chi_av, "positive electrode")

# electrolyte current
i_e_n = i_boundary_cc_0 * x_n / l_n
i_e_s = pybamm.PrimaryBroadcast(i_boundary_cc_0, "separator")
i_e_p = i_boundary_cc_0 * (1 - x_p) / l_p
i_e = pybamm.Concatenation(i_e_n, i_e_s, i_e_p)

i_e_n_edge = i_boundary_cc_0 * x_n_edge / l_n
i_e_s_edge = pybamm.PrimaryBroadcastToEdges(i_boundary_cc_0, "separator")
i_e_p_edge = i_boundary_cc_0 * (1 - x_p_edge) / l_p

# electrolyte potential
indef_integral_n = (
pybamm.IndefiniteIntegral(
i_e_n_edge / (param.kappa_e(c_e_n, T_av_n) * tor_n), x_n
)
* param.C_e
/ param.gamma_e
)
indef_integral_s = (
pybamm.IndefiniteIntegral(
i_e_s_edge / (param.kappa_e(c_e_s, T_av_s) * tor_s), x_s
)
* param.C_e
/ param.gamma_e
)
indef_integral_p = (
pybamm.IndefiniteIntegral(
i_e_p_edge / (param.kappa_e(c_e_p, T_av_p) * tor_p), x_p
)
* param.C_e
/ param.gamma_e
)

integral_n = indef_integral_n - pybamm.boundary_value(indef_integral_n, "left")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left boundary value of an indefinite integral should always be zero by definition (and implementation) but worth checking

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked, and maybe it evaluates to zero (actually it should), but is not zero by definition. The definition is

<bound method UnaryOperator.evaluate of BoundaryValue(-0x33bf8d7889aadb3a, boundary value, children=["* integrated w.r.t x_n on ['negative electrode'](3.0 * x_n ** 2.0)"], domain=['current collector'], auxiliary_domains={})>

integral_s = (
indef_integral_s
- pybamm.boundary_value(indef_integral_s, "left")
+ pybamm.boundary_value(integral_n, "right")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pybamm.Integral(a) should give the same value as pybamm.boundary_value(pybamm.IndefiniteIntegral(a), "right") while building a smaller tree

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but maybe it automatically gets simplified down to the same tree anyway

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I check if they reduce to the same tree? In any case, I think that if they are equivalent, using pybamm.Integral(a) and removing the boundary values on the left should result in a much more readable code.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried replacing the boundary value at the "right" by Integral and I get a very long error (see below) which basically looks like a dimension mismatch. So I guess they are not the same object...

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 817, in process_symbol
    return self._discretised_symbols[symbol.id]
KeyError: 1041553401910644705

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 817, in process_symbol
    return self._discretised_symbols[symbol.id]
KeyError: 2459353937759019131

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 817, in process_symbol
    return self._discretised_symbols[symbol.id]
KeyError: 4130260032263747209

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 817, in process_symbol
    return self._discretised_symbols[symbol.id]
KeyError: 7060176036539492958

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 817, in process_symbol
    return self._discretised_symbols[symbol.id]
KeyError: 8911840126246680561

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 817, in process_symbol
    return self._discretised_symbols[symbol.id]
KeyError: -7919469058354380383

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/expression_tree/symbol.py", line 594, in evaluate_for_shape
    return self._saved_evaluate_for_shape
AttributeError: 'MatrixMultiplication' object has no attribute '_saved_evaluate_for_shape'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/PyBaMM/pybamm/expression_tree/symbol.py", line 801, in test_shape
    self.shape_for_testing
  File "/home/ferranbrosa/PyBaMM/pybamm/expression_tree/symbol.py", line 785, in shape_for_testing
    evaluated_self = self.evaluate_for_shape()
  File "/home/ferranbrosa/PyBaMM/pybamm/expression_tree/symbol.py", line 596, in evaluate_for_shape
    self._saved_evaluate_for_shape = self._evaluate_for_shape()
  File "/home/ferranbrosa/PyBaMM/pybamm/expression_tree/binary_operators.py", line 201, in _evaluate_for_shape
    return self._binary_evaluate(left, right)
  File "/home/ferranbrosa/PyBaMM/pybamm/expression_tree/binary_operators.py", line 497, in _binary_evaluate
    return left @ right
  File "/home/ferranbrosa/coding/reduced-TEC/env/lib/python3.7/site-packages/scipy/sparse/base.py", line 564, in __matmul__
    return self.__mul__(other)
  File "/home/ferranbrosa/coding/reduced-TEC/env/lib/python3.7/site-packages/scipy/sparse/base.py", line 502, in __mul__
    raise ValueError('dimension mismatch')
ValueError: dimension mismatch

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ferranbrosa/miniconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/ferranbrosa/miniconda3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/ferranbrosa/.vscode-server/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
    cli.main()
  File "/home/ferranbrosa/.vscode-server/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/home/ferranbrosa/.vscode-server/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 267, in run_file
    runpy.run_path(options.target, run_name=compat.force_str("__main__"))
  File "/home/ferranbrosa/miniconda3/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/ferranbrosa/miniconda3/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/ferranbrosa/miniconda3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/ferranbrosa/coding/reduced-TEC/TSPMe_compare_DFN.py", line 91, in <module>
    sim.solve([0, 3700 / Crate])
  File "/home/ferranbrosa/PyBaMM/pybamm/simulation.py", line 338, in solve
    self.build(check_model=check_model)
  File "/home/ferranbrosa/PyBaMM/pybamm/simulation.py", line 291, in build
    self._model_with_set_params, inplace=False, check_model=check_model
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 173, in process_model
    self.set_internal_boundary_conditions(model)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 419, in set_internal_boundary_conditions
    rbc = (boundary_gradient(first_orphan, next_orphan), "Neumann")
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 399, in boundary_gradient
    right_symbol_disc = self.process_symbol(right_symbol)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 819, in process_symbol
    discretised_symbol = self._process_symbol(symbol)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 853, in _process_symbol
    disc_right = self.process_symbol(right)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 819, in process_symbol
    discretised_symbol = self._process_symbol(symbol)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 853, in _process_symbol
    disc_right = self.process_symbol(right)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 819, in process_symbol
    discretised_symbol = self._process_symbol(symbol)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 862, in _process_symbol
    disc_child = self.process_symbol(child)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 819, in process_symbol
    discretised_symbol = self._process_symbol(symbol)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 852, in _process_symbol
    disc_left = self.process_symbol(left)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 819, in process_symbol
    discretised_symbol = self._process_symbol(symbol)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 852, in _process_symbol
    disc_left = self.process_symbol(left)
  File "/home/ferranbrosa/PyBaMM/pybamm/discretisations/discretisation.py", line 821, in process_symbol
    discretised_symbol.test_shape()
  File "/home/ferranbrosa/PyBaMM/pybamm/expression_tree/symbol.py", line 803, in test_shape
    raise pybamm.ShapeError("Cannot find shape (original error: {})".format(e))

)
integral_p = (
indef_integral_p
- pybamm.boundary_value(indef_integral_p, "left")
+ pybamm.boundary_value(integral_s, "right")
)

phi_e_const = (
-delta_phi_n_av
+ phi_s_n_av
- (
chi_av
* (1 + param.Theta * T_av)
* pybamm.x_average(self._higher_order_macinnes_function(c_e_n / c_e_n0))
)
+ pybamm.x_average(integral_n)
)

phi_e_n = (
phi_e_const
+ (
chi_av_n
* (1 + param.Theta * T_av_n)
* self._higher_order_macinnes_function(c_e_n / c_e_n0)
)
- integral_n
)

phi_e_s = (
phi_e_const
+ (
chi_av_s
* (1 + param.Theta * T_av_s)
* self._higher_order_macinnes_function(c_e_s / c_e_n0)
)
- integral_s
)

phi_e_p = (
phi_e_const
+ (
chi_av_p
* (1 + param.Theta * T_av_p)
* self._higher_order_macinnes_function(c_e_p / c_e_n0)
)
- integral_p
)

# concentration overpotential
eta_c_av = (
chi_av
* (1 + param.Theta * T_av)
* (
pybamm.x_average(self._higher_order_macinnes_function(c_e_p / c_e_av))
- pybamm.x_average(self._higher_order_macinnes_function(c_e_n / c_e_av))
)
)

# average electrolyte ohmic losses
delta_phi_e_av = -(pybamm.x_average(integral_p) - pybamm.x_average(integral_n))

variables.update(
self._get_standard_potential_variables(phi_e_n, phi_e_s, phi_e_p)
)
variables.update(self._get_standard_current_variables(i_e))
variables.update(self._get_split_overpotential(eta_c_av, delta_phi_e_av))

return variables
@@ -0,0 +1,42 @@
#
# Test integrated Stefan Maxwell electrolyte conductivity submodel
#

import pybamm
import tests
import unittest


class TestFull(unittest.TestCase):
def test_public_functions(self):
param = pybamm.LithiumIonParameters()
a = pybamm.PrimaryBroadcast(0, "current collector")
c_e_n = pybamm.standard_variables.c_e_n
c_e_s = pybamm.standard_variables.c_e_s
c_e_p = pybamm.standard_variables.c_e_p
variables = {
"X-averaged electrolyte concentration": a,
"Leading-order current collector current density": a,
"Negative electrolyte concentration": c_e_n,
"Separator electrolyte concentration": c_e_s,
"Positive electrolyte concentration": c_e_p,
"X-averaged negative electrode surface potential difference": a,
"X-averaged negative electrode potential": a,
"Negative electrolyte tortuosity": a,
"Separator tortuosity": a,
"Positive electrolyte tortuosity": a,
"X-averaged cell temperature": a,
}
submodel = pybamm.electrolyte_conductivity.Integrated(param)
std_tests = tests.StandardSubModelTests(submodel, variables)
std_tests.test_all()


if __name__ == "__main__":
print("Add -v for more debug output")
import sys

if "-v" in sys.argv:
debug = True
pybamm.settings.debug_mode = True
unittest.main()