diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py index 073d1db873..c2f7a6f977 100644 --- a/pybamm/models/full_battery_models/base_battery_model.py +++ b/pybamm/models/full_battery_models/base_battery_model.py @@ -243,9 +243,15 @@ def __init__(self, extra_options): # provided # Change the default for stress-induced diffusion based on which particle - # mechanics option is provided + # mechanics option is provided. If the user doesn't supply a particle mechanics + # option set the default stress-induced diffusion option based on the default + # particle mechanics option which may change depending on other options + # (e.g. for stress-driven LAM the default mechanics option is "swelling only") mechanics_option = extra_options.get("particle mechanics", "none") - if mechanics_option == "none": + if ( + mechanics_option == "none" + and default_options["particle mechanics"] == "none" + ): default_options["stress-induced diffusion"] = "false" else: default_options["stress-induced diffusion"] = "true" diff --git a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py index 79c9eb07dc..6882ea458e 100644 --- a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py +++ b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py @@ -33,7 +33,7 @@ 'SEI': 'none' (possible: ['none', 'constant', 'reaction limited', 'solvent-diffusion limited', 'electron-migration limited', 'interstitial-diffusion limited', 'ec reaction limited']) 'SEI film resistance': 'none' (possible: ['none', 'distributed', 'average']) 'SEI porosity change': 'false' (possible: ['false', 'true']) -'stress-induced diffusion': 'false' (possible: ['false', 'true']) +'stress-induced diffusion': 'true' (possible: ['false', 'true']) 'surface form': 'differential' (possible: ['false', 'differential', 'algebraic']) 'thermal': 'x-full' (possible: ['isothermal', 'lumped', 'x-lumped', 'x-full']) 'total interfacial current density as a state': 'false' (possible: ['false', 'true']) @@ -250,6 +250,10 @@ def test_options(self): ) } ) + # check default options change + model = pybamm.BaseBatteryModel({"loss of active material": "stress-driven"}) + self.assertEqual(model.options["particle mechanics"], "swelling only") + self.assertEqual(model.options["stress-induced diffusion"], "true") # crack model with self.assertRaisesRegex(pybamm.OptionError, "particle mechanics"):