Does a While Iterator subsystem prevent ode1be implicit iterations? Backward Euler becomes explicit in my custom DAE solver
Show older comments
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:
- Integrator outputs x_k
- While Iterator runs NR iterations using x_k (and other signals) to solve algebraic variables and compute f(...) = dx/dt
- 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 (1)
Raag
10 minutes ago
0 votes
Hi,
It is my understanding that you are attempting to solve a DAE by running a custom Newton-Raphson loop inside a While Iterator Subsystem, with the derivative fed to a continuous Integrator using the fixed‑step 'ode1be' solver.
In general, Backward Euler behaves implicitly only when the solver can re-evaluate derivatives using tentative future states.
However, a While Iterator Subsystem executes entirely within a single major step using signals available at the beginning of that step, which prevents the solver from performing its own implicit iterations. As a result, the algebraic dependency between 'xk+1' and 'x(dot)' is broken, and 'ode1be' effectively reduces to a forward/explicit update. A continuous path without the While Iterator allows Simulink to form an algebraic loop, enabling proper backward‑Euler behavior.
If you want to maintain your custom NR loop, one option is to move to a discrete formulation and perform the full backward‑Euler update inside your NR solver.
Alternatively, you may shift the residual and derivative evaluation back to a continuous direct‑feedthrough path and allow the solver to handle implicit iterations. For more advanced control, implementing the DAE in an S‑Function or switching to implicit solvers like 'ode15s' may also help.
You can refer to the following documentations for more information:
- Choose a solver: https://www.mathworks.com/help/simulink/ug/choose-a-solver.html
- Algebraic loops: https://www.mathworks.com/help/simulink/ug/algebraic-loops.html
- Algebraic Constraint block: https://www.mathworks.com/help/simulink/slref/algebraicconstraint.html
- S-Functions overview: https://www.mathworks.com/help/simulink/sfg/what-is-an-s-function.html
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!