-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
Changes from 89 commits
92de548
e5d7c14
fb667b3
7899fdd
7b3df30
573db34
eec8354
5d7ca5d
334dd17
3eb9c68
4a3ebf7
5c5b7fa
00bfd7c
a8496db
34b94f3
e439182
3ebae0b
5548930
4c10748
7e3c823
3f76b27
577f5fc
a39ac10
9d30d37
e7897be
428e4aa
e30ddf9
f5bef85
7ebf86a
f0aa087
57c856b
320804b
bf92330
44bdd41
a0d17b5
90eb3ee
bef6b8c
80dc52d
3866e20
a5c51cd
7b55d57
06674fa
a923ca7
593ddd4
764fcec
96eb696
183a765
c0448ca
d790866
c135494
1cee889
a92fcf8
8dc661f
40b12c3
fb4f6d9
9e0d807
71d7a03
d8108e8
4e47666
6ec5ce6
4a6874f
b6626c0
93eefae
679ffbe
0a6dfd9
51f71c4
02ee792
2b77066
a91053d
7e6de9d
466e502
d11e266
a15c8d5
1521a3f
73a5bfa
85c77e7
3904114
1ae86bb
62c52ea
9999775
b55ede7
dd8e174
f4ba84e
cf39650
756e093
9d08f5e
0d19dbc
48ca85c
5eee5be
e615e4a
08d191c
6a89b7d
3f04c15
86051b9
a019e6b
8341306
4890bab
f35dd26
30ab27c
6aa1bb3
0308466
ddb5ac5
006dc25
480765f
9818f21
3afea4e
8672eff
e286ce0
c301814
f67357b
5d4bd51
49fa413
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
integral_s = ( | ||
indef_integral_s | ||
- pybamm.boundary_value(indef_integral_s, "left") | ||
+ pybamm.boundary_value(integral_n, "right") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but maybe it automatically gets simplified down to the same tree anyway There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just tried replacing the boundary value at the "right" by
|
||
) | ||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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