I'm attempting to solve the two body differential equation. DifferentialEquations.jl used to solve my equation with no trouble, but at some point, it started handing in nothing
for the initial condition to differential equation.
Is this potentially a problem with the scoping stuff that's been coming up a lot recently?
using Unitful, RecursiveArrayTools, DifferentialEquations
function propagateTrajNewWay(df::DataFrame, idx::Int)
x = df.E[idx]u"m"
y = df.F[idx]u"m"
z = df.G[idx]u"m"
r0 = [x, y, z]
vx = df.dE[idx]u"m/s"
vy = df.dF[idx]u"m/s"
vz = df.dG[idx]u"m/s"
v0 = [vx, vy, vz]
rv0 = ArrayPartition(r0, v0)
tspan = (df.time[idx]u"s", df.time[end]u"s")
μ = 3.986004418e14u"m^3/s^2"
# prob = ODEProblem(twoBody, u0, tspan)
# println(prob)
# sol = solve(prob, VCABM(), reltol = 1e-12, abstol = 1e-12)
prob = ODEProblem((t, y, dy) -> twoBodyNew(t, y, dy, μ), rv0, tspan)
sol = solve(prob, VCABM())
return sol
end
function twoBodyNew(t, y, dy, μ)
show(y)
r = norm(y.x[1])
dy.x[1] .= y.x[2]
dy.x[2] .= -μ .* y.x[1] / r^3
end
function propWholeTraj(df)
for ii = 1:size(df, 1)
propagateTrajNewWay(df, ii)
end
end
propWholeTraj(df)
The code that's in here is basically copied verbatim from this page on using static arrays. I also have my own version of the two body function and the function that sets up and calls it, but this also has the same error.
Any thoughts on what could be going wrong here?
The function signature should be twoBodyNew(t, y, μ, dy)
. It's always ((du),u,p,t)
. The docs on that linked page have been fixed.