I am modeling simple projectile motion using the DifferentialEquations.jl package. I have read in the documentation that you can interpolate based on time to get an answer for an exact time.
Instead of time I have been looking for a way to interpolate based on position. For example I want the vertical position of the projectile at evenly spaced horizontal increments. Is this functionality already in the DifferentialEquations package or do I need to use a package like CurveFit.jl on the horizontal and vertical positions to approximate a solution at evenly spaced horizontal intervals? Thanks.
I think what you want can be achieved easily with one of the interpolation packages, e.g.
Then you do something like:
sol = solve(problem, solver) # solve the ODE
# interpolate at fixed time
tfix = 0.5
smoothfunction_fixed_t = linear_interpolation(xgrid, sol(tfix))
# can now do smoothfunction_fixed_t(x)
# interpolate everything
tgrid = range(0,sol.t[end]; length=100)
smoothfunction = linear_interpolation((xgrid, tgrid), mapreduce(sol, hcat, tgrid))
# can now do smoothfunction(x,t)
Edit:sorry, misunderstood the problem. Ignore me
You can use the solver option
saveat=your_stepsize to do this at solve if you know your stepsize in advance.
Common Solver Options (Solve Keyword Arguments) · DifferentialEquations.jl
I think you can also use the built in interpolations by calling the solution object as
Solution Handling · DifferentialEquations.jl