ModelingToolkit.jl
ModelingToolkit.jl copied to clipboard
Implicit DAE observed indexing is broken
https://github.com/SciML/ModelingToolkitStandardLibrary.jl/pull/56
@sharanry could you take a look?
Copy-paste example:
using ModelingToolkitStandardLibrary.Mechanical.Rotational, ModelingToolkit, OrdinaryDiffEq
@parameters t
D = Differential(t)
@named fixed = Fixed()
@named inertia1 = Inertia(J=2) # this one is fixed
@named spring = Spring(c=1e4)
@named damper = Damper(d=10)
@named inertia2 = Inertia(J=2, phi_start=pi/2)
connections = [
connect(fixed.flange, inertia1.flange_b)
connect(inertia1.flange_b, spring.flange_a, damper.flange_a)
connect(spring.flange_b, damper.flange_b, inertia2.flange_a)
]
@named model = ODESystem(connections, t, systems=[fixed, inertia1, inertia2, spring, damper])
sys = structural_simplify(model)
prob = DAEProblem(sys, D.(states(sys)) .=> 0.0, Pair[], (0, 10.0))
sol = solve(prob, DFBDF())
julia> sol[inertia1.w]
ERROR: Indexing symbol inertia1₊w(t) is unknown.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] DEFAULT_OBSERVED(sym::Num, u::Vector{Float64}, p::Vector{Float64}, t::Float64)
@ SciMLBase .julia\packages\SciMLBase\Vg9hW\src\scimlfunctions.jl:4
https://github.com/SciML/ModelingToolkit.jl/pull/1616 is a good start. We might need interface changes to DAE observed functions from the DAEFunction side, so that observed functions can depend on derivatives as well.
@oscardssmith this must've been solved given you rely on it?
yeah.