Simulink simulations often run smoothly until they suddenly stall at a specific time step. The solver cuts its step size down repeatedly toward 10−15 or 10−18 seconds, progress halts, and Simulink terminates with an error:

Derivative of state in block 'model/Integrator' at time 0.42813 is not finite. The simulation will be stopped. There may be a singularity in the solution.

When this happens, tightening tolerances or guessing alternative solvers rarely fixes the root problem. The crash usually stems from one of three numerical issues: system stiffness, an unresolved algebraic loop, or zero-crossing chattering. Below is the diagnostic procedure to identify and eliminate each one.

1. The root cause: system stiffness and eigenvalue spread

Default variable-step solvers like ode45 (Dormand-Prince) are explicit Runge-Kutta integrators. They compute the state at step n+1 using only the state and derivatives from step n:

Explicit Runge-Kutta Step:

xn+1 = xn + h · ∑(bi · ki)

Physical systems, including power converters, mechanical linkages, and hydraulic actuators, are frequently stiff. Stiffness means the system contains dynamic modes operating on widely separated timescales, such as an inverter switching at 20 kHz while an attached motor accelerates over several seconds.

If the system Jacobian matrix J = ∂f / ∂x has eigenvalues λi, the stiffness ratio is:

Stiffness Ratio:

SR = max|Re(λi)| / min|Re(λi)|

When SR exceeds 103, explicit solvers must reduce their step size h below 2 / |λmax| solely to prevent numerical divergence.

When ode45 encounters stiff dynamics, it takes millions of tiny steps to track settled high-frequency transients. It eventually runs into floating-point roundoff limits and crashes with non-finite derivatives (NaN or Inf).

2. Switching to implicit stiff solvers

Stiff physical dynamics require an implicit solver. Implicit solvers evaluate states at step n+1 by solving algebraic equations at each step using Newton-Raphson iterations:

Solver Formulation Best Suited For Zero-Crossing Performance
ode15s Numerical Differentiation Formulas (NDF / BDF) Stiff continuous models, chemical reactions, differential algebraic equations (DAEs) Reliable with smooth continuous states
ode23t Trapezoidal rule with free interpolation Simscape physical networks, RLC circuits, lossless mechanical vibration Preserves energy with zero artificial numerical damping
ode23tb TR-BDF2 (Trapezoidal plus 2nd-order BDF) Power electronics, switching converters, motor drives Rapid recovery after sharp switching events

3. Diagnosing and breaking algebraic loops

An algebraic loop occurs when a block output feeds back into its own input within the same time step without a dynamic state (like an integrator or delay block) in between:

Direct Feedthrough Loop:

y(t) = f(u(t)) = f(g(y(t)))

Simulink must pause numerical integration at each step to solve the algebraic equation yf(g(y)) = 0 iteratively. If the algebraic solver fails to converge within its iteration limit, the simulation halts.

Three techniques to eliminate algebraic loops

  • Insert a first-order physical filter: Rather than inserting a Memory block (which introduces phase lag that can destabilize feedback loops), insert a low-pass filter with its pole placed 5 to 10 times higher than the closed-loop bandwidth: H(s) = 1 / (τs + 1), where τ β‰ͺ 1 / ωbandwidth. This adds a physical differential state dx/dt and turns the algebraic constraint into an explicit ODE.
  • Add parasitic resistances in Simscape: In electrical networks, algebraic loops commonly appear when ideal switches are in series with inductors or ideal diodes are in parallel with capacitors. Adding realistic snubber resistance (Rsnub = 105 Ω) or parasitic ESR (Resr = 10 mΩ) restores continuous dynamics.
  • Switch to Line Search: In Model Configuration Parameters under Optimization > Algebraic Loops, change the solver algorithm from Trust-Region to Line Search to improve convergence on difficult nonlinearities.

4. Summary checklist to stabilize non-converging simulations

  • Step 1: If using ode45 on mechanical or power systems, switch to ode15s (for continuous stiff dynamics) or ode23tb (for switching circuits).
  • Step 2: Set Relative Tolerance (RelTol) to 1e-4. The default 1e-3 is often too loose for tight feedback loops, while 1e-6 forces excessive step cuts.
  • Step 3: Set MaxStep to (StopTime − StartTime) / 1000 to prevent the variable-step solver from overshooting rapid zero-crossings.
  • Step 4: Replace discontinuous blocks (such as sign(x)) with continuously differentiable equivalents (like tanh(50x)) to eliminate zero-crossing chattering.