Interesting… the fix is:
using ModelingToolkit, OrdinaryDiffEq
p₀, q₀ = 0.0, 3.0
@variables t
@variables P(t) Q(t)
∂t = Differential(t)
eqs = [∂t(Q) ~ 0.2P
∂t(P) ~ -80.0sin(Q)]
@named sys = ODESystem(eqs)
u₀ = [P=>p₀, Q=>q₀]
t_span = (0.0, 20.0)
prob = ODEProblem(sys, u₀, t_span)
sol = solve(prob, Tsit5())
The only change was to make @variables P(t) Q(t) instead of parameters. It seems that by making them parameters, the automatic system detection put them as both variables and parameters, printing out:
julia> @named sys = ODESystem(eqs)
Model sys with 2 equations
States (2):
Q(t)
P(t)
Parameters (2):
Q(t)
P(t)
So it would be great if you could open an issue on ModelingToolkit.jl. We should add a sanity check that the intersection between states and parameters should be null. Somehow this one slipped by. Thanks for pointing this out!