ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

Implicit DAE observed indexing is broken

Open YingboMa opened this issue 2 years ago • 2 comments

https://github.com/SciML/ModelingToolkitStandardLibrary.jl/pull/56

@sharanry could you take a look?

YingboMa avatar May 21 '22 03:05 YingboMa

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

ValentinKaisermayer avatar May 22 '22 18:05 ValentinKaisermayer

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.

YingboMa avatar May 30 '22 00:05 YingboMa

@oscardssmith this must've been solved given you rely on it?

ChrisRackauckas avatar Feb 22 '24 16:02 ChrisRackauckas

yeah.

oscardssmith avatar Feb 22 '24 17:02 oscardssmith