blockStageChangeCommand

Generate stage change command

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:

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

TypeNameDefaultDescription
Buildings.Templates.Plants.Controls.Types.ApplicationtypType of application
Booleanhave_phpfalseSet to true for plants with polyvalent heat pumps
Booleanhave_pumSecSet to true for primary-secondary distribution, false for primary-only
Booleanhave_inpPlrStafalseSet to true to use an input signal for SPLR, false to use a parameter
RealplrSta0.9Staging 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[:,:]staEquStaging matrix – Equipment required for each stage
IntegernStaif have_php then integer((1 + sqrt(1 + 4*size(staEqu, 1)))/2) - 1 else size(staEqu, 1)Number of stages
IntegernEqusize(staEqu, 2)Number of equipment
Real[:]capEquDesign capacity of each equipment
RealdtRun900Runtime with exceeded staging part load ratio before staging event is triggered
RealdtMea300Duration used to compute the moving average of required capacity
Realcp_defaultDefault specific heat capacity used to compute required capacity
Realrho_defaultDefault density used to compute required capacity
RealdTDelta-T triggering stage up command (>0)
RealdtPri900Runtime with high primary-setpoint Delta-T before staging up
RealdtSec600Runtime with high secondary-primary and secondary-setpoint Delta-T before staging up

Connectors

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Interfaces.BooleanInput[nSta]u1AvaStaStage available signal
Buildings.Controls.OBC.CDL.Interfaces.BooleanInputu1StaProStaging process in progress
Buildings.Controls.OBC.CDL.Interfaces.RealInputuPlrStaInput signal for staging part load ratio
Buildings.Controls.OBC.CDL.Interfaces.IntegerInputuStaStage index
Buildings.Controls.OBC.CDL.Interfaces.RealInputTRetReturn temperature used to compute required capacity
Buildings.Controls.OBC.CDL.Interfaces.RealInputTSupSetActive supply temperature setpoint used to compute required capacity
Buildings.Controls.OBC.CDL.Interfaces.RealInputV_flowVolume flow rate used to compute required capacity
Buildings.Controls.OBC.CDL.Interfaces.BooleanOutputy1UpStage up command
Buildings.Controls.OBC.CDL.Interfaces.BooleanOutputy1DowStage down command
Buildings.Controls.OBC.CDL.Interfaces.IntegerInputuStaOppStage index of opposite mode
Buildings.Controls.OBC.CDL.Interfaces.RealOutput[nEqu,nSta]staTraTranspose of staging matrix at given stage
Buildings.Controls.OBC.CDL.Interfaces.BooleanInputu1LckLock stage up command
Buildings.Controls.OBC.CDL.Interfaces.BooleanOutputy1LckLock stage up command of opposite mode
Buildings.Controls.OBC.CDL.Interfaces.RealInputTPriSupPrimary supply temperature
Buildings.Controls.OBC.CDL.Interfaces.RealInputTSecSupSecondary supply temperature
Buildings.Controls.OBC.CDL.Interfaces.IntegerInputuStaOppNexHigNext available higher stage index of opposite mode
Buildings.Controls.OBC.CDL.Interfaces.IntegerOutputyStaNexHigNext available higher stage index

Components

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Reals.Sources.Constant[nEqu,nSta]traMatStaEquTranspose of staging matrix
Buildings.Controls.OBC.CDL.Routing.RealExtractor[nEqu]reqEquStaExtract equipment required at given stage
Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicatorintScaRepReplicate signal
Buildings.Controls.OBC.CDL.Reals.Multiply[nEqu]capEquStaCapacity of each equipment required at given stage
Buildings.Controls.OBC.CDL.Reals.Sources.Constant[nEqu]capEquParCapacity of each equipment
Buildings.Controls.OBC.CDL.Reals.MultiSumcapStaCompute nominal capacity of active stage
Buildings.Controls.OBC.CDL.Reals.GreatergreCompare OPLR to SPLR (hysteresis is to avoid chattering with some simulators)
Buildings.Controls.OBC.ASHRAE.G36.Plants.Chillers.Generic.TimerWithResettimUpTimer
Buildings.Controls.OBC.CDL.Reals.LesslesCompare OPLR to SPLR (hysteresis is to avoid chattering with some simulators)
Buildings.Controls.OBC.ASHRAE.G36.Plants.Chillers.Generic.TimerWithResettimDowTimer
Utilities.HoldRealholHold value of required capacity at stage change
Buildings.Controls.OBC.CDL.Integers.MaxmaxIntMaximum between stage index and 1
Buildings.Controls.OBC.CDL.Integers.Sources.ConstantoneConstant
Buildings.Controls.OBC.CDL.Integers.Sources.Constant[nSta]idxStaStage index
Buildings.Controls.OBC.CDL.Integers.Less[nSta]idxStaLesActReturn true if stage index lower than active stage index
Buildings.Controls.OBC.CDL.Logical.And[nSta]idxStaLesActAvaTrue if stage index lower than active stage index and stage available
Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicatorintScaRep1Replicate signal
Utilities.LastTrueIndexidxLasTruIndex of next available lower stage
Buildings.Controls.OBC.CDL.Integers.MaxmaxInt1Maximum between stage index and 1
Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicatorintScaRep2Replicate signal
Buildings.Controls.OBC.CDL.Routing.RealExtractor[nEqu]reqEquStaLowExtract equipment required at next available lower stage
Buildings.Controls.OBC.CDL.Reals.Multiply[nEqu]capEquStaLowCapacity of each equipment required at next available lower stage
Buildings.Controls.OBC.CDL.Reals.MultiSumcapStaLowCompute nominal capacity of next available lower stage
Buildings.Controls.OBC.CDL.Integers.MinminIntMinimum between stage index and 1
Buildings.Controls.OBC.CDL.Conversions.IntegerToRealintToReaConvert to real value
Buildings.Controls.OBC.CDL.Reals.MultiplysetZerSet nominal capacity to zero if no lower available stage
Buildings.Controls.OBC.CDL.Reals.MultiplysplTimCapStaSPLR times capacity of active stage
Buildings.Controls.OBC.CDL.Reals.MultiplysplTimCapStaLowSPLR times capacity of next available lower stage
Utilities.PlaceholderRealparPlrStaParameter value for SPLR
Buildings.Controls.OBC.CDL.Logical.FallingEdgeendStaProTrue when staging process terminates
LoadAveragecapReqCompute required capacity
FailsafeConditionfaiSafFailsafe stage up condition
Buildings.Controls.OBC.CDL.Logical.OreffOrFaiSafEfficiency OR failsafe condition met
Buildings.Controls.OBC.CDL.Logical.NotnotFaiSafFailsafe stage up condition is not true
Buildings.Controls.OBC.CDL.Logical.AndeffAndNotFaiSafEfficiency condition met AND failsafe stage up condition is not true
PolyvalentHeatPumps.ExtractStagingMatrixextTraExtract transpose of staging matrix for the opposite mode stage index
Buildings.Controls.OBC.CDL.Routing.RealExtractor[nEqu]reqEquStaNexHigExtract equipment required at next available higher stages
PolyvalentHeatPumps.ExtractStagingMatrixextTraOppNexHigExtract transpose of staging matrix for the next available higher stage of opposite mode
Buildings.Controls.OBC.CDL.Logical.AndupAndCouEquStaNexHigZerTrue if stage up command and equipment count at next available higher stages is zero
Utilities.PlaceholderLogicalphLckOppPlaceholder value (no lock)
Buildings.Controls.OBC.CDL.Logical.NotnotLckTrue if stage up command is not locked
Buildings.Controls.OBC.CDL.Logical.AndupAndNotLckTrue if stage up command and no active lock
Buildings.Controls.OBC.CDL.Integers.Greater[nSta]idxStaGreActReturn true if stage index greater than active stage index
Buildings.Controls.OBC.CDL.Logical.And[nSta]idxStaGreActAvaTrue if stage index greater than active stage index and stage available
Utilities.FirstTrueIndexidxFirTruIndex of next available higher stage
Buildings.Controls.OBC.CDL.Integers.MaxmaxCurStaGuard against first true index returning 0
Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicatorintScaRep4Replicate signal
Buildings.Controls.OBC.CDL.Reals.MultiSumcouEquStaNexHigEquipment count at next available higher stages
Buildings.Controls.OBC.CDL.Reals.LessThresholdcouEquStaNexHigZerTrue if equipment count at next available higher stages is zero
Buildings.Controls.OBC.CDL.Logical.TrueFalseHoldtruFalHolNo-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 using LoadAverage block and added failsafe condition.
  • March 29, 2024, by Antoine Gautier:
    First implementation.