Julia language - How to increase the time span in an ODE problem without losing optimization?

265 views Asked by At

I have a large system of about 1000 differential equations, such as

function HR(du,u,p,t)
        du[1,:] .= u[2,:] .- a*u[1,:].^3 .+ b.*u[1,:].^2 .+ I .-u[3,:] .+(ϵ/N)*sum(u[1,:])
        du[2,:] .= c .- d.*u[1,:].^2 .- u[2,:]
        du[3,:] .= r.*(s.*(u[1,:] .+ k) .- u[3,:])
end

for which I provide a matrix of initial conditions u0 (3 rows by 1000 columns). The letters a,b,c,d,I... are global variables. Solving the ODEs works fine as long as the time span (tspan) does not exceed 1000.0.

tspan=1000.0
prob = ODEProblem(HR, u0, tspan)
sol = solve(prob, Tsit5(),
            alias_u0=true,
            save_idxs=idxs,
            save_at=0.1,
            reltol=1e-5, abstol=1e-5,
            progress = true,
            maxiters = 1e7
            )

Solving this takes less than one minute but when I increase tspan my computer crashes. Why does it happen? How could I increase tspan without increasing runtime too much or crashing my computer?

I've thought about doing it for time windows: solve the ODEs to tspan=1000.0 once, get the final conditions, use them as initial conditions and solve the ODEs again, in a loop. In the end I just amend each solution. But I'm not sure if this is the best way to get around this problem because it still crashes my computer.

Any tips or explanation as to why this happens?

0

There are 0 answers