blockStageChangeCommand
Information
The plant equipment is staged in part based on required capacity, Qrequired, relative to nominal capacity of a given stage, Qstage. This ratio is the operative part load ratio, OPLR.
OPLR = Qrequired / Qstage
If both primary and secondary return temperature and flow rate sensors are available, the sensors in the primary loop are used for calculating Qrequired. (This condition is implemented in Buildings.Templates.Plants.Controls.HeatPumps.AirToWater.)
The required capacity is calculated based on return temperature, active supply temperature setpoint and measured flow through the associated circuit flow meter.
The required capacity used in logic is a rolling average over a period of
dtMea of instantaneous values sampled at minimum once every
30 s.
When a stage up or stage down transition is initiated,
Qrequired is held fixed at its last value until the longer of the
successful completion of the stage change and the duration
dtRun.
The nominal capacity of a given stage, Qstage, is calculated as the sum of the design capacities of all units enabled in a given stage.
Staging is executed per the conditions below subject to the following requirements.
-
Each stage has a minimum runtime of
dtRun. (This condition is implemented in Buildings.Templates.Plants.Controls.Utilities.StageIndex.) - Timers are reset to zero at the completion of every stage change.
- Any unavailable stage is skipped during staging events, but staging conditionals in the current stage are evaluated as per usual.
A stage up command is triggered if any of the following is true:
- Availability condition: The equipment necessary to operate the current stage is unavailable. The availability condition is not subject to the minimum stage runtime requirement. (This condition is implemented in Buildings.Templates.Plants.Controls.Utilities.StageIndex.)
-
Efficiency condition: Current stage OPLR > plrSta for a duration
of
dtRun. - Failsafe condition: see Buildings.Templates.Plants.Controls.StagingRotation.FailsafeCondition.
A stage down command is triggered if both of the following are true:
-
Next available lower stage OPLR < plrSta for a duration of
dtRun. - The failsafe stage up condition is not true.
Details
A staging matrix staEqu is required as a parameter. See the
documentation of
Buildings.Templates.Plants.Controls.StagingRotation.EquipmentEnable for
the associated definition and requirements.
An "if" condition is used to generate the stage up and down command as
opposed to a "when" condition. This means that the command remains true as
long as the condition is verified. This is necessary, for example, if no
higher stage is available when a stage up command is triggered. Using a
"when" condition – which is only valid at the point in time at which
the condition becomes true – would prevent the plant from staging when
a higher stage becomes available again. To avoid multiple consecutive stage
changes, the block that receives the stage up and down command and computes
the stage index must enforce a minimum stage runtime of dtRun.
Locking logic for polyvalent heat pump plants
For plants with polyvalent heat pumps (have_php=true), a
locking mechanism prevents a race condition in which heating and cooling
simultaneously stage up to an infeasible stage combination.
Such a combination is encoded as a zero equipment count in the staging
matrix.
This race condition is not captured by the stage availability logic in
Buildings.Templates.Plants.Controls.StagingRotation.StageAvailability:
that block evaluates feasibility based on the current stage of the
opposite mode, so it correctly clears infeasible stages in steady state,
but cannot anticipate that the opposite mode will also stage up within
the same event iteration.
The heating-mode instance of this block evaluates the feasibility of the combined next step by looking up the equipment count for the pair (next available higher heating stage, next available higher cooling stage) in the staging matrix. If that count is zero – i.e., the combination is infeasible – the heating block asserts the lock output. This signal is connected to the cooling-mode instance which inhibits the stage-up command. Heating therefore stages up with priority, landing on a combination that is feasible with the current cooling stage.
Parameters
| Type | Name | Default | Description |
|---|---|---|---|
| Buildings.Templates.Plants.Controls.Types.Application | typ | Type of application | |
| Boolean | have_php | false | Set to true for plants with polyvalent heat pumps |
| Boolean | have_pumSec | Set to true for primary-secondary distribution, false for primary-only | |
| Boolean | have_inpPlrSta | false | Set to true to use an input signal for SPLR, false to use a parameter |
| Real | plrSta | 0.9 | Staging part load ratio |
| Real[nEqu,nSta] | traStaEqu | {{staEqu[i, j] for i in 1:nSta} for j in 1:nEqu} | Transpose of staging matrix |
| Real[:,:] | staEqu | Staging matrix – Equipment required for each stage | |
| Integer | nSta | if have_php then integer((1 + sqrt(1 + 4*size(staEqu, 1)))/2) - 1 else size(staEqu, 1) | Number of stages |
| Integer | nEqu | size(staEqu, 2) | Number of equipment |
| Real[:] | capEqu | Design capacity of each equipment | |
| Real | dtRun | 900 | Runtime with exceeded staging part load ratio before staging event is triggered |
| Real | dtMea | 300 | Duration used to compute the moving average of required capacity |
| Real | cp_default | Default specific heat capacity used to compute required capacity | |
| Real | rho_default | Default density used to compute required capacity | |
| Real | dT | Delta-T triggering stage up command (>0) | |
| Real | dtPri | 900 | Runtime with high primary-setpoint Delta-T before staging up |
| Real | dtSec | 600 | Runtime with high secondary-primary and secondary-setpoint Delta-T before staging up |
Connectors
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Buildings.Controls.OBC.CDL.Reals.Sources.Constant[nEqu,nSta] | traMatStaEqu | Transpose of staging matrix | |
| Buildings.Controls.OBC.CDL.Routing.RealExtractor[nEqu] | reqEquSta | Extract equipment required at given stage | |
| Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicator | intScaRep | Replicate signal | |
| Buildings.Controls.OBC.CDL.Reals.Multiply[nEqu] | capEquSta | Capacity of each equipment required at given stage | |
| Buildings.Controls.OBC.CDL.Reals.Sources.Constant[nEqu] | capEquPar | Capacity of each equipment | |
| Buildings.Controls.OBC.CDL.Reals.MultiSum | capSta | Compute nominal capacity of active stage | |
| Buildings.Controls.OBC.CDL.Reals.Greater | gre | Compare OPLR to SPLR (hysteresis is to avoid chattering with some simulators) | |
| Buildings.Controls.OBC.ASHRAE.G36.Plants.Chillers.Generic.TimerWithReset | timUp | Timer | |
| Buildings.Controls.OBC.CDL.Reals.Less | les | Compare OPLR to SPLR (hysteresis is to avoid chattering with some simulators) | |
| Buildings.Controls.OBC.ASHRAE.G36.Plants.Chillers.Generic.TimerWithReset | timDow | Timer | |
| Utilities.HoldReal | hol | Hold value of required capacity at stage change | |
| Buildings.Controls.OBC.CDL.Integers.Max | maxInt | Maximum between stage index and 1 | |
| Buildings.Controls.OBC.CDL.Integers.Sources.Constant | one | Constant | |
| Buildings.Controls.OBC.CDL.Integers.Sources.Constant[nSta] | idxSta | Stage index | |
| Buildings.Controls.OBC.CDL.Integers.Less[nSta] | idxStaLesAct | Return true if stage index lower than active stage index | |
| Buildings.Controls.OBC.CDL.Logical.And[nSta] | idxStaLesActAva | True if stage index lower than active stage index and stage available | |
| Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicator | intScaRep1 | Replicate signal | |
| Utilities.LastTrueIndex | idxLasTru | Index of next available lower stage | |
| Buildings.Controls.OBC.CDL.Integers.Max | maxInt1 | Maximum between stage index and 1 | |
| Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicator | intScaRep2 | Replicate signal | |
| Buildings.Controls.OBC.CDL.Routing.RealExtractor[nEqu] | reqEquStaLow | Extract equipment required at next available lower stage | |
| Buildings.Controls.OBC.CDL.Reals.Multiply[nEqu] | capEquStaLow | Capacity of each equipment required at next available lower stage | |
| Buildings.Controls.OBC.CDL.Reals.MultiSum | capStaLow | Compute nominal capacity of next available lower stage | |
| Buildings.Controls.OBC.CDL.Integers.Min | minInt | Minimum between stage index and 1 | |
| Buildings.Controls.OBC.CDL.Conversions.IntegerToReal | intToRea | Convert to real value | |
| Buildings.Controls.OBC.CDL.Reals.Multiply | setZer | Set nominal capacity to zero if no lower available stage | |
| Buildings.Controls.OBC.CDL.Reals.Multiply | splTimCapSta | SPLR times capacity of active stage | |
| Buildings.Controls.OBC.CDL.Reals.Multiply | splTimCapStaLow | SPLR times capacity of next available lower stage | |
| Utilities.PlaceholderReal | parPlrSta | Parameter value for SPLR | |
| Buildings.Controls.OBC.CDL.Logical.FallingEdge | endStaPro | True when staging process terminates | |
| LoadAverage | capReq | Compute required capacity | |
| FailsafeCondition | faiSaf | Failsafe stage up condition | |
| Buildings.Controls.OBC.CDL.Logical.Or | effOrFaiSaf | Efficiency OR failsafe condition met | |
| Buildings.Controls.OBC.CDL.Logical.Not | notFaiSaf | Failsafe stage up condition is not true | |
| Buildings.Controls.OBC.CDL.Logical.And | effAndNotFaiSaf | Efficiency condition met AND failsafe stage up condition is not true | |
| PolyvalentHeatPumps.ExtractStagingMatrix | extTra | Extract transpose of staging matrix for the opposite mode stage index | |
| Buildings.Controls.OBC.CDL.Routing.RealExtractor[nEqu] | reqEquStaNexHig | Extract equipment required at next available higher stages | |
| PolyvalentHeatPumps.ExtractStagingMatrix | extTraOppNexHig | Extract transpose of staging matrix for the next available higher stage of opposite mode | |
| Buildings.Controls.OBC.CDL.Logical.And | upAndCouEquStaNexHigZer | True if stage up command and equipment count at next available higher stages is zero | |
| Utilities.PlaceholderLogical | phLckOpp | Placeholder value (no lock) | |
| Buildings.Controls.OBC.CDL.Logical.Not | notLck | True if stage up command is not locked | |
| Buildings.Controls.OBC.CDL.Logical.And | upAndNotLck | True if stage up command and no active lock | |
| Buildings.Controls.OBC.CDL.Integers.Greater[nSta] | idxStaGreAct | Return true if stage index greater than active stage index | |
| Buildings.Controls.OBC.CDL.Logical.And[nSta] | idxStaGreActAva | True if stage index greater than active stage index and stage available | |
| Utilities.FirstTrueIndex | idxFirTru | Index of next available higher stage | |
| Buildings.Controls.OBC.CDL.Integers.Max | maxCurSta | Guard against first true index returning 0 | |
| Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicator | intScaRep4 | Replicate signal | |
| Buildings.Controls.OBC.CDL.Reals.MultiSum | couEquStaNexHig | Equipment count at next available higher stages | |
| Buildings.Controls.OBC.CDL.Reals.LessThreshold | couEquStaNexHigZer | True if equipment count at next available higher stages is zero | |
| Buildings.Controls.OBC.CDL.Logical.TrueFalseHold | truFalHol | No-op hold to improve tool support |
Revisions
-
July 10, 2026, by Antoine Gautier:
Refactored to support plants with polyvalent heat pumps.
This is for #4512. -
May 31, 2024, by Antoine Gautier:
Refactored usingLoadAverageblock and added failsafe condition. -
March 29, 2024, by Antoine Gautier:
First implementation.