StableSignal block
Requirements.ChecksInFixedWindow.StableSignal
ยท source
In every true condition phase (after an optional delay), the moving average of the input's rate of change must stay at or below a limit
Extends Requirements.Interfaces.PartialCheck
Syntax
property = StableSignal(condition=..., u=..., window=..., upperLimit=..., delayTime=...).y;
Description
In every duration where the Boolean input condition is true, the Real input u must be stable: it must not oscillate. Stability is measured by the average speed of u, the moving average of |du/dt| over the last window seconds, output rateAverage; u is stable while it is at or below upperLimit. Averaging starts delayTime after each rising edge of condition; it needs a full window of the phase before the first verdict.
- y = Undefined while condition is false and during the delay: the check is not applicable.
- y = Undecided during the first window of a phase: the average does not yet cover a full window.
- y = Satisfied while rateAverage ≤ upperLimit, y = Violated while it is above.
Set delayTime to the time the system needs to reach quasi steady state, for example 600 s after a chiller switches on, and the window to a few times the settling time of the closed loop: a valve that settles in about 120 s suggests window = 360 s. With the output rateAverage one sees how close the signal comes to the limit and can adjust upperLimit.
Implementation
du/dt is approximated with a first-order filter (time constant Td, default 0.1 s; see Choosing Td). Its absolute value is
integrated from the start of each phase, and the moving average is the difference of that integral over the last
window, (I(t) - I(t - window))/window. This avoids the state events that a test on changes of direction
would generate. The filter is started in steady state and always sees u: the original held its input at 0 while the
check did not apply, and the step to u at the start of a phase (290 K for a temperature in kelvin) put a derivative
spike into the first window -- harmless during that window, but at the instant it was full the spike was still at its
edge, and the average read 290 K / window for a few seconds: a violation that never happened. The original averaged with
SignalAnalysis.MovingAverage, which integrates
u - delay(u, window): its numerical error never decays, and over a long run (or a pulsed condition, whose
derivative spike at every start is not cancelled exactly by its delayed copy) the average drifts by tens of percent
with the solver's step sequence. The difference of the integral has no such drift. Parameter h adds a hysteresis: once unstable, u counts as stable again only at
or below upperLimit - h, which avoids chattering verdicts at the limit.
Choosing Td
The filter is s/(1 + Td s): it follows u only on time scales well above Td, and the check measures what
the filter lets through, not the signal's own rate of change.
- A sine of angular frequency ω reaches |du/dt| with the gain
1/sqrt(1 + (ω Td)²), so rateAverage reads low by that factor: 0.1 % at ω Td = 0.045, 29 % at ω Td = 1. - A move faster than Td is smeared, and back-and-forth movements within about Td partly cancel before the absolute value is taken: the average reads closer to the net change than to the travel. Measured (Chaperone, 2026-11-19): a level with an inverse response, (1 - 0.1 s·s)/(1 + 0.2 s·s)² after a 0.1 m step, dips by 7.5 mm within 67 ms and then rises; over a 1 s window its travel is 0.109 m. With Td = 1 s the block read rateAverage = 0.053 m/s; with Td = 0.01 s, 0.1087 m/s. A requirement checked with a filter as long as its window passed where the signal violated it.
- The rule: Td at most a tenth of the fastest time constant of the movements the requirement means to count, and at most a hundredth of window. A window of minutes on a building's temperatures is met by the default; a window of a second on a mechanical or a level loop needs Td = window/100 or less.
- Not smaller than needed: the filter is a state with time constant Td, which the solver has to resolve; a small Td on a long run of a slow signal costs steps and accuracy for nothing. Measured on Examples.Elementary.ChecksInFixedWindow.StableSignal (a 120 s sine, a 360 s window, an hour): at 100 times the rtol the final rateAverage moves by 0.26 % with Td = 0.1 s and by 0.01 % with Td = 1 s, which the rule gives there and the example sets. Fast noise on u (a measured signal, a chattering controller) passes a small Td and counts in |du/dt|: there a Td above the noise's time scale is the point, and the requirement's limit has to allow for it.
The default is 0.1 s since version 0.18.0. It was 1 s before, the original's fixed value, which is negligible for the
windows of minutes it was written for and wrong for windows of a few seconds. A model that relied on the old default
and wants its old results sets Td = 1.
Margin
Output margin (present if computeMargin = true, the default) is (upperLimit - rateAverage)/scale.
With h = 0 (the default), margin ≥ 0 exactly when the check holds. With h > 0, the verdict stays Violated
while the margin lies between 0 and h/scale after a violation, so the sign of the margin is no longer the
verdict there. During the first window of a phase the margin is provisional (rateAverage is 0 then); a
consumer takes the worst value over the decided points only.
Example
Examples.Elementary.ChecksInFixedWindow.StableSignal and, with the moving average and the margin asserted in closed form, Examples.Elementary.Margin.StableSignal.
Origin
Ported in version 0.13.0 from block Buildings_Requirements.StableContinuousSignal of
modelica-buildings-requirements
(M. Wetter, Lawrence Berkeley National Laboratory, 2024-2025). Parameters T and t of the
original are window and upperLimit here, the activation input and its delay are condition and
delayTime. Changes besides those listed in
WithinBand: the hysteresis is a parameter
h with default 0 (the original fixed it to upperLimit/20) so that the margin's sign is the verdict, and
the derivative filter's time constant is a parameter Td (fixed to 1 s in the original; default 1 s up to
version 0.17.0, 0.1 s from 0.18.0, see Choosing Td), the moving
average is the difference of an integral instead of SignalAnalysis.MovingAverage, and the derivative filter
always sees u instead of 0 while inactive (see Implementation for both).
Copyright (c) 1998-2024 Modelica Association, International Building Performance Simulation Association (IBPSA),
The Regents of the University of California, through Lawrence Berkeley National Laboratory, and contributors;
see UsersGuide.BuildingsLicense.
Copyright © 2026 Model Based Innovation LLC (the port). All rights reserved.
Parameters
| Name | Type | Description |
|---|---|---|
window parameter | SI.Time | Length of the moving window over which |du/dt| is averaged (a few times the settling time of the loop) |
upperLimit parameter | Real | Largest moving average of |du/dt| (unit of u per second) at which u counts as stable |
h parameter | Real | Hysteresis: once unstable, u counts as stable again only at or below upperLimit - h (0: none, and the sign of the margin is the verdict) |
delayTime parameter | SI.Time | Time after each rising edge of condition before the averaging starts (to skip a start-up transient) |
Td parameter | SI.Time | Time constant of the filter that approximates du/dt: at most a tenth of the fastest movement of u to be counted and a hundredth of window (see Choosing Td) |
Components and variables
| Name | Type | Description |
|---|---|---|
u | Modelica.Blocks.Interfaces.RealInput | Monitored quantity |
rateAverage | Modelica.Blocks.Interfaces.RealOutput | Moving average of |du/dt| over the last window, 0 until a full window has passed in the current phase |