-
-
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
Merged
Merged
Issue 1505 porosity #1617
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bc5bdc3
#1505 reformatted model but getting different answers
valentinsulzer 97d80b2
#1505 merge develop
valentinsulzer 371583b
#1505 modified porosity submodel but still not fully working
brosaplanella 1e47276
#1505 update but still not working
brosaplanella 4e8fa90
#1505 removed sphere model and just kept planar
brosaplanella 09ba7ca
flake8
brosaplanella 6aaf405
Merge branch 'develop' into issue-1505-porosity
brosaplanella 3a11b17
#1505 fix lead-acid models
brosaplanella 61342dc
#1505 fix porosity tests
brosaplanella ee12500
#1505 fix example calendar aging
brosaplanella 825ec71
#1505 revert calendar ageing
brosaplanella b039fb8
#1505 fix example
brosaplanella 92a84b6
flake8
brosaplanella 701a224
#1505 fix coverage
brosaplanella d5113bf
flake8
brosaplanella 94c6ab8
Merge branch 'develop' into issue-1505-porosity
brosaplanella d8b3736
#1505 removed SEI and plating lines
brosaplanella 7a2dc5c
#1505 update CHANGELOG
brosaplanella File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
8 changes: 8 additions & 0 deletions
8
docs/source/models/submodels/porosity/reaction_driven_porosity_ode.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
pybamm/models/submodels/porosity/reaction_driven_porosity_ode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# 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"] | ||
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"] | ||
deps_s_dt = pybamm.FullBroadcast( | ||
0, "separator", auxiliary_domains={"secondary": "current collector"} | ||
) | ||
|
||
deps_n_dt = -self.param.beta_surf_n * j_n | ||
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.