Hello, please help me understand what it is sol.interp
, sol.k
and is there any way not to save them? I found that they take up quite a lot of RAM, which is why ubuntu 24.04 freezes.
Thank you for your helps!
Code:
using StaticArrays, DifferentialEquations
function FHN2_try3(u, p ,t)
x1, y1, x2, y2, z= u
ϵ, a, g, k, σ, α, k1, k2 = p
I(ϕ_i) = g * (1.0/(1.0 + exp(k*(cos(σ/2) - cos(ϕ_i - α - σ/2)))))
ρz = k1 + k2 * z ^ 2
ϕ2 = atan(y2, x2)
ϕ1 = atan(y1, x1)
dx1dt = (x1 - x1 ^ 3 / 3 - y1 + I(ϕ2) + ρz * (x2 - x1) ) / ϵ
dy1dt = x1 - a
dx2dt = (x2 - x2 ^ 3 / 3 - y2 + I(ϕ1) + ρz * (x1 - x2) ) / ϵ
dy2dt = x2 - a
dzdt = x1 - x2
return SVector(dx1dt, dy1dt, dx2dt, dy2dt, dzdt)
end
function FHN2_try3_params()
ϵ = 0.01; a = -1.01;
g = 0.1; k = 50.0; σ = 50.0 * pi / 180; α = 160.0 * pi / 180;
k1 = 0.0; k2 = 0.0
return [ ϵ, a, g, k, σ, α, k1, k2]
end
function jac_FHN(u, p, t)
x1, y1, x2, y2, z = u
ϵ, a, g, k, σ, α, k1, k2 = p
pz = k1 + k2 * z^2
exp_ϕ2 = exp( k * ( cos(σ/2) - cos( α + σ/2 - atan(y2, x2) ) ) )
sin_ϕ2 = sin( α + σ/2 - atan(y2, x2) )
exp_ϕ1 = exp( k * ( cos(σ/2) - cos( α + σ/2 - atan(y1, x1) ) ) )
sin_ϕ1 = sin( α + σ/2 - atan(y1, x1) )
x1x1 = (1.0 - x1^2 - pz) / ϵ
x1y1 = -1.0/ϵ
x1x2 = (-g * k * y2 * exp_ϕ2 * sin_ϕ2) / ( x2^2 * (1 + y2^2 / x2^2 ) * ( exp_ϕ2 + 1.0 )^2 ) + k1 + k2 * z^2
x1x2 = x1x2 / ϵ
x1y2 = ( g * k * x2 * exp_ϕ2 * sin_ϕ2 ) / ( (x2^2 + y2^2) * ( 1.0 + exp_ϕ2 )^2 )
x1y2 = x1y2 / ϵ
x1z = 2.0 * k2 * z * ( -x1 + x2 ) / ϵ
#-----------------------------------------------
y1x1 = 1.0;
y1y1 = 0.0; y1x2 = 0.0; y1y2 = 0.0; y1z = 0.0;
#----------------------------------------------
x2x2 = (1.0 - x2^2 - pz) / ϵ
x2y2 = -1.0/ϵ
x2x1 = (-g * k * y1 * exp_ϕ1 * sin_ϕ1) / ( x1^2 * (1 + y1^2 / x1^2 ) * ( exp_ϕ1 + 1.0 )^2 ) + k1 + k2 * z^2
x2x1 = x2x1 / ϵ
x2y1 = ( g * k * x1 * exp_ϕ1 * sin_ϕ1 ) / ( (x1^2 + y1^2) * ( 1.0 + exp_ϕ1 )^2 )
x2y1 = x2y1 / ϵ
x2z = 2.0 * k2 * z * ( -x2 + x1 ) / ϵ
#----------------------------------------------
y2x2 = 1.0;
y2y2 = 0.0; y2x1 = 0.0; y2y1 = 0.0; y2z = 0.0;
#----------------------------------------------
zx1 = 1.0; zy1 = 0.0; zx2 = -1.0; zy2 = 0.0; zz = 0.0;
return SMatrix{5,5}(x1x1, y1x1, x2x1, y2x1, zx1,
x1y1, y1y1, x2y1, y2y1, zy1,
x1x2, y1x2, x2x2, y2x2, zx2,
x1y2, y1y2, x2y2, y2y2, zy2,
x1z, y1z, x2z, y2z, zz)
end
parameters = FHN2_try3_params()
tspan = (0.0, 10000.0)
parameters[7] = 0.09
parameters[8] = 75.74
u0 = [-0.9859005363852416, -0.635253572091177, -1.0345181027025165, -0.636382088705782, 0.0011285166148596525]
u0 = SVector{5}(u0)
prob = ODEProblem(FHN2_try3, u0, tspan, parameters)
alg = Vern9();
sol = solve(prob, alg, adaptive = false, dt = 0.001, maxiters = 1e7) #true, abstol = abs_tolerance, reltol = rel_tolerance, maxiters = max_iters);
sol_alg = sol.alg
sol_alg_choice = sol.alg_choice
sol_dense = sol.dense
sol_errors = sol.errors
sol_interp = sol.interp
sol_k = sol.k
sol_prob = sol.prob
sol_retcode = sol.retcode
sol_stats = sol.stats
sol_t = sol.t
sol_tslocation = sol.tslocation
sol_u = sol.u
sol_u_analytic = sol.u_analytic
varinfo()