-
-
Notifications
You must be signed in to change notification settings - Fork 712
Description
PyBaMM Version
25.10.1
Python Version
3.11.9
Describe the bug
Hello
I am using the sub model configuration below. Please note I am still interested in using the cracking submodel.
My code
model_options = {
"particle phases": ("2", "1"),
"open-circuit potential": (("single", "current sigmoid"), "single"),
"SEI": "ec reaction limited",
"particle mechanics": ("swelling and cracking","swelling only"),
"loss of active material": "stress-driven",
"SEI on cracks": "true",
"surface form": "algebraic",
}
And I am getting the following error.
Error:
KeyError Traceback (most recent call last)
pybamm\models\base_model.py:831, in BaseModel.build_coupled_variables(self)
830 model_var_copy = self.variables.copy()
--> 831 updated_variables = submodel.get_coupled_variables(
832 self.variables
833 )
834 self._variables_by_submodel[submodel_name].update(
835 {
836 key: updated_variables[key]
(...)
839 }
840 )
\pybamm\models\submodels\interface\sei\sei_growth.py:119, in SEIGrowth.get_coupled_variables(self, variables)
114 j = variables[
115 f"X-averaged {domain} electrode total "
116 "interfacial current density [A.m-2]"
117 ]
--> 119 L_sei = variables[f"{Domain} {self.reaction_name}thickness [m]"]
121 R_sei = phase_param.R_sei
KeyError: 'Negative primary SEI on cracks thickness [m]'
The above exception was the direct cause of the following exception:
ModelError Traceback (most recent call last)
Cell In[1], line 53
28 # nominal_value= [
29 # 9.708425e-14, # primary: SEI kinetic rate constant [m.s-1] X[0]
30 # 7.663143e-22, # primary: EC diffusivity [m2.s-1] X[1]
(...)
46 # 10e9 # secondary: negative electrode Young's modulus [Pa] X[17]
47 # ]
49 nominal_value = last_results.Value
---> 53 model = pybamm.lithium_ion.SPMe(
54 options=model_options
55 )
57 # Define the discretization points
58 var_pts = {
59 "x_n": 10, # negative electrode
60 "x_s": 3, # separator
(...)
67 'r_p_sec': 30,
68 }
pybamm\models\full_battery_models\lithium_ion\spme.py:32, in SPMe.init(self, options, name, build)
29 self.x_average = True
31 # Initialize with the SPM
---> 32 super().init(options, name, build)
pybamm\models\full_battery_models\lithium_ion\spm.py:45, in SPM.init(self, options, name, build)
41 options["x-average side reactions"] = "true"
43 super().init(options, name)
---> 45 self.set_submodels(build)
47 if self.class != "MPM":
48 pybamm.citations.register("Marquis2019")
pybamm\models\full_battery_models\lithium_ion\base_lithium_ion_model.py:63, in BaseModel.set_submodels(self, build)
60 self.set_total_interface_submodel()
62 if build:
---> 63 self.build_model()
pybamm\models\full_battery_models\base_battery_model.py:1176, in BaseBatteryModel.build_model(self)
1174 def build_model(self):
1175 # Build model variables and equations
-> 1176 self._build_model()
1178 # Set battery specific variables
1179 pybamm.logger.debug(f"Setting voltage variables ({self.name})")
pybamm\models\base_model.py:904, in BaseModel._build_model(self)
901 if self._built_fundamental is False:
902 self.build_fundamental()
--> 904 self.build_coupled_variables()
906 self.build_model_equations()
pybamm\models\base_model.py:846, in BaseModel.build_coupled_variables(self)
843 except KeyError as key:
844 if len(submodels) == 1 or count == 100:
845 # no more submodels to try
--> 846 raise pybamm.ModelError(
847 f"Missing variable for submodel '{submodel_name}': {key}.\n"
848 + "Check the selected "
849 "submodels provide all of the required variables."
850 ) from key
851 else:
852 # try setting coupled variables on next loop through
853 pybamm.logger.debug(
854 f"Can't find {key}, trying other submodels first"
855 )
ModelError: Missing variable for submodel 'negative primary sei on cracks': 'Negative primary SEI on cracks thickness [m]'.
Check the selected submodels provide all of the required variables.
Steps to Reproduce
Parameter set
param = pybamm.ParameterValues("Chen2020_composite")
model
var_pts = {
"x_n": 10, # negative electrode
"x_s": 3, # separator
"x_p": 10, # positive electrode
"r_n": 30, # negative particle
"r_p": 30, # positive particle
'r_n_prim': 30,
'r_p_prim': 30,
'r_n_sec': 30,
'r_p_sec': 30,
}
experiment_test = pybamm.Experiment(
[
("Rest for 20 min", "Charge at 1.7A until 4.2V", "Discharge at 1.7A until 2.65 V","Rest for 20 min")*2
]
)
solver = pybamm.IDAKLUSolver()
model = pybamm.lithium_ion.SPMe(
options={
"particle phases": ("2", "1"),
"open-circuit potential": (("single", "current sigmoid"), "single"),
"SEI": "ec reaction limited",
"particle mechanics": ("swelling and cracking","swelling only"),
"loss of active material": "stress-driven",
"SEI on cracks": "true",
"surface form": "algebraic",
}
)
sim = pybamm.Simulation(model, parameter_values=param, experiment=experiment_test, var_pts=var_pts, solver=solver)
sol = sim.solve(calc_esoh=True, showprogress=True,initial_soc=0.0)
Relevant log output
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
pybamm\models\base_model.py:831, in BaseModel.build_coupled_variables(self)
830 model_var_copy = self.variables.copy()
--> 831 updated_variables = submodel.get_coupled_variables(
832 self.variables
833 )
834 self._variables_by_submodel[submodel_name].update(
835 {
836 key: updated_variables[key]
(...)
839 }
840 )
pybamm\models\submodels\interface\sei\sei_growth.py:119, in SEIGrowth.get_coupled_variables(self, variables)
114 j = variables[
115 f"X-averaged {domain} electrode total "
116 "interfacial current density [A.m-2]"
117 ]
--> 119 L_sei = variables[f"{Domain} {self.reaction_name}thickness [m]"]
121 R_sei = phase_param.R_sei
KeyError: 'Negative primary SEI on cracks thickness [m]'
The above exception was the direct cause of the following exception:
ModelError Traceback (most recent call last)
Cell In[1], line 53
28 # nominal_value= [
29 # 9.708425e-14, # primary: SEI kinetic rate constant [m.s-1] X[0]
30 # 7.663143e-22, # primary: EC diffusivity [m2.s-1] X[1]
(...)
46 # 10e9 # secondary: negative electrode Young's modulus [Pa] X[17]
47 # ]
49 nominal_value = last_results.Value
---> 53 model = pybamm.lithium_ion.SPMe(
54 options=model_options
55 )
57 # Define the discretization points
58 var_pts = {
59 "x_n": 10, # negative electrode
60 "x_s": 3, # separator
(...)
67 'r_p_sec': 30,
68 }
pybamm\models\full_battery_models\lithium_ion\spme.py:32, in SPMe.__init__(self, options, name, build)
29 self.x_average = True
31 # Initialize with the SPM
---> 32 super().__init__(options, name, build)
pybamm\models\full_battery_models\lithium_ion\spm.py:45, in SPM.__init__(self, options, name, build)
41 options["x-average side reactions"] = "true"
43 super().__init__(options, name)
---> 45 self.set_submodels(build)
47 if self.__class__ != "MPM":
48 pybamm.citations.register("Marquis2019")
pybamm\models\full_battery_models\lithium_ion\base_lithium_ion_model.py:63, in BaseModel.set_submodels(self, build)
60 self.set_total_interface_submodel()
62 if build:
---> 63 self.build_model()
pybamm\models\full_battery_models\base_battery_model.py:1176, in BaseBatteryModel.build_model(self)
1174 def build_model(self):
1175 # Build model variables and equations
-> 1176 self._build_model()
1178 # Set battery specific variables
1179 pybamm.logger.debug(f"Setting voltage variables ({self.name})")
pybamm\models\base_model.py:904, in BaseModel._build_model(self)
901 if self._built_fundamental is False:
902 self.build_fundamental()
--> 904 self.build_coupled_variables()
906 self.build_model_equations()
pybamm\models\base_model.py:846, in BaseModel.build_coupled_variables(self)
843 except KeyError as key:
844 if len(submodels) == 1 or count == 100:
845 # no more submodels to try
--> 846 raise pybamm.ModelError(
847 f"Missing variable for submodel '{submodel_name}': {key}.\n"
848 + "Check the selected "
849 "submodels provide all of the required variables."
850 ) from key
851 else:
852 # try setting coupled variables on next loop through
853 pybamm.logger.debug(
854 f"Can't find {key}, trying other submodels first"
855 )
ModelError: Missing variable for submodel 'negative primary sei on cracks': 'Negative primary SEI on cracks thickness [m]'.
Check the selected submodels provide all of the required variables.