Does a While Iterator subsystem prevent ode1be implicit iterations? Backward Euler becomes explicit in my custom DAE solver

10 views (last 30 days)
Hi all,
I’m trying to solve a DAE in Simulink using a custom Newton–Raphson (NR) loop implemented with a While Iterator Subsystem.
What I’m doing
  • The overall problem is a DAE where I solve algebraic unknowns using NR at every time step.
  • Inside the While Iterator Subsystem, I compute the residual and (as part of that) compute the ODE part’s state derivative dx/dt.
  • The Integrator block is outside the While Iterator Subsystem (continuous Integrator), so time advances only once per major step.
  • The Integrator’s current state x(t) is fed into the While Iterator as the initial guess for the residual evaluation, and the computed dx/dt is fed back to the Integrator input.
  • The solver is set to fixed-step with ode1be (Backward Euler) (step size: [1e-3]).
Conceptually:
  1. Integrator outputs x_k
  2. While Iterator runs NR iterations using x_k (and other signals) to solve algebraic variables and compute f(...) = dx/dt
  3. Integrator updates the state using ode1be
Expected behavior
With ode1be, I expect an implicit update (Backward Euler):
meaning Simulink should effectively evaluate the derivative using the “future” state (or iterate internally to satisfy the implicit equation).
Observed behavior
When the derivative dx/dt is produced through my While Iterator + NR loop structure, the result matches Forward Euler:
However, if I remove the While Iterator / custom NR loop and compute dx/dt in a normal continuous path, ode1be behaves correctly (implicit/backward).
So it looks like my model structure causes ode1be to lose its implicit behavior and behave like an explicit integrator.
  • schimetics for custom DAE Sovler
Questions
1. Why does ode1be effectively become forward/explicit when the derivative is computed inside a While Iterator subsystem?
  • Does While Iterator prevent the solver from performing implicit iterations / re-evaluations of the derivative with tentative x_{k+1}?
  • Is the While Iterator subsystem treated as “non-reentrant” or “discrete-like” in a way that breaks the implicit loop needed for ode1be?
2. Is there a recommended way to structure a custom DAE + NR loop while still using an implicit integrator like ode1be?
  • I specifically want to avoid using the Algebraic Constraint block.
3. Are there alternative Simulink-native DAE approaches (without Algebraic Constraint) that can keep the stability benefits of implicit integration?
For example: using a different solver class (ode15s/ode23t), using an S-Function, using a discrete update with manual backward Euler inside NR, etc.
If needed, I can share a minimal reproducible example model.
ps. I used AI for translation
Thanks!

Answers (0)

Products


Release

R2025a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!