Add time dependent terms in a differential equation

Hi,

I am a new to Julia and trying to solve Differential Equation with exogenous inputs. The inputs will be read from data at discrete times. Can someone help with the minimal code for the same. I would also like to do the parameter estimation for the same.

How is your exogenous input defined? An array of values? If so, just use DataInterpolations.jl to define the function. With that, did you get a good ODE definition? Would be good to see your steps here.

Hi Chris, thank you for your response. I did try using interpolation before but I could not get it right. I had been reading other posts as well. Could you help me how to use DataInterpolations.jl as well for the code below.

Here is the code that I have put up so far:

here rate(t) is the exogenous input that I am trying to read from a data file.

function rate(t)
if t > feedTime[end]
rate = 0
else
for i in 1:(length(feedTime) - 1)
if feedTime[i] < t < feedTime[i+1]
rate = feedData.Total[i]
end
end
end
return rate
end

function Volume(du, u, p, t)
du = u + rate(t)
end

u0 = [1.0]
tspan = (0.0, 14.0)

prob = ODEProblem(Volume, u0, tspan, rate)

sol = solve(prob, Tsit5(), tstops= feedTime)

display(plot(sol))