You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using PyBaMM-EIS with the degradation model enabled, However, it is keeping me with the following errors, whereas when using the typical time domain method it is correctly giving the EIS results.
Is it a issue with PyBaMM-EIS.
Also in your examples to import PybaMM EIS you mentioned using import pybammeis but it can only import with import pbeis.
importpybammimportmatplotlib.pyplotaspltimportnumpyasnpfromscipy.fftimportfftimporttimeastimer# Set random seednp.random.seed(0)
# Load parameterspp=pybamm.ParameterValues("OKane2022")
# Define model with configurationmodel=pybamm.lithium_ion.SPMe(
{
"thermal": "lumped", #lumped thermal submodel "surface form": "differential", #Adding capacitance to the model "SEI":"solvent-diffusion limited", #"reaction limited","SEI porosity change": "true",
#"lithium plating": "partially reversible",#"lithium plating porosity change": "true", # alias for "SEI porosity change"#"particle mechanics":"swelling only","particle mechanics":"swelling and cracking",
"SEI on cracks": "true",
#"loss of active material": "stress-driven",
}
)
var_pts= {
"x_n": 5,
"x_s": 5,
"x_p": 5,
"r_n": 30,
"r_p": 30,
}
defget_chen2020_parameters():
parameter_values=pybamm.ParameterValues("Chen2020")
parameters=parameter_valuesreturnparametersdefget_okane2022_degradation_parameters():
degradation_parameters= {
'Dead lithium decay constant [s-1]': 1e-06,
'Dead lithium decay rate [s-1]':pp["Dead lithium decay rate [s-1]"],
'Initial plated lithium concentration [mol.m-3]': 0.0,
'Lithium metal partial molar volume [m3.mol-1]': 1.3e-05,
'Lithium plating kinetic rate constant [m.s-1]': 1e-09,
'Lithium plating transfer coefficient': 0.65,
'Negative electrode LAM constant exponential term': 2.0,
'Negative electrode LAM constant proportional term [s-1]': 2.7778e-07,
"Negative electrode Paris' law constant b": 1.12,
"Negative electrode Paris' law constant m": 2.2,
"Negative electrode Poisson's ratio": 0.3,
"Negative electrode Young's modulus [Pa]": 15000000000.0,
'Negative electrode cracking rate':pp["Negative electrode cracking rate"],
'Negative electrode critical stress [Pa]': 60000000.0,
'Negative electrode initial crack length [m]': 2e-08,
'Negative electrode initial crack width [m]': 1.5e-08,
'Negative electrode number of cracks per unit area [m-2]': 3180000000000000.0,
'Negative electrode partial molar volume [m3.mol-1]': 3.1e-06,
'Negative electrode reference concentration for free of deformation [mol.m-3]': 0.0,
'Negative electrode volume change':pp["Negative electrode volume change"],
'Positive electrode LAM constant exponential term': 2.0,
'Positive electrode LAM constant proportional term [s-1]': 2.7778e-07,
'Positive electrode OCP entropic change [V.K-1]': 0.0,
"Positive electrode Paris' law constant b": 1.12,
"Positive electrode Paris' law constant m": 2.2,
"Positive electrode Poisson's ratio": 0.2,
"Positive electrode Young's modulus [Pa]": 375000000000.0,
'Positive electrode active material volume fraction': 0.665,
'Positive electrode cracking rate':pp["Positive electrode cracking rate"],
'Positive electrode critical stress [Pa]': 375000000.0,
'Positive electrode initial crack length [m]': 2e-08,
'Positive electrode initial crack width [m]': 1.5e-08,
'Positive electrode number of cracks per unit area [m-2]': 3180000000000000.0,
'Positive electrode partial molar volume [m3.mol-1]': 1.25e-05,
'Positive electrode reference concentration for free of deformation [mol.m-3]': 0.0,
'Positive electrode volume change':pp["Positive electrode volume change"],
'Typical plated lithium concentration [mol.m-3]': 1000.0,
'Exchange-current density for stripping [A.m-2]':pp["Exchange-current density for stripping [A.m-2]"],
'Exchange-current density for plating [A.m-2]':pp["Exchange-current density for plating [A.m-2]"],
}
returndegradation_parametersdefupdate_parameters():
# Load Chen2020 parameterschen2020_params=get_chen2020_parameters()
# Load OKane2022 degradation parametersokane2022_degradation_params=get_okane2022_degradation_parameters()
# Update Chen2020 parameters with OKane2022 degradation parameterschen2020_params.update(okane2022_degradation_params, check_already_exists=False)
returnchen2020_paramsupdated_parameters=update_parameters()
# Simulation parameterscycle_numbers= [1]
frequencies=np.logspace(-4, 3, 30)
I=1e-3# Current amplitude for EISnumber_of_periods=20samples_per_period=20# Store results for Nyquist plotimpedance_data= {}
# Loop through each cycle countforcycle_numberincycle_numbers:
exp=pybamm.Experiment(
[
(
"Discharge at 1C until 2.5 V", # ageing cycles"Charge at 0.6C until 4.2 V (5 minute period)",
"Hold at 4.2 V until C/100 (5 minute period)",
)
]
*cycle_number
)
sim=pybamm.Simulation(
model,
parameter_values=updated_parameters,
experiment=exp,
solver=pybamm.CasadiSolver(mode='safe without grid'),
var_pts=var_pts,
)
sol=sim.solve()
# Set initial conditions of aged_model from the solution and EIS Runningaged_model=model.set_initial_conditions_from(sol)
eis_sim=pbeis.EISSimulation(aged_model)
# calculate impedance at log-spaced frequencieseis_sim.solve(np.logspace(-2, 4, 30))
eis_sim.nyquist_plot()
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:559, inParameterValues.process_symbol(self, symbol)
558try:
-->559returnself._processed_symbols[symbol]
560exceptKeyError:
KeyError: XAverage(0x39c1c2e9f02566c4, x-average, children=["Negative electrode cracking rate * (Negative electrode Young's modulus [Pa] ** Negative electrode Paris' law constant m) * (Negative electrode initial crack length [m] ** ((Negative electrode Paris' law constant m / 2.0) - 1.0)) * ((((Negative electrode partial molar volume [m3.mol-1] * Negative electrode Young's modulus [Pa] / 3.0 / (1.0 - Negative electrode Poisson's ratio)) * (broadcast(r-average(X-averaged negative particle concentration)) - broadcast(boundary value(X-averaged negative particle concentration))) * Maximum concentration in negative electrode [mol.m-3] / Negative electrode Young's modulus [Pa]) * Negative electrode Paris' law constant b * sqrt(broadcast(3.141592653589793 * X-averaged negative particle crack length)) * (0.0 <= (Negative electrode partial molar volume [m3.mol-1] * Negative electrode Young's modulus [Pa] / 3.0 / (1.0 - Negative electrode Poisson's ratio)) * (broadcast(r-average(X-averaged negative particle concentration)) - broadcast(boundary value(X-averaged negative particle concentration))) * Maximum concentration in negative electrode [mol.m-3] / Negative electrode Young's modulus [Pa])) ** Negative electrode Paris' law constant m) / (3600.0 / (abs(Typical current [A] / Nominal cell capacity [A.h]) * 96485.33212 * Maximum concentration in negative electrode [mol.m-3] * (Negative electrode thickness [m] + Separator thickness [m] + Positive electrode thickness [m]) / absolute(Typical current [A] / (Number of electrodes connected in parallel to make a cell * Electrode width [m] * Electrode height [m]))))"], domains={'primary': ['current collector']})
Duringhandlingoftheaboveexception, anotherexceptionoccurred:
KeyErrorTraceback (mostrecentcalllast)
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:559, inParameterValues.process_symbol(self, symbol)
558try:
-->559returnself._processed_symbols[symbol]
560exceptKeyError:
KeyError: Division(-0x37934c81d85ca00d, /, children=["Negative electrode cracking rate * (Negative electrode Young's modulus [Pa] ** Negative electrode Paris' law constant m) * (Negative electrode initial crack length [m] ** ((Negative electrode Paris' law constant m / 2.0) - 1.0)) * ((((Negative electrode partial molar volume [m3.mol-1] * Negative electrode Young's modulus [Pa] / 3.0 / (1.0 - Negative electrode Poisson's ratio)) * (broadcast(r-average(X-averaged negative particle concentration)) - broadcast(boundary value(X-averaged negative particle concentration))) * Maximum concentration in negative electrode [mol.m-3] / Negative electrode Young's modulus [Pa]) * Negative electrode Paris' law constant b * sqrt(broadcast(3.141592653589793 * X-averaged negative particle crack length)) * (0.0 <= (Negative electrode partial molar volume [m3.mol-1] * Negative electrode Young's modulus [Pa] / 3.0 / (1.0 - Negative electrode Poisson's ratio)) * (broadcast(r-average(X-averaged negative particle concentration)) - broadcast(boundary value(X-averaged negative particle concentration))) * Maximum concentration in negative electrode [mol.m-3] / Negative electrode Young's modulus [Pa])) ** Negative electrode Paris' law constant m)", '3600.0 / (abs(Typical current [A] / Nominal cell capacity [A.h]) * 96485.33212 * Maximum concentration in negative electrode [mol.m-3] * (Negative electrode thickness [m] + Separator thickness [m] + Positive electrode thickness [m]) / absolute(Typical current [A] / (Number of electrodes connected in parallel to make a cell * Electrode width [m] * Electrode height [m])))'], domains={'primary': ['negative electrode'], 'secondary': ['current collector']})
Duringhandlingoftheaboveexception, anotherexceptionoccurred:
KeyErrorTraceback (mostrecentcalllast)
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:559, inParameterValues.process_symbol(self, symbol)
558try:
-->559returnself._processed_symbols[symbol]
560exceptKeyError:
KeyError: Multiplication(0xe005a9b6c739eb7, *, children=["Negative electrode cracking rate * (Negative electrode Young's modulus [Pa] ** Negative electrode Paris' law constant m) * (Negative electrode initial crack length [m] ** ((Negative electrode Paris' law constant m / 2.0) - 1.0))", "(((Negative electrode partial molar volume [m3.mol-1] * Negative electrode Young's modulus [Pa] / 3.0 / (1.0 - Negative electrode Poisson's ratio)) * (broadcast(r-average(X-averaged negative particle concentration)) - broadcast(boundary value(X-averaged negative particle concentration))) * Maximum concentration in negative electrode [mol.m-3] / Negative electrode Young's modulus [Pa]) * Negative electrode Paris' law constant b * sqrt(broadcast(3.141592653589793 * X-averaged negative particle crack length)) * (0.0 <= (Negative electrode partial molar volume [m3.mol-1] * Negative electrode Young's modulus [Pa] / 3.0 / (1.0 - Negative electrode Poisson's ratio)) * (broadcast(r-average(X-averaged negative particle concentration)) - broadcast(boundary value(X-averaged negative particle concentration))) * Maximum concentration in negative electrode [mol.m-3] / Negative electrode Young's modulus [Pa])) ** Negative electrode Paris' law constant m"], domains={'primary': ['negative electrode'], 'secondary': ['current collector']})
Duringhandlingoftheaboveexception, anotherexceptionoccurred:
KeyErrorTraceback (mostrecentcalllast)
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:559, inParameterValues.process_symbol(self, symbol)
558try:
-->559returnself._processed_symbols[symbol]
560exceptKeyError:
KeyError: Multiplication(0x1008323fdf220993, *, children=['Negative electrode cracking rate', "(Negative electrode Young's modulus [Pa] ** Negative electrode Paris' law constant m) * (Negative electrode initial crack length [m] ** ((Negative electrode Paris' law constant m / 2.0) - 1.0))"], domains={'primary': ['negative electrode'], 'secondary': ['current collector']})
Duringhandlingoftheaboveexception, anotherexceptionoccurred:
KeyErrorTraceback (mostrecentcalllast)
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:559, inParameterValues.process_symbol(self, symbol)
558try:
-->559returnself._processed_symbols[symbol]
560exceptKeyError:
KeyError: FunctionParameter(0x311aab223c581fd0, Negativeelectrodecrackingrate, children=['broadcast(broadcast(Volume-averaged cell temperature + Reference temperature [K]))'], domains={'primary': ['negative electrode'], 'secondary': ['current collector']})
Duringhandlingoftheaboveexception, anotherexceptionoccurred:
KeyErrorTraceback (mostrecentcalllast)
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/util.py:59, inFuzzyDict.__getitem__(self, key)
58try:
--->59returnsuper().__getitem__(key)
60exceptKeyError:
KeyError: 'Negative electrode cracking rate'Duringhandlingoftheaboveexception, anotherexceptionoccurred:
KeyErrorTraceback (mostrecentcalllast)
CellIn[12], line1---->1eis_sim=pbeis.EISSimulation(aged_model)
2# calculate impedance at log-spaced frequencies3eis_sim.solve(np.logspace(-2, 4, 30))
File~/pybamm-eis/pbeis/eis_simulation.py:61, inEISSimulation.__init__(self, model, parameter_values, geometry, submesh_types, var_pts, spatial_methods)
52parameter_values["Current function [A]"] =053sim=pybamm.Simulation(
54self.model,
55geometry=geometry,
(...)
59spatial_methods=spatial_methods,
60 )
--->61sim.build()
62self.built_model=sim.built_model64# Extract mass matrix and JacobianFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/simulation.py:436, inSimulation.build(self, check_model, initial_soc)
434self._built_model=self.model435else:
-->436self.set_parameters()
437self._mesh=pybamm.Mesh(self._geometry, self._submesh_types, self._var_pts)
438self._disc=pybamm.Discretisation(self._mesh, self._spatial_methods)
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/simulation.py:374, inSimulation.set_parameters(self)
372self._model_with_set_params=self._unprocessed_model373else:
-->374self._model_with_set_params=self._parameter_values.process_model(
375self._unprocessed_model, inplace=False376 )
377self._parameter_values.process_geometry(self._geometry)
378self.model=self._model_with_set_paramsFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:396, inParameterValues.process_model(self, unprocessed_model, inplace)
392forvariable, equationinunprocessed_model.rhs.items():
393pybamm.logger.verbose(
394"Processing parameters for {!r} (rhs)".format(variable)
395 )
-->396new_rhs[variable] =self.process_symbol(equation)
397model.rhs=new_rhs399new_algebraic= {}
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:561, inParameterValues.process_symbol(self, symbol)
559returnself._processed_symbols[symbol]
560exceptKeyError:
-->561processed_symbol=self._process_symbol(symbol)
562self._processed_symbols[symbol] =processed_symbol564returnprocessed_symbolFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:717, inParameterValues._process_symbol(self, symbol)
715# Unary operators716elifisinstance(symbol, pybamm.UnaryOperator):
-->717new_child=self.process_symbol(symbol.child)
718new_symbol=symbol._unary_new_copy(new_child)
719# ensure domain remains the sameFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:561, inParameterValues.process_symbol(self, symbol)
559returnself._processed_symbols[symbol]
560exceptKeyError:
-->561processed_symbol=self._process_symbol(symbol)
562self._processed_symbols[symbol] =processed_symbol564returnprocessed_symbolFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:708, inParameterValues._process_symbol(self, symbol)
704returnself.process_symbol(function_out)
706elifisinstance(symbol, pybamm.BinaryOperator):
707# process children-->708new_left=self.process_symbol(symbol.left)
709new_right=self.process_symbol(symbol.right)
710# make new symbol, ensure domain remains the sameFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:561, inParameterValues.process_symbol(self, symbol)
559returnself._processed_symbols[symbol]
560exceptKeyError:
-->561processed_symbol=self._process_symbol(symbol)
562self._processed_symbols[symbol] =processed_symbol564returnprocessed_symbolFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:708, inParameterValues._process_symbol(self, symbol)
704returnself.process_symbol(function_out)
706elifisinstance(symbol, pybamm.BinaryOperator):
707# process children-->708new_left=self.process_symbol(symbol.left)
709new_right=self.process_symbol(symbol.right)
710# make new symbol, ensure domain remains the sameFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:561, inParameterValues.process_symbol(self, symbol)
559returnself._processed_symbols[symbol]
560exceptKeyError:
-->561processed_symbol=self._process_symbol(symbol)
562self._processed_symbols[symbol] =processed_symbol564returnprocessed_symbolFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:708, inParameterValues._process_symbol(self, symbol)
704returnself.process_symbol(function_out)
706elifisinstance(symbol, pybamm.BinaryOperator):
707# process children-->708new_left=self.process_symbol(symbol.left)
709new_right=self.process_symbol(symbol.right)
710# make new symbol, ensure domain remains the sameFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:561, inParameterValues.process_symbol(self, symbol)
559returnself._processed_symbols[symbol]
560exceptKeyError:
-->561processed_symbol=self._process_symbol(symbol)
562self._processed_symbols[symbol] =processed_symbol564returnprocessed_symbolFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:596, inParameterValues._process_symbol(self, symbol)
594else:
595new_children.append(self.process_symbol(child))
-->596function_name=self[symbol.name]
598# Create Function or Interpolant or Scalar object599ifisinstance(function_name, tuple):
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/parameters/parameter_values.py:111, inParameterValues.__getitem__(self, key)
110def__getitem__(self, key):
-->111returnself._dict_items[key]
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/util.py:62, inFuzzyDict.__getitem__(self, key)
60exceptKeyError:
61best_matches=self.get_best_matches(key)
--->62raiseKeyError(f"'{key}' not found. Best matches are {best_matches}")
KeyError: "'Negative electrode cracking rate' not found. Best matches are ['Negative electrode porosity', 'Negative electrode electrons in reaction', 'Negative electrode thickness [m]']"
The text was updated successfully, but these errors were encountered:
Hello,
I tried using PyBaMM-EIS with the degradation model enabled, However, it is keeping me with the following errors, whereas when using the typical time domain method it is correctly giving the EIS results.
Is it a issue with PyBaMM-EIS.
Also in your examples to import PybaMM EIS you mentioned using
import pybammeis
but it can only import withimport pbeis
.The text was updated successfully, but these errors were encountered: