-
-
Notifications
You must be signed in to change notification settings - Fork 671
Solver error right at the beginning of simulation when trying to adapt OKane2022 coupled aging model to Ai2020 dataset #3709
Replies: 1 comment · 5 replies
-
Firstly, what does the error message say? Secondly, can you share a minimal reproducible example without custom libraries or a link to the library if it is open-source? Thirdly please use "```" to start and finish code snippets to make them more readable and copyable. |
Beta Was this translation helpful? Give feedback.
All reactions
-
@TomTranter, apologies for the lack of clarity. Here is the minimum working example with quotes:
Here is the error message with some additional warnings right at the beginning of the sim:
I also used Dr. Brosa Planella's TEC-reduced-model repository to add thermal effects to the model: https://github.com/brosaplanella/TEC-reduced-model.git. Its worth noting though from this repository, I only use the set_thermal_parameters function from the set_parameters.py script. Here is a code snippet of how I used this script:
I didn't touch anything else in this repository. Its also worth noting that the Ai2020 parameter set uses a small format pouch cell (2.3Ah) whereas the Okane2022 parameter set is based on a 5 Ah 21700 cell. Please let me know if I can clarify anything else. |
Beta Was this translation helpful? Give feedback.
All reactions
-
@TomTranter apologies for the several edits, still very new to GitHub but I hope the code is more readable now? |
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for updating the code and providing more info. I'm not going to have time to look into this right now but I would try some different values for the degradation models or a different parameter set Ai2020 isn't always the most stable. Maybe @brosaplanella has some suggestions |
Beta Was this translation helpful? Give feedback.
All reactions
-
@brosaplanella , @DrSOKane , do you have any suggestions? |
Beta Was this translation helpful? Give feedback.
All reactions
-
@TomTranter , @brosaplanella , @DrSOKane , an update: When I change the particle mechanics to swelling only for both anode and cathode along with removing the sei on cracks option, it runs till the discharge step of my rpt experiment and then freezes there for 10+minutes. Is there something wrong with this dataset or my approach? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello pybamm-team/community -
I am trying to run an aging experiment on the Ai2022 parameter using the OKane2022 coupled aging model. I get a solver error right at the beginning of the experiment with the maximum number of decreased steps occurring. Can anyone tell me why this happening and how I can fix it? I believe I added all the missing variables/functions but here is a working example of my code:
import pybamm
import matplotlib.pyplot as plt
import numpy as np
from os import path
import pandas as pd
from tec_reduced_model.set_parameters import (
set_thermal_parameters,
set_experiment_parameters,
set_ambient_temperature,
)
from tec_reduced_model.process_experimental_data import import_thermal_data, get_idxs
from pybamm import Parameter, constants, exp
temperature = 25
Crate = 1
cells_ignore = ["791"]
#Define the DFN Model
model = pybamm.lithium_ion.DFN(options = {
"thermal":"lumped",
"dimensionality":0,
"cell geometry": "arbitrary",
"SEI": "solvent-diffusion limited",
"SEI porosity change": "true",
"particle mechanics": ("swelling and cracking", "swelling only"),
"SEI on cracks": "true",
"loss of active material": "stress-driven",
"calculate discharge energy": "true",
"lithium plating": "partially reversible",
"lithium plating porosity change": "true"
},
name="TDFN",
)
#Parameter assignment and definition
param = pybamm.ParameterValues("Ai2020")
param = set_thermal_parameters(param, 16, 2.32e6, temperature)
T = model.variables["Volume-averaged cell temperature [K]"]
c_e = model.variables["Electrolyte concentration [mol.m-3]"]
c_Li = model.variables["Lithium plating concentration [mol.m-3]"]
L_sei = model.variables["Total SEI thickness [m]"]
param["Ambient temperature [K]"] = 298.15
param["Initial temperature [K]"] = 298.15
param["Initial inner SEI thickness [m]"] = 0
param.update({"Typical plated lithium concentration [mol.m-3]": 1000}, check_already_exists=False)
param.update({"Lithium metal partial molar volume [m3.mol-1]": 1.3e-05}, check_already_exists=False)
param.update({"Lithium plating kinetic rate constant [m.s-1]": 1e-09}, check_already_exists=False)
param.update({"Initial plated lithium concentration [mol.m-3]": 0.0}, check_already_exists=False)
param.update({"Lithium plating transfer coefficient": 0.65}, check_already_exists=False)
param.update({"Dead lithium decay constant [s-1]": 1e-06}, check_already_exists=False)
def anode_cracking_rate_Ai2020(T):
k_cr = 3.9e-20
T_ref = pybamm.Parameter("Reference temperature [K]")
Eac_cr = 81044.08
arrhenius = exp(Eac_cr / constants.R * (1 / T - 1 / T_ref))
return k_cr * arrhenius
def cathode_cracking_rate_Ai2020(T_dim):
k_cr = 3.9e-20
T_ref = pybamm.Parameter("Reference temperature [K]")
Eac_cr = 81044.08
arrhenius = exp(Eac_cr / constants.R * (1 / T_dim - 1 / T_ref))
return k_cr * arrhenius
def solvent_diffusivity_sei(T):
Ea = 37000
arrhenius = exp(Ea / constants.R * (1 / 298.15 - 1 / T))
return 2.50000000000000002e-22 * arrhenius
def plating_exchange_current_density_OKane2020(c_e, c_Li, T):
k_plating = param["Lithium plating kinetic rate constant [m.s-1]"]
return pybamm.constants.F * k_plating * c_e
def stripping_exchange_current_density_OKane2020(c_e, c_Li, T):
k_plating = param["Lithium plating kinetic rate constant [m.s-1]"]
return pybamm.constants.F * k_plating * c_e
def SEI_limited_dead_lithium_OKane2022(L_sei):
gamma_0=param["Dead lithium decay constant [s-1]"]
L_inner_0 = pybamm.Parameter("Initial inner SEI thickness [m]")
L_outer_0 = pybamm.Parameter("Initial outer SEI thickness [m]")
L_sei_0 = L_inner_0 + L_outer_0
param.update({"Outer SEI solvent diffusivity [m2.s-1]": solvent_diffusivity_sei(T)})
param.update({"Negative electrode cracking rate":anode_cracking_rate_Ai2020(T)})
param.update({"Positive electrode cracking rate":cathode_cracking_rate_Ai2020})
param.update({"Exchange-current density for stripping [A.m-2]": stripping_exchange_current_density_OKane2020}, check_already_exists=False)
param.update({"Exchange-current density for plating [A.m-2]": plating_exchange_current_density_OKane2020}, check_already_exists=False)
param.update({"Dead lithium decay rate [s-1]": SEI_limited_dead_lithium_OKane2022}, check_already_exists=False)
#Define experiment
pybamm.set_logging_level("NOTICE")
cycle_number = 1
#Simple cycling experiment
N=50
cccv_experiment = pybamm.Experiment([
("Charge at 1C until 4.2V",
"Discharge at 1C until 3.0V",
)
]*N
)
rpt_experiment = pybamm.Experiment([(
"Rest for 30 minutes",
"Charge at 0.1C until 4.2V",
"Hold at 4.2V until C/20",
"Rest for 30 minutes",
"Discharge at 0.1C until 3.0V",
"Hold at 3.0V until C/20",
"Rest for 30 minutes",
)])
#Refine mesh
var_pts = {
"x_n" : 30, # x-direction, length, negative electrode
"x_s" : 30, # x-direction, length, separator
"x_p" : 30, # x-direction, length, positive electrode
"r_n" : 30, # number of volumes in the radial direction, negative particle
"r_p" : 30 # number of volumes in the radial direction, positive particle
}
#Run model
solver = pybamm.CasadiSolver(mode="safe", atol=1e-6, rtol=1e-3)
cccv_sols = []
rpt_sols = []
cccv_sol = None
rpt_sol = None
M = 5
for i in range(M):
sim = pybamm.Simulation(model, experiment=rpt_experiment,parameter_values=param, var_pts=var_pts, solver=solver)
rpt_sol = sim.solve(starting_solution=cccv_sol)
sim = pybamm.Simulation(model, experiment=cccv_experiment,parameter_values=param, var_pts=var_pts, solver=solver)
cccv_sol = sim.solve(starting_solution=rpt_sol, save_at_cycles= 10)
cccv_sols.append(cccv_sol)
rpt_sols.append(rpt_sol)
Any help would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions