Stop Simulation (Auto-Stop)
Shippingstop_simulationTerminal event: end the sim run early when a watched signal crosses a level in a chosen direction
Signature
Inputs
signalScalar|Integer|Signal— The watched value (ball height, error norm, a state). Scalarized (a Signal uses its last sample); absent ⇒ 0.
Outputs
eventSignal— The zero-crossing function g = signal − level. The solver reads it to localize the stop; it need not be wired anywhere.
Parameters
| Key | Type | Default | Notes |
|---|---|---|---|
level | float | 0.0 | Stop the simulation when the input signal crosses this level (e.g. 0 = the floor, or an error tolerance). |
direction | enum | either | one of: either, falling, rising |
Description
Stop Simulation (Captyse "Auto-Stop"; Simulink's "Stop Simulation" block) is a terminal event for the sim engine. Inside a execution_mode = Simulation compound it emits the zero-crossing function on its event output. The event-localizing solver (any explicit fixed or adaptive method) watches for a sign change in the configured direction; when it fires, the solver localizes the exact crossing time and ends the run there (before ), with no state change.
Use it to stop when a ball's height reaches the floor (height crosses falling), when an error norm falls below a tolerance (early-out on convergence), or when a state exceeds a limit (a divergence / safety guard).
Because the stop time is localized on the step's dense output (or by fixed-step sub-stepping), it is accurate to solver precision — not snapped to a coarse step boundary the way a discrete Stop block would be. Internally it reuses the same zero-crossing engine as Hit Crossing; the only difference is the action declared at compile time (Stop vs. Reset).
On the ordinary acyclic dataflow path (or with a non-event solver) it is a benign passthrough emitting — only a real simulation acts on the crossing. The input is optional and is scalarized before use: a Scalar uses its value, an Integer its integer, a Signal its last sample, and an absent/unsupported input is treated as . The emitted event is a degenerate one-sample Signal (sample_rate = 0) carrying ; it does not need to be wired to anything for the engine to act.
Mathematics
Examples
Stop a bouncing ball at the floor
Wire the ball's height into signal, set level = 0, direction = falling. When crosses downward the solver localizes the exact contact time and ends the run there — no coarse step snapping.
Early-out on convergence
Feed an error norm into signal, set level = 1e-6, direction = falling. The run terminates the instant the error drops below tolerance, saving the remaining integration steps.
Safety / divergence guard
Wire a state magnitude into signal, set level = 1e6, direction = rising. If the state ever exceeds the limit the simulation stops immediately instead of running to with a blown-up trajectory.
Applications
- Ending a simulation at a physical event (impact, threshold, depletion) localized to solver precision rather than a step boundary.
- Early-out termination when an error norm or residual falls below a convergence tolerance.
- Divergence and safety guards that halt a run the moment a state exceeds a magnitude limit.
- Bounding the runtime of event-driven models where the natural stop condition is a state crossing, not a fixed final time.
Neat
It shares the exact same zero-crossing localization engine as Hit Crossing; only the compile-time `EventAction` differs (Stop vs. Reset), so the two can never drift in how they find a crossing.
The stop time is found on the step's dense output (or fixed-step sub-stepping), so it is accurate to solver precision — far finer than a discrete Stop block that can only halt on a step boundary.
The `event` output is purely for the engine to read; it does not have to be wired downstream, and on a plain dataflow/non-event path the node is a harmless passthrough emitting g.
It emits g even outside a simulation, so a model with an Auto-Stop still runs head-less on the dataflow path without special-casing.
Known issues
The stop action only takes effect inside a Simulation compound with an event-localizing solver; on the dataflow path or a non-event method it merely passes g through and never terminates.
The input is scalarized to a single value per step — a Signal is reduced to its last sample — so the crossing is watched on that scalar, not element-wise across the whole signal.
The emitted event Signal has sample_rate = 0 and a single sample; it is meant for the engine, not as a general-purpose numeric output for downstream processing.