SciML / DiffEqPhysics.jl

A library for building differential equations arising from physical problems for physics-informed and scientific machine learning (SciML)
Other
50 stars 19 forks source link

Harmonic oscillator mass ignored #64

Open jw3126 opened 3 years ago

jw3126 commented 3 years ago

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)

image

ChrisRackauckas commented 3 years ago

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.