Force MTK to generate explicit ODEs?

Hi!

I am using ModelingToolkit.jl to model a physical system. The compiler generates an index-1 DAE, which works great for simulation.

However, I need to use a standard Kalman Filter, which requires a minimal state-space representation (\dot{x} = Ax + Bu) with a full-rank observability matrix.

The Problem:

When I use ModelingToolkit.linearize(sys, inputs, outputs), the resulting state-space matrices include the dummy (algebraic) states.

  • Total states: 5 (3 true states + 2 dummy/algebraic states).
  • Observability Matrix Rank: 3.
  • Result: The system is unobservable and the Kalman covariance update fails.

My Question:

Is there a way to force MTK to perform full substitution/elimination of these algebraic variables to generate a purely explicit ODE system before or during linearization? I essentially need to convert the Mass Matrix DAE into a standard ODE so I can get a minimal A matrix.

You can use model-order index reduction: Run only the algebraic part of the solver - #15 by baggepinnen