Skip to content

Ensure stress-induced diffusion is only enabled on electrodes that have particle mechanics #4944

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

## Bug fixes

- Added code to `base_battery_model` to ensure default options for stress-induced diffusion change correctly if particle mechanics is only enabled on one electrode ([#4944](https://github.com/pybamm-team/PyBaMM/pull/4944))
- Fixed a bug with observing the outputs of 2D FEM simulations. ([#4912](https://github.com/pybamm-team/PyBaMM/pull/4912))
- Fixed a bug in simulating FEM models with the `IDAKLUSolver`. ([#4879](https://github.com/pybamm-team/PyBaMM/pull/4879))
- Moved concentration inside x-averaged when calculating LLI due to LAM variables ([#4858](https://github.com/pybamm-team/PyBaMM/pull/4858))
Expand Down
15 changes: 15 additions & 0 deletions src/pybamm/models/full_battery_models/base_battery_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,21 @@ def __init__(self, extra_options):
and default_options["particle mechanics"] == "none"
):
default_options["stress-induced diffusion"] = "false"
elif (
mechanics_option == ("none", "swelling only")
and default_options["particle mechanics"] == "none"
):
default_options["stress-induced diffusion"] = ("false", "true")
elif (
mechanics_option == ("swelling only", "none")
and default_options["particle mechanics"] == "none"
):
default_options["stress-induced diffusion"] = ("true", "false")
elif (
mechanics_option == ("swelling and cracking", "none")
and default_options["particle mechanics"] == "none"
):
default_options["stress-induced diffusion"] = ("true", "false")
else:
default_options["stress-induced diffusion"] = "true"
# The "stress-induced diffusion" option will still be overridden by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,20 @@ def test_options(self):
assert model.options["particle mechanics"] == "swelling and cracking"
assert model.options["stress-induced diffusion"] == "true"

# crack model
# particle mechanics
with pytest.raises(pybamm.OptionError, match="particle mechanics"):
pybamm.BaseBatteryModel({"particle mechanics": "bad particle cracking"})
pybamm.BaseBatteryModel({"particle mechanics": "bad particle mechanics"})
with pytest.raises(pybamm.OptionError, match="particle cracking"):
pybamm.BaseBatteryModel({"particle cracking": "bad particle cracking"})
# check default options change correctly
model = pybamm.BaseBatteryModel(
{"particle mechanics": ("none", "swelling-only")}
)
assert model.options["stress-induced diffusion"] == ("false", "true")
model = pybamm.BaseBatteryModel(
{"particle mechanics": ("swelling-only", "none")}
)
assert model.options["stress-induced diffusion"] == ("true", "false")

# SEI on cracks
with pytest.raises(pybamm.OptionError, match="SEI on cracks"):
Expand Down