Open tomjholland opened 2 days ago
@tomjholland just double-checking – are you on PyBaMM v24.9 or develop? As a temporary workaround, you can change the OCP interpolant to "linear"
.
cc @kratman
This is the same bug as the one with the CasADi plugin system: #3783. A hacky workaround is in #4487 at the time of writing
For Linux and Mac this fix from #4487 can resolve this issue. The change is needed inside pybamm's main __init__.py
:
# Fix Casadi import
import os
import sysconfig
if sys.platform == "win32":
os.environ["CASADIPATH"] = os.path.join(sysconfig.get_path('purelib'), 'casadi').replace("\\", "\\\\")
else:
os.environ["CASADIPATH"] = os.path.join(sysconfig.get_path('purelib'), 'casadi')
This does not work on Windows yet, I am working on improving the Windows build to make it work there as well.
@tomjholland For tracking issues:
I can reproduce this on MacOS with PyBaMM 24.9 on MacOS
@tomjholland This works on my Mac as a workaround:
import pybamm
# Fix Casadi import
import os
import sysconfig
os.environ["CASADIPATH"] = os.path.join(sysconfig.get_path('purelib'), 'casadi')
exp = pybamm.Experiment([ "Discharge at 1C until 2.5 V"])
model = pybamm.lithium_ion.DFN()
params = pybamm.ParameterValues("OKane2022")
solver = pybamm.IDAKLUSolver()
sim = pybamm.Simulation(model, experiment=exp, parameter_values=params, solver=solver)
sim.solve()
Hi @kratman, thanks for the quick response on this.
Sorry, I forgot to add this detail to the issue. I get this error from 24.9 installed from pip on MacOS and Linux. I can confirm that your workaround also works for me on my Mac.
Thanks for the help!
Partial fix was added to develop, it will be in the next release (hopefully in the next week or two)
PyBaMM Version
24.9
Python Version
3.11
Describe the bug
Casadi error is returned when using the IDAKLU solver with the
OKane2022
parameter set. Appears to be related to the interpolation of the negative electrode OCP, as it is searching forlibcasadi_interpolatnt_bspline.dylib
and setting the OCP to the functional form inChen2020
eliminates the error.This is a separate issue, but I will tag #4365 as another issue caused by the interpolation of discrete points of NE OCP in this parameter set.
Steps to Reproduce
Produces the Runtime error:
This can be overcome by changing the OCP function of the parameter set:
Relevant log output
No response