DiffEqPhysics.jl
DiffEqPhysics.jl copied to clipboard
Harmonic oscillator mass ignored
While playing with a harmonic oscillator, I encountered the following interesting behaviour.
Somehow DPRKN6 ignores my hard coded mass in the hamiltonian and gives a solution as if the mass was one:
using OrdinaryDiffEq
using DiffEqPhysics
using Plots
function H(p,q, param)
m = 1000 # very heavy object, should oscillate slowly
k = 1.0
1/2*p^2/m + 1/2*k*q^2
end
p0 = 0.0
q0 = 1.0
tspan = (0, 2pi)
prob = HamiltonianProblem(H, p0, q0, tspan)
alg = McAte5() # works
alg = Tsit5() # works
alg = DPRKN6()
sol = solve(prob, alg)
plot(sol, fmt=:png)

I think DPRKNX might require that the system is a second order ODE, so we should throw an error if it's that's not held.