-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
Issue 836 add lithium plating #1009
Issue 836 add lithium plating #1009
Conversation
Adds new SEI reaction "ec reaction limited"
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.
Thanks @felipe-salinas , impressed with how quickly you have got to grips with the submodel structure. Some additional things to do are:
- Add the EC SEI model to the
sei.rst
docs - Add the EC SEI model to the
BaseBatteryModel
docstring - Add unit and integration tests for using the EC SEI model with the SPM, SPMe, DFN. You can just copy the test for the other SEI models and change the option (see
test_spm.py
, etc)
It looks like you also undid some changes in the merge, please check this. The automatic tests didn't start because we recently switched from travis to github actions but this should be fixed by the time you push again
|
||
options = {"sei": "ec reaction limited", | ||
"sei film resistance": "distributed", | ||
"porosity": "variable porosity"} |
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.
Note that the "sei film resistance" is set automatically by the following lines in BaseBatteryModel
:
# Change the default for SEI film resistance based on which sei option is
# provided
extra_options = extra_options or {}
sei_option = extra_options.get("sei", None) # return None if option not given
if sei_option is None:
default_options["sei film resistance"] = None
else:
default_options["sei film resistance"] = "distributed"
Something similar could be done for porosity
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.
Thanks for the tip: I will erase the redundant setting for sei film resistance in this example. In the case of porosity, It would be a nice feature, but the variable porosity is not a default option for SEI models (older publications like Ramadass et. al. 2003 don't include it), so I think that is better to leave it as a "visible" option.
] | ||
eta_sei_av = eta_sei_n_av + eta_sei_p_av | ||
eta_sei_av_dim = eta_sei_n_av_dim + eta_sei_p_av_dim | ||
|
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.
lines deleted accidentally?
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.
Sorry, I grabbed an older version of develop :/
@@ -684,8 +670,6 @@ def set_voltage_variables(self): | |||
"Measured open circuit voltage [V]": ocv_dim, | |||
"X-averaged reaction overpotential": eta_r_av, | |||
"X-averaged reaction overpotential [V]": eta_r_av_dim, | |||
"X-averaged sei film overpotential": eta_sei_av, | |||
"X-averaged sei film overpotential [V]": eta_sei_av_dim, |
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.
lines deleted accidentally?
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.
I think it is correct now.
if self.options["porosity"] is None: | ||
self.submodels["porosity"] = pybamm.porosity.Constant(self.param) | ||
elif self.options["porosity"] == "variable porosity": | ||
self.submodels["porosity"] = pybamm.porosity.Full(self.param) |
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.
equivalent changes need to be made in SPM
and SPMe
models
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.
Done.
|
||
L_scale = pybamm.sei_parameters.L_sei_0_dim | ||
# in this model the scale is identical to the intercalation current | ||
j_scale = pybamm.sei_parameters.j_scale |
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.
j_scale
is different in the negaive and positive electrodes so you need to be a bit careful here (though at the moment an error will be raised if the positive electrode sei model isn't NoSEI
, so it might be ok)
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.
Modified in the file to explicitly recover the negative scale.
|
||
self.algebraic = {j_sei: j_sei + C_sei_ec * c_ec * pybamm.exp(- 0.5 * ( | ||
phi_s_n - phi_e_n - j * L_sei * R_sei)), | ||
c_ec: c_ec - pybamm.Scalar(1) - j_sei * L_sei * C_ec} |
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.
it looks like j_sei
and c_ec
can be defined explicitly in terms of other variables in get_coupled_variables
, instead of being made Variable
objects themselves. While this will give the same answer, it's best to try to reduce the number of equations, especially algebraic
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.
c_ec and j_sei are present in both equations, and j_sei depends on itself because it is included in j (the total current). I think that makes it necessary to implement j_sei
with an algebraic equation. c_ec is now defined by the other variables.
deps_p_dt = -self.param.beta_surf_p * j_p | ||
# for the moment is not needed but could be used for positive SEI | ||
deps_p_dt = pybamm.FullBroadcast(0, "positive electrode", | ||
"current collector") |
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.
The beta_surf_n * j_n
and beta_surf_p * j_p
terms should be kept as they are used in the lead-acid models. You can do this by setting beta_surf_n
and beta_surf_p
to zero in standard_parameters_lithium_ion
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.
I created another class because they have different purposes.
pybamm/parameters/sei_parameters.py
Outdated
) | ||
C_sei_reaction = ( | ||
F * L_sei_0_dim / (m_sei_dimensional * tau_discharge * V_bar_inner_dimensional) | ||
) * pybamm.exp(-(F * U_n_ref / (2 * R * T_ref))) |
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.
please fix the changes overwritten in this file
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.
Done.
"Sum of negative electrode interfacial current densities", | ||
#"Negative electrode EC surface concentration", | ||
] | ||
) |
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.
nice example!
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.
:D
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.
Thanks @felipe-salinas , getting there, just some more comments and need to add the docs and tests
if self.options["porosity"] is None: | ||
self.submodels["porosity"] = pybamm.porosity.Constant(self.param) | ||
elif self.options["porosity"] == "variable porosity": | ||
self.submodels["porosity"] = pybamm.porosity.SeiFull(self.param) |
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.
For the SPM, given that j_sei
is uniform in x, using the "SeiFull" porosity submodel creates unnecessarily many states for the porosity (i.e. when discretised, there will be n
ODEs where n
is the number of grid points, instead of just one ODE for each domain). You could use the "leading order reaction driven porosity" model instead
if self.options["porosity"] is None: | ||
self.submodels["porosity"] = pybamm.porosity.Constant(self.param) | ||
elif self.options["porosity"] == "variable porosity": | ||
self.submodels["porosity"] = pybamm.porosity.SeiFull(self.param) |
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.
Same comment as for the SPM
) | ||
) | ||
|
||
return variables |
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.
Still not convinced this warrants a whole separate submodel. All you would need to do to reuse the full submodel is to add these lines to standard_parameters_lithium_ion.py
:
beta_surf_n = pybamm.Scalar(0)
beta_surf_p = pybamm.Scalar(0)
By the way, just so you are aware, deps_dt
comes into the dce_dt
equation (see e.g. full_diffusion.py
) so a changing porosity will affect the electrolyte concentration (make the electrolyte more concentrated) - again, this comes from the lead-acid models
Merge develop
Now #1073 |
Description
Adds SEI model based on Yang et. al. (see #836) and reduction in negative electrode porosity.
Fixes # (issue)
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ flake8
$ python run-tests.py --unit
$ cd docs
and then$ make clean; make html
You can run all three at once, using
$ python run-tests.py --quick
.Further checks: