-
-
Notifications
You must be signed in to change notification settings - Fork 553
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 1505 porosity #1617
Issue 1505 porosity #1617
Changes from 15 commits
bc5bdc3
97d80b2
371583b
1e47276
4e8fa90
09ba7ca
6aaf405
3a11b17
61342dc
ee12500
825ec71
b039fb8
92a84b6
701a224
d5113bf
94c6ab8
d8b3736
7a2dc5c
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ Porosity | |
base_porosity | ||
constant_porosity | ||
reaction_driven_porosity | ||
reaction_driven_porosity_ode | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Reaction-driven Model as an ODE | ||
=============================== | ||
|
||
.. autoclass:: pybamm.porosity.ReactionDrivenODE | ||
:members: | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
|
||
sim.solve(t_eval=t_eval, solver=solver) | ||
sims.append(sim) | ||
|
||
pb.dynamic_plot( | ||
sims, | ||
[ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .base_porosity import BaseModel | ||
from .constant_porosity import Constant | ||
from .reaction_driven_porosity import ReactionDriven | ||
from .reaction_driven_porosity_ode import ReactionDrivenODE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# | ||
# Class for reaction driven porosity changes as an ODE | ||
# | ||
import pybamm | ||
from .base_porosity import BaseModel | ||
|
||
|
||
class ReactionDrivenODE(BaseModel): | ||
"""Reaction-driven porosity changes as an ODE | ||
|
||
Parameters | ||
---------- | ||
param : parameter class | ||
The parameters to use for this submodel | ||
options : dict | ||
Options dictionary passed from the full model | ||
x_average : bool | ||
Whether to use x-averaged variables (SPM, SPMe, etc) or full variables (DFN) | ||
|
||
**Extends:** :class:`pybamm.porosity.BaseModel` | ||
""" | ||
|
||
def __init__(self, param, options, x_average): | ||
super().__init__(param, options) | ||
self.x_average = x_average | ||
|
||
def get_fundamental_variables(self): | ||
if self.x_average is True: | ||
eps_n_pc = pybamm.standard_variables.eps_n_pc | ||
eps_s_pc = pybamm.standard_variables.eps_s_pc | ||
eps_p_pc = pybamm.standard_variables.eps_p_pc | ||
|
||
eps_n = pybamm.PrimaryBroadcast(eps_n_pc, "negative electrode") | ||
eps_s = pybamm.PrimaryBroadcast(eps_s_pc, "separator") | ||
eps_p = pybamm.PrimaryBroadcast(eps_p_pc, "positive electrode") | ||
else: | ||
eps_n = pybamm.standard_variables.eps_n | ||
eps_s = pybamm.standard_variables.eps_s | ||
eps_p = pybamm.standard_variables.eps_p | ||
variables = self._get_standard_porosity_variables(eps_n, eps_s, eps_p) | ||
|
||
return variables | ||
|
||
def get_coupled_variables(self, variables): | ||
|
||
if self.x_average is True: | ||
j_n = variables["X-averaged negative electrode interfacial current density"] | ||
j_p = variables["X-averaged positive electrode interfacial current density"] | ||
# j_sei_n = variables[ | ||
# "X-averaged negative electrode SEI interfacial current density" | ||
# ] | ||
# j_plating = variables[ | ||
# "X-averaged negative electrode lithium plating " | ||
# "interfacial current density" | ||
# ] | ||
deps_s_dt = pybamm.PrimaryBroadcast(0, "current collector") | ||
else: | ||
j_n = variables["Negative electrode interfacial current density"] | ||
j_p = variables["Positive electrode interfacial current density"] | ||
# j_sei_n = variables["Negative electrode SEI interfacial current density"] | ||
# j_plating = variables[ | ||
# "Negative electrode lithium plating interfacial current density" | ||
# ] | ||
deps_s_dt = pybamm.FullBroadcast( | ||
0, "separator", auxiliary_domains={"secondary": "current collector"} | ||
) | ||
|
||
deps_n_dt = -self.param.beta_surf_n * j_n | ||
# Reaction driven porosity ODE for lithium-ion is not supported at the moment | ||
# if self.options["SEI porosity change"] == "true": | ||
# beta_sei_n = self.param.beta_sei_n | ||
# deps_n_dt += beta_sei_n * j_sei_n | ||
# if self.options["lithium plating porosity change"] == "true": | ||
# beta_plating = self.param.beta_plating | ||
# deps_n_dt += beta_plating * j_plating | ||
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 commented it out as it is not used. Should I delete it? Because it is checking the options rather than the submodels at the moment there is no way we can enter these 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. Yes can be removed |
||
|
||
deps_p_dt = -self.param.beta_surf_p * j_p | ||
|
||
variables.update( | ||
self._get_standard_porosity_change_variables( | ||
deps_n_dt, deps_s_dt, deps_p_dt | ||
) | ||
) | ||
|
||
return variables | ||
|
||
def set_rhs(self, variables): | ||
if self.x_average is True: | ||
for domain in ["negative electrode", "separator", "positive electrode"]: | ||
eps_av = variables["X-averaged " + domain + " porosity"] | ||
deps_dt_av = variables["X-averaged " + domain + " porosity change"] | ||
self.rhs.update({eps_av: deps_dt_av}) | ||
else: | ||
eps = variables["Porosity"] | ||
deps_dt = variables["Porosity change"] | ||
self.rhs = {eps: deps_dt} | ||
|
||
def set_initial_conditions(self, variables): | ||
if self.x_average is True: | ||
eps_n_av = variables["X-averaged negative electrode porosity"] | ||
eps_s_av = variables["X-averaged separator porosity"] | ||
eps_p_av = variables["X-averaged positive electrode porosity"] | ||
|
||
self.initial_conditions = { | ||
eps_n_av: self.param.epsilon_n_init, | ||
eps_s_av: self.param.epsilon_s_init, | ||
eps_p_av: self.param.epsilon_p_init, | ||
} | ||
else: | ||
eps = variables["Porosity"] | ||
self.initial_conditions = {eps: self.param.epsilon_init} |
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.
Had to add the rest periods and reduce the sampling period at discharge, otherwise simulations didn't converge.