# ModelingToolkit second derivative only gives first derivative

Hello,

I’m running into an issue that has left me confused. Using ModelingToolkit v6.7.1, I (for example) want to simulate a falling object. So:

``````@variables t [unit = u"s"] x(t) [unit = u"m"] v(t) [unit = u"m/s"]
@parameters g=-9.8 [unit = u"m/s^2"]
Dt = Differential(t)
Dt2 = Differential(t)^2
``````

I would think that I could just set the second derivative of `x` equal to `g`:

``````@named eqs = ODESystem([
Dt2(x) ~ g,
])
prob = ODEProblem(structural_simplify(eqs), [x => 0.0], (0.0,10.0))
sol = solve(prob, saveat=1)
``````

Then when I plot `x` vs `t`, I would expect to get a parabola, but instead I get a straight line: If I only use first derivatives, however, and introduce another variable `v`, it does work:

``````@named eqs = ODESystem([
Dt(v) ~ g,
Dt(x) ~ v,
])
prob = ODEProblem(structural_simplify(eqs), [x => 0.0, v => 0.0], (0.0,10.0))
sol = solve(prob, saveat=1)
`````` Is this the expected behavior? If so, why doesn’t my first attempt work, or what is the proper way to define a second derivative? Thanks!

Does `ode_order_lowering` fix it? Anyways, this should be an issue in the MTK repo, not a Discourse post.

Thanks, that works! I also opened an issue here regarding the possibility of this type of user error being caught and thrown rather than passing silently.

1 Like