Skip to content

Commit

Permalink
add temperature dependence to MSMR model (pybamm-team#3832)
Browse files Browse the repository at this point in the history
* Bump to v23.9rc0

* Merge pull request pybamm-team#3412 from agriyakhetarpal/drop-i686-manylinux2014-support

Drop support for i686 manylinux

* Merge pull request pybamm-team#3413 from Saransh-cpp/improve-release-workflow

Improve release workflow, add a note, bump version manually

* Merge pull request pybamm-team#3436 from Saransh-cpp/fortnightly-wheels

Build wheels on the 1st and 15th of every month

* Merge pull request pybamm-team#3445 from pybamm-team/issue-3428-rename-exchange

pybamm-team#3428 exchange-current density error

* Merge pull request pybamm-team#3449 from pybamm-team/i3431-windows-wheels

Fix failing windows wheel builds

* Merge pull request pybamm-team#3456 from abillscmu/issue-3224-initial_soc

make initial soc work with half cell models

* Merge pull request pybamm-team#3467 from abillscmu/bugfix/initial_soh

* Merge pull request pybamm-team#3423 from jsbrittain/jax_gpu

JaxSolver fails when using GPU support with no input parameters

* Fix changelog

* Merge pull request pybamm-team#3475 from arjxn-py/fix-default-imports

Resolve default imports for optional dependencies

* Bump - `v23.9rc1`

* Fix date in CHANGELOG

* Bump version to v23.9

* Fix docs about Jax solver compatibility with Python versions (pybamm-team#3702)

* Ensure correct Python versions for Jax solver compatibility

* Simplify array of Python versions

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* Use different conjunction

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* Merge pull request pybamm-team#3706 from agriyakhetarpal/fix-pybamm-install-odes

Make `pybamm_install_odes` a bit more robust

* pybamm-team#3690 fix issue with skipped steps (pybamm-team#3708)

* pybamm-team#3690 fix issue with skipped steps

* pybamm-team#3690 changelog

* pybamm-team#3690 add test

* pybamm-team#3611 use actual cell volume for average total heating (pybamm-team#3707)

* pybamm-team#3611 use actual cell volume for average total heating

* pybamm-team#3611 changelog

* pybamm-team#3611 account for number of electrode pairs

* pybamm-team#3611 update variable names

* Improve the release workflow (pybamm-team#3737)

* Try fixing the release workflow

* Turn off safety

* Fix CHANGELOG

* Add OS

* Use regex for better matches

* Update instructions, add safety checks

* checkout to the version branch for the final release

* Bump to v24.1rc1

* pybamm-team#3630 fix interpolant shape error (pybamm-team#3761)

* pybamm-team#3630 fix interpolant shape error

* pybamm-team#3630 changelog

* Bump to v24.1rc2

* Bump to v24.1

* Fix doctests failures in scheduled tests (pybamm-team#3784)

Closes pybamm-team#3781

* Resolve broken `scikits.odes` installation on self-hosted M-series runner (pybamm-team#3785)

* Try fixing M-series runner tests

This is being done by adding SuiteSparse and SUNDIALS installations which might have been missing on the runner, which broke `scikits.odes`.

* Don't use Homebrew SUNDIALS, use LD_LIBRARY_PATH

* Don't use Homebrew to install SUNDIALS

* Force remove pip cache for `scikits.odes`

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

* add temperature dependence to MSMR model

* changelog

* fix tests

* fix example

* rob comments

* update notebook

---------

Co-authored-by: Ferran Brosa Planella <Ferran.Brosa-Planella@warwick.ac.uk>
Co-authored-by: Saransh Chopra <saransh0701@gmail.com>
Co-authored-by: Martin Robinson <martinjrobins@gmail.com>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Co-authored-by: Robert Timms <43040151+rtimms@users.noreply.github.com>
Co-authored-by: Saransh-cpp <Saransh-cpp@users.noreply.github.com>
  • Loading branch information
8 people authored and js1tr3 committed Aug 12, 2024
1 parent ee28414 commit 4b564de
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 139 deletions.
3 changes: 3 additions & 0 deletions docs/source/api/models/submodels/particle/msmr_diffusion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ MSMR Diffusion
.. autoclass:: pybamm.particle.MSMRDiffusion
:members:

.. autoclass:: pybamm.particle.MSMRStoichiometryVariables
:members:

.. footbibliography::
56 changes: 28 additions & 28 deletions docs/source/examples/notebooks/models/MSMR.ipynb

Large diffs are not rendered by default.

28 changes: 23 additions & 5 deletions pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,26 @@
# Remove any imported modules, so we don't expose them as part of pybamm
del sys

__all__ = ['batch_study', 'callbacks', 'citations', 'discretisations',
'doc_utils', 'experiment', 'expression_tree', 'geometry', 'input',
'logger', 'meshes', 'models', 'parameters', 'plotting', 'settings',
'simulation', 'solvers', 'spatial_methods', 'type_definitions',
'util', 'version']
__all__ = [
"batch_study",
"callbacks",
"citations",
"discretisations",
"doc_utils",
"experiment",
"expression_tree",
"geometry",
"input",
"logger",
"meshes",
"models",
"parameters",
"plotting",
"settings",
"simulation",
"solvers",
"spatial_methods",
"type_definitions",
"util",
"version",
]
11 changes: 11 additions & 0 deletions pybamm/models/full_battery_models/lithium_ion/dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ def set_particle_submodel(self):
submod = pybamm.particle.MSMRDiffusion(
self.param, domain, self.options, phase=phase, x_average=False
)
# also set the submodel for calculating stoichiometry from
# potential
self.submodels[f"{domain} {phase} stoichiometry"] = (
pybamm.particle.MSMRStoichiometryVariables(
self.param,
domain,
self.options,
phase=phase,
x_average=False,
)
)
self.submodels[f"{domain} {phase} particle"] = submod
self.submodels[f"{domain} {phase} total particle concentration"] = (
pybamm.particle.TotalConcentration(
Expand Down
24 changes: 13 additions & 11 deletions pybamm/models/full_battery_models/lithium_ion/electrode_soh.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def __init__(
x_n = param.n.prim.x
x_p = param.p.prim.x

T = param.T_ref
V_max = param.voltage_high_cut
V_min = param.voltage_low_cut
Q_n = pybamm.InputParameter("Q_n")
Expand All @@ -221,21 +222,21 @@ def __init__(
if "Un_0" in solve_for:
Un_0 = pybamm.Variable("Un(x_0)")
Up_0 = V_min + Un_0
x_0 = x_n(Un_0)
y_0 = x_p(Up_0)
x_0 = x_n(Un_0, T)
y_0 = x_p(Up_0, T)

# Define variables for 100% state of charge
# TODO: thermal effects (include dU/dT)
if "Un_100" in solve_for:
Un_100 = pybamm.Variable("Un(x_100)")
Up_100 = V_max + Un_100
x_100 = x_n(Un_100)
y_100 = x_p(Up_100)
x_100 = x_n(Un_100, T)
y_100 = x_p(Up_100, T)
else:
Un_100 = pybamm.InputParameter("Un(x_100)")
Up_100 = pybamm.InputParameter("Up(y_100)")
x_100 = x_n(Un_100)
y_100 = x_p(Up_100)
x_100 = x_n(Un_100, T)
y_100 = x_p(Up_100, T)

# Define equations for 100% state of charge
if "Un_100" in solve_for:
Expand Down Expand Up @@ -682,20 +683,20 @@ def get_initial_stoichiometries(self, initial_value, tol=1e-6, inputs=None):
soc = pybamm.Variable("soc")
x = x_0 + soc * (x_100 - x_0)
y = y_0 - soc * (y_0 - y_100)
T_ref = parameter_values["Reference temperature [K]"]
if self.options["open-circuit potential"] == "MSMR":
xn = param.n.prim.x
xp = param.p.prim.x
Up = pybamm.Variable("Up")
Un = pybamm.Variable("Un")
soc_model.algebraic[Up] = x - xn(Un)
soc_model.algebraic[Un] = y - xp(Up)
soc_model.algebraic[Up] = x - xn(Un, T_ref)
soc_model.algebraic[Un] = y - xp(Up, T_ref)
soc_model.initial_conditions[Un] = 0
soc_model.initial_conditions[Up] = V_max
soc_model.algebraic[soc] = Up - Un - V_init
else:
Up = param.p.prim.U
Un = param.n.prim.U
T_ref = parameter_values["Reference temperature [K]"]
soc_model.algebraic[soc] = Up(y, T_ref) - Un(x, T_ref) - V_init
# initial guess for soc linearly interpolates between 0 and 1
# based on V linearly interpolating between V_max and V_min
Expand Down Expand Up @@ -1051,14 +1052,15 @@ def _get_msmr_potential_model(parameter_values, param):
V_min = param.voltage_low_cut
x_n = param.n.prim.x
x_p = param.p.prim.x
T = param.T_ref
model = pybamm.BaseModel()
Un = pybamm.Variable("Un")
Up = pybamm.Variable("Up")
x = pybamm.InputParameter("x")
y = pybamm.InputParameter("y")
model.algebraic = {
Un: x_n(Un) - x,
Up: x_p(Up) - y,
Un: x_n(Un, T) - x,
Up: x_p(Up, T) - y,
}
model.initial_conditions = {
Un: 1 - x,
Expand Down
11 changes: 11 additions & 0 deletions pybamm/models/full_battery_models/lithium_ion/newman_tobias.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ def set_particle_submodel(self):
submod = pybamm.particle.MSMRDiffusion(
self.param, domain, self.options, phase=phase, x_average=True
)
# also set the submodel for calculating stoichiometry from
# potential
self.submodels[f"{domain} {phase} stoichiometry"] = (
pybamm.particle.MSMRStoichiometryVariables(
self.param,
domain,
self.options,
phase=phase,
x_average=True,
)
)
self.submodels[f"{domain} {phase} particle"] = submod
self.submodels[f"{domain} {phase} total particle concentration"] = (
pybamm.particle.TotalConcentration(
Expand Down
11 changes: 11 additions & 0 deletions pybamm/models/full_battery_models/lithium_ion/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ def set_particle_submodel(self):
submod = pybamm.particle.MSMRDiffusion(
self.param, domain, self.options, phase=phase, x_average=True
)
# also set the submodel for calculating stoichiometry from
# potential
self.submodels[f"{domain} {phase} stoichiometry"] = (
pybamm.particle.MSMRStoichiometryVariables(
self.param,
domain,
self.options,
phase=phase,
x_average=True,
)
)
self.submodels[f"{domain} {phase} particle"] = submod
self.submodels[f"{domain} {phase} total particle concentration"] = (
pybamm.particle.TotalConcentration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _get_standard_exchange_current_by_reaction_variables(self, j0, index):
return variables

def _get_kinetics_by_reaction(self, j0, ne, eta_r, T, u, index):
alpha = self.phase_param.alpha_bv_j(index)
alpha = self.phase_param.alpha_bv_j(T, index)
Feta_RT = self.param.F * eta_r / (self.param.R * T)
return (
u
Expand Down
13 changes: 9 additions & 4 deletions pybamm/models/submodels/particle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
from .polynomial_profile import PolynomialProfile
from .x_averaged_polynomial_profile import XAveragedPolynomialProfile
from .total_particle_concentration import TotalConcentration
from .msmr_diffusion import MSMRDiffusion
from .msmr_diffusion import MSMRDiffusion, MSMRStoichiometryVariables

__all__ = ['base_particle', 'fickian_diffusion', 'msmr_diffusion',
'polynomial_profile', 'total_particle_concentration',
'x_averaged_polynomial_profile']
__all__ = [
"base_particle",
"fickian_diffusion",
"msmr_diffusion",
"polynomial_profile",
"total_particle_concentration",
"x_averaged_polynomial_profile",
]
Loading

0 comments on commit 4b564de

Please sign in to comment.