I updated the branch broken
of the repo Tethers.jl
to use MTK 9.40.1, and I can run the example now. But I get a warning that I did NOT get with the older MTK version:
julia> include("src/Tether_01.jl")
┌ Warning: Initialization system is overdetermined. 1 equations for 0 unknowns. Initialization will default to using least squares. To suppress this warning pass warn_initialize_determined = false. To make this warning into an error, pass fully_determined = true
└ @ ModelingToolkit ~/.julia/packages/ModelingToolkit/AS70O/src/systems/diffeqs/abstractodesystem.jl:1465
3.125912 seconds (4.50 M allocations: 295.207 MiB, 2.24% gc time, 99.99% compilation time)
OK
Any idea why?
My code:
# Example one: Falling mass.
using ModelingToolkit, OrdinaryDiffEq, ControlPlots
using ModelingToolkit: t_nounits as t, D_nounits as D
G_EARTH::Vector{Float64} = [0.0, 0.0, -9.81] # gravitational acceleration [m/s²]
# definiting the model
@variables pos(t)[1:3] = [0.0, 0.0, 0.0]
@variables vel(t)[1:3] = [0.0, 0.0, 50.0]
@variables acc(t)[1:3] = [0.0, 0.0, -9.81]
eqs = vcat(D(pos) ~ vel,
D(vel) ~ acc,
acc ~ G_EARTH)
@named sys = ODESystem(eqs, t)
simple_sys = structural_simplify(sys)
# running the simulation
duration = 10.0
dt = 0.02
tol = 1e-6
ts = 0:dt:duration
prob = ODEProblem(simple_sys, nothing, (0.0, duration))
@time sol = solve(prob, Rodas5(), dt=dt, abstol=tol, reltol=tol, saveat=ts)
# plotting the result
X = sol.t
POS_Z = stack(sol[pos], dims=1)[:,3]
VEL_Z = stack(sol[vel], dims=1)[:,3]
p = plot(X, POS_Z, VEL_Z; xlabel="time [s]", ylabels=["pos_z [m]", "vel_z [m/s]"],
labels=["pos_z [m]", "vel_z [m/s]"], fig="falling mass")
display(p)