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 used the following code to run the degradation submodels suggested by @DrSOKane, However, when I tried to obtain the plotting as per the example code I got an empty plot. Also, I cannot see the following as model variables.
Loss of capacity to negative SEI [A.h].entries
Q_SEI_cr = sol["Loss of capacity to negative SEI on cracks [A.h]
Q_plating = sol["Loss of capacity to negative lithium plating [A.h]"]
If @DrSOKane or someone can guide me about the mistake I'm making here it will be really appreciated.
Thank you.
importmatplotlib.pyplotaspltimportnumpyasnpfromscipy.fftimportfftimportpybammimporttimeastimer# Set random seednp.random.seed(0)
# Original function for degradation parameterspp=pybamm.ParameterValues("OKane2022")
# Function to get Chen2020 parametersdefget_chen2020_parameters():
parameter_values=pybamm.ParameterValues("Chen2020")
returnparameter_values# Function to get OKane2022 degradation parameters with k_cr includeddefget_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"], # Function'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"], # Function'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]"],
"k_cr": pybamm.Parameter("k_cr"), # Define as a parameter object
}
returndegradation_parameters# Graphite cracking rate functiondefgraphite_cracking_rate_Ai2020(T_dim):
""" Calculates the graphite cracking rate using an Arrhenius-like relationship. T_dim: Dimensional temperature (in Kelvin) """Eac_cr=0# Activation energy for cracking [J/mol], update if neededarrhenius=pybamm.exp(Eac_cr/pybamm.constants.R* (1/T_dim-1/298.15))
returnpybamm.Parameter("k_cr") *arrhenius# Function to update 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)
# Add graphite cracking rate functionchen2020_params["k_cr"] =50*3.9e-20returnchen2020_params# Update the parametersupdated_parameters=update_parameters()
# Define the model with configurationmodel=pybamm.lithium_ion.DFN(
{
#"thermal": "lumped", # Lumped thermal submodel"surface form": "differential", # Adding capacitance to the model"SEI": "solvent-diffusion limited",
"SEI porosity change": "true",
"particle mechanics": ("swelling and cracking", "swelling only"),
"SEI on cracks": "true",
}
)
# Variable pointsvar_pts= {
"x_n": 5,
"x_s": 5,
"x_p": 5,
"r_n": 30,
"r_p": 30,
}
# Simulation parameterscycle_numbers= [10]
# 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()
Qt=sol["Throughput capacity [A.h]"].entriesQ_SEI=sol["Loss of capacity to SEI [A.h]"].entriesQ_SEI_cr=sol["Loss of capacity to SEI on cracks [A.h]"].entriesQ_side=sol["Total capacity lost to side reactions [A.h]"].entriesQ_LLI= (
sol["Total lithium lost [mol]"].entries*96485.3/3600
) # convert from mol to A.hplt.figure()
plt.plot(Qt, Q_SEI, label="SEI", linestyle="dashed")
plt.plot(Qt, Q_SEI_cr, label="SEI on cracks", linestyle="dashdot")
plt.plot(Qt, Q_side, label="All side reactions", linestyle=(0, (6, 1)))
plt.xlabel("Throughput capacity [A.h]")
plt.ylabel("Capacity loss [A.h]")
plt.legend()
plt.show()
Also, I have tried to run the example code available here exactly as it is, however it gives me following error message.
---------------------------------------------------------------------------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: 'Loss of capacity to negative SEI [A.h]'Duringhandlingoftheaboveexception, anotherexceptionoccurred:
KeyErrorTraceback (mostrecentcalllast)
CellIn[2], line21Qt=sol["Throughput capacity [A.h]"].entries---->2Q_SEI=sol["Loss of capacity to negative SEI [A.h]"].entries3Q_SEI_cr=sol["Loss of capacity to negative SEI on cracks [A.h]"].entries4Q_plating=sol["Loss of capacity to negative lithium plating [A.h]"].entriesFile~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/solvers/solution.py:537, inSolution.__getitem__(self, key)
534returnself._variables[key]
535else:
536# otherwise create it, save it and then return it-->537self.update(key)
538returnself._variables[key]
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/solvers/solution.py:476, inSolution.update(self, variables)
474cumtrapz_ic=None475pybamm.logger.debug("Post-processing {}".format(key))
-->476vars_pybamm= [model.variables_and_events[key] formodelinself.all_models]
478# Iterate through all models, some may be in the list several times and479# therefore only get set up once480vars_casadi= []
File~/pybamm-eis/env/lib/python3.9/site-packages/pybamm/solvers/solution.py:476, in<listcomp>(.0)
474cumtrapz_ic=None475pybamm.logger.debug("Post-processing {}".format(key))
-->476vars_pybamm= [model.variables_and_events[key] formodelinself.all_models]
478# Iterate through all models, some may be in the list several times and479# therefore only get set up once480vars_casadi= []
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: "'Loss of capacity to negative SEI [A.h]' not found. Best matches are ['Loss of capacity to SEI [A.h]', 'Loss of capacity to SEI on cracks [A.h]', 'Loss of capacity to lithium plating [A.h]']"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello Everyone,
I used the following code to run the degradation submodels suggested by @DrSOKane, However, when I tried to obtain the plotting as per the example code I got an empty plot. Also, I cannot see the following as model variables.
If @DrSOKane or someone can guide me about the mistake I'm making here it will be really appreciated.
Thank you.
Also, I have tried to run the example code available here exactly as it is, however it gives me following error message.
Beta Was this translation helpful? Give feedback.
All reactions