I would like to solve a system of stiff ODE equations from Matlab with other methods from the scipy library such as LSODA or Sundials rather than Rosenbrock (ode23s).
A matlab ODE complex function defined as;
function [dpdt]=damper_rebo(t,P,amp,freq,pars)
with amp, frequency constants and pars a cell of parameters with constants parameters.
It works fine with;
[tsol,ysol]=ode23s(@(t,P) damper_rebo(t,P,amp,freq,pars),[0 0.5/freq],P_0,options);
I am trying to compare with other methods to solve ODE with stiff equations like LSODA and BDF.
I loaded the python environment and installed all the path requirements, then I tried this:
py.importlib.import_module("scipy")
pyrun("from scipy.integrate import LSODA")
P_0=[0.01,0.001,1e5,2e5,Pg_0];
Tspan = py.list([0.0, 0.5/freq]);
pyfun = py.str('lambda t,P: damper_rebo(t,P,amp,freq,pars)');
pyfun = py.function_handle(@(t,P) damper_rebo(t,P,amp,freq,pars));
sol=py.scipy.integrate.solve_ivp(pyfun,Tspan, py.numpy.array(P_0),pyargs(method="BDF", rtol=0.00001, atol=1e-06));
The first `pyfun`option brings an error that `
Python Error: TypeError: 'str' object is not callable`
The second option brings an error too with
`Unable to resolve the name 'py.function_handle'.`
1. How can I pass the Matlab ODE function to a callable python function?
2. How can I pass the extra arguments in a python manner?