I am trying to solve an equation in Julia but I get Unstable retcode, I have solved the same eqaution in MATLAB with no issues. here is a simplified version of the code:
using DifferentialEquations
struct RosslerMSF
alpha::Float64
beta::Float64
gamma::Float64
steadystate::Matrix{Float64}
dT::Float64
end
Jac(f, alpha, gamma) = [0 -1 -1; 1 alpha 0; f[3] 0 f[1]-gamma]
function (p::RosslerMSF)(du,u,par,t)
ind = floor(Int,t/p.dT)+1
x, y, z = p.steadystate[1,ind], p.steadystate[2,ind], p.steadystate[3,ind]
J = Jac([x, y, z], p.alpha, p.gamma)
du[1:3] = J*[u[1], u[2], u[3]]
du[4:12] = J*[u[4] u[7] u[10];u[5] u[8] u[11];u[6] u[9] u[12]]
end
function Rossler(du,u,p,t)
x, y, z = u[1], u[2], u[3]
du[1] = -y-z
du[2] = x + 0.2*y
du[3] = 0.2 + (x - 9)*z
end
init = [0.1 -0.5 2]
sol = solve(ODEProblem(Rossler,init,(0,2200)),Tsit5(),dt=0.001,saveat = 200:0.001:2200)
funx = RosslerMSF(0.2,0.2,9,[sol[:,1,:]; sol[:,2,:]; sol[:,3,:]],0.001)
initx = [init..., 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
solx = solve(ODEProblem(funx, initx, (0, 2000)), Tsit5(), dt=0.001)