Skip to content

Commit

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

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

Drop support for i686 manylinux

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

Improve release workflow, add a note, bump version manually

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

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

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

#3428 exchange-current density error

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

Fix failing windows wheel builds

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

make initial soc work with half cell models

* Merge pull request #3467 from abillscmu/bugfix/initial_soh

* Merge pull request #3423 from jsbrittain/jax_gpu

JaxSolver fails when using GPU support with no input parameters

* Fix changelog

* Merge pull request #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 (#3702)

* Ensure correct Python versions for Jax solver compatibility

* Simplify array of Python versions

Co-authored-by: Eric G. Kratz <[email protected]>

* Use different conjunction

Co-authored-by: Eric G. Kratz <[email protected]>

---------

Co-authored-by: Eric G. Kratz <[email protected]>

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

Make `pybamm_install_odes` a bit more robust

* #3690 fix issue with skipped steps (#3708)

* #3690 fix issue with skipped steps

* #3690 changelog

* #3690 add test

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

* #3611 use actual cell volume for average total heating

* #3611 changelog

* #3611 account for number of electrode pairs

* #3611 update variable names

* Improve the release workflow (#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

* #3630 fix interpolant shape error (#3761)

* #3630 fix interpolant shape error

* #3630 changelog

* Bump to v24.1rc2

* Bump to v24.1

* Fix doctests failures in scheduled tests (#3784)

Closes #3781

* Resolve broken `scikits.odes` installation on self-hosted M-series runner (#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 <[email protected]>

* add temperature dependence to MSMR model

* changelog

* fix tests

* fix example

* rob comments

* update notebook

---------

Co-authored-by: Ferran Brosa Planella <[email protected]>
Co-authored-by: Saransh Chopra <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
Co-authored-by: Agriya Khetarpal <[email protected]>
Co-authored-by: Eric G. Kratz <[email protected]>
Co-authored-by: Robert Timms <[email protected]>
Co-authored-by: Saransh-cpp <[email protected]>
  • Loading branch information
8 people authored May 16, 2024
1 parent afbf21d commit 33d9ea7
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 140 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Lithium plating now works on composite electrodes ([#3919](https://github.com/pybamm-team/PyBaMM/pull/3919))
- Added lithium plating parameters to `Ecker2015` and `Ecker2015_graphite_halfcell` parameter sets ([#3919](https://github.com/pybamm-team/PyBaMM/pull/3919))
- Added custom experiment steps ([#3835](https://github.com/pybamm-team/PyBaMM/pull/3835))
- MSMR open-circuit voltage model now depends on the temperature ([#3832](https://github.com/pybamm-team/PyBaMM/pull/3832))
- Added support for macOS arm64 (M-series) platforms. ([#3789](https://github.com/pybamm-team/PyBaMM/pull/3789))
- Added the ability to specify a custom solver tolerance in `get_initial_stoichiometries` and related functions ([#3714](https://github.com/pybamm-team/PyBaMM/pull/3714))
- Modified `step` function to take an array of time `t_eval` as an argument and deprecated use of `npts`. ([#3627](https://github.com/pybamm-team/PyBaMM/pull/3627))
Expand Down Expand Up @@ -67,7 +68,6 @@
- Added a method, `insert_reference_electrode`, to `pybamm.lithium_ion.BaseModel` that insert a reference electrode to measure the electrolyte potential at a given position in space and adds new variables that mimic a 3E cell setup. ([#3573](https://github.com/pybamm-team/PyBaMM/pull/3573))
- Serialisation added so models can be written to/read from JSON ([#3397](https://github.com/pybamm-team/PyBaMM/pull/3397))
- Added a `get_parameter_info` method for models and modified "print_parameter_info" functionality to extract all parameters and their type in a tabular and readable format ([#3584](https://github.com/pybamm-team/PyBaMM/pull/3584))
- Mechanical parameters are now a function of stoichiometry and temperature ([#3576](https://github.com/pybamm-team/PyBaMM/pull/3576))

## Bug fixes

Expand Down
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 33d9ea7

Please sign in to comment.