Problems with current function and initial_soc using Ai2020 parameter set. #2263
-
Hello, I am currently trying to simulate charging a battery using a constant current of -2.28 A (1C). However, when I set the current function to any -ve value, the solver crashes giving the error "psetup failed: .../casadi/interfaces/sundials/idas_interface.cpp:852: Linear solve failed Any ideas on how fix such a problem? The code can be found below. import pybamm dfn = pybamm.lithium_ion.DFN() sim = pybamm.Simulation(dfn, parameter_values=params) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It seems to be a problem with the solver using to find the initial conditions. A workaround for now is to discharge and then set the initial conditions based on that solution, e.g. something like import pybamm
model = pybamm.lithium_ion.DFN()
params = pybamm.ParameterValues("Ai2020")
discharge_exp = pybamm.Experiment(["Discharge at C/10 until 3V"])
discharge_sim = pybamm.Simulation(model, parameter_values=params, experiment=discharge_exp)
discharge_sol = discharge_sim.solve(calc_esoh=False)
# MODEL RE-INITIALIZATION: #############################################################
# Now initialize the model with the solution of the discharge, and then charge
# We could also do this inplace by setting inplace to True, which modifies the original
# model in place
new_model = model.set_initial_conditions_from(discharge_sol, inplace=False)
########################################################################################
charge_exp = pybamm.Experiment(["Charge at 1C until 4.2V"])
charge_sim = pybamm.Simulation(new_model, parameter_values=params, experiment=charge_exp)
charge_sol = charge_sim.solve(calc_esoh=False)
charge_sol.plot() |
Beta Was this translation helpful? Give feedback.
It seems to be a problem with the solver using to find the initial conditions. A workaround for now is to discharge and then set the initial conditions based on that solution, e.g. something like