lrnv
1
Hey,
I admit that I am a novice in differential equations solving, this problem came out of completely somthing else…
I want to solve an equation that has the following form :
S(t) = \exp(- H(t))
\partial H(t) = F(t, S(t), parameters...)
The function F(t) is highly non-linear, but :
- it has jumps at previously known time values t_1,...t_n
- between these times values it is continuous (but still non-linear).
I can provide starting values S(0) = 1.
Is this kind of stuff solvable ?
using DifferentialEquations
function odefunc!(du,u,p,t)
S = u[1]
H = u[2]
dS = exp(-H)
dH = p * (S - t^2 + S^3) #arbitrary nonlinear function, p is switched at predefined times in callback
du[1] = dS
du[2] = dH
nothing
end
affect!(integrator) = (integrator.p > 0) ? integrator.p = -1 : integrator.p = 1
cb = PresetTimeCallback([2,5],affect!)
S0 = 1
H0 = 2
u0 = [S0,H0]
p = 1.0
prob = ODEProblem(odefunc!,u0,(0,10),p)
sol = solve(prob, callback = cb)
julia> sol.u
26-element Vector{Vector{Float64}}:
[1.0, 2.0]
[1.0130247068630718, 2.2164863270563178]
[1.0360292186508027, 2.779573896877542]
⋮
[4.875245836243441, 65.69652980394312]
[4.875245836243441, 187.0985129901355]
1 Like
That’s the jumps part. The other part, using previous values, is just a DDE.
1 Like