There was an unexpected behavior I noticed when using ode solver and itp that I would appreciate your help.
I am sharing a problem where u[1] can be a assign to a value like 3000 , where the final solution was the value expected, however, when u[1] is assigned to the value the interpolant object predicts, the final solution is not what is expected. For a moment I thought that the interpolant is being ignored, but when printing the values , it does seem to be evaluating it , but the final solution does not reflect those values that u[1] was, is there something I am missing, I am using julia 1.4 v also. Any recommendation / or explanation of what is happening will be appreciated.
scenario one : u[1]= constant, scenario two: u[1]= itp(t) ( the latter is the unexpected behavior I mentioned above)
Again thank you very much.
Christian
using DifferentialEquations
using Sundials
using Interpolations
t= collect(0.0:1.0:6.0)
y= [525.42,577.87,560,536,526,427,390];
#This Interpolates
knots = (t,)
itp = interpolate(knots, y, Gridded(Linear()))
function ode_functionminie(du,u, p,t)
du[1] = 0
value= itp(t)
#u[1]=value;
u[1]=3000;
if t >1.0 && t <=3
println("value vs u", (value, u[1]))
end
end
p=[]
uo_e=[30]
tol= 1e-6
t_start= 0.0;
sim_time_e= 6.0;
prob = ODEProblem(ode_functionminie,uo_e,(t_start,sim_time_e), p)
sol = solve(prob, abstol=tol, reltol=tol,CVODE_BDF(), dtmax=0.1, tstops=[1.0,4.0]);
times= 0.0:1.0:6.0;
time_output, output= collect(times), sol(times).u
final_output= Array(sol(times)')
println("Done")