Buildings.Examples.ChillerPlant.BaseClasses.Controls

Package with control components for Buildings.Examples.ChillerPlant

Information

This package contains component models that are used to construct the control system in Buildings.Examples.ChillerPlant.

Extends from Modelica.Icons.VariantsPackage (Icon for package containing variants).

Package Content

Name Description
Buildings.Examples.ChillerPlant.BaseClasses.Controls.BatteryControl BatteryControl Controller for battery
Buildings.Examples.ChillerPlant.BaseClasses.Controls.ChillerSwitch ChillerSwitch Control unit for enabling/disabling chiller
Buildings.Examples.ChillerPlant.BaseClasses.Controls.KMinusU KMinusU Output y=k-u
Buildings.Examples.ChillerPlant.BaseClasses.Controls.LinearPiecewiseTwo LinearPiecewiseTwo A two-pieces linear piecewise function
Buildings.Examples.ChillerPlant.BaseClasses.Controls.RequestCounter RequestCounter Count the number of actuators that have request
Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond TrimAndRespond Trim and respond logic
Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespondContinuousTimeApproximation TrimAndRespondContinuousTimeApproximation Trim and respond logic
Buildings.Examples.ChillerPlant.BaseClasses.Controls.WSEControl WSEControl Control unit for WSE
Buildings.Examples.ChillerPlant.BaseClasses.Controls.Examples Examples Test of components

Buildings.Examples.ChillerPlant.BaseClasses.Controls.BatteryControl Buildings.Examples.ChillerPlant.BaseClasses.Controls.BatteryControl

Controller for battery

Buildings.Examples.ChillerPlant.BaseClasses.Controls.BatteryControl

Information

Block for a battery controller. The battery is charged during night if its charge is below a threshold. It remains charging until it is full. During day, it discharges provided that its charge is above a threshold. It remains discharging until it is empty.

Connectors

TypeNameDescription
input RealInputSOCState of charge
output RealOutputyPower charged or discharged from battery

Modelica definition

model BatteryControl "Controller for battery" Modelica.Blocks.Interfaces.RealInput SOC "State of charge"; Modelica.Blocks.Interfaces.RealOutput y "Power charged or discharged from battery"; Modelica.Blocks.Logical.LessThreshold lessThreshold(threshold=0.5); Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold(threshold= 0.99); Modelica.Blocks.Sources.BooleanExpression isDay(y=mod(time, 86400) > 7*3600 and mod(time, 86400) <= 19*3600) "Outputs true if it is day time"; Modelica.Blocks.Logical.Not not1; Modelica.Blocks.Logical.And and1; Modelica.Blocks.Logical.And and2; Modelica.Blocks.Logical.GreaterThreshold greaterThreshold(threshold=0.8); Modelica.Blocks.Logical.LessEqualThreshold lessEqualThreshold(threshold= 0.01); Modelica.Blocks.Math.MultiSwitch multiSwitch1( nu=2, expr={200e3,-400e3}); Modelica.StateGraph.InitialStep off "Off state"; inner Modelica.StateGraph.StateGraphRoot stateGraphRoot; Modelica.StateGraph.Alternative alternative(nBranches=2) "Splitter for alternative branches"; Modelica.StateGraph.TransitionWithSignal t1(enableTimer=true, waitTime=1) "Transition to charge"; Modelica.StateGraph.TransitionWithSignal t2(enableTimer=true, waitTime=1) "Transition to discharge"; Modelica.StateGraph.StepWithSignal charge "Charge battery"; Modelica.StateGraph.StepWithSignal discharge "Discharge battery"; Modelica.StateGraph.TransitionWithSignal t3 "Transition to off"; Modelica.StateGraph.TransitionWithSignal t4 "Transition to off"; equation connect(lessThreshold.u, SOC); connect(greaterEqualThreshold.u, SOC); connect(not1.u, isDay.y); connect(and1.u1, not1.y); connect(lessThreshold.y, and1.u2); connect(isDay.y, and2.u1); connect(greaterThreshold.u, SOC); connect(greaterThreshold.y, and2.u2); connect(lessEqualThreshold.u, SOC); connect(multiSwitch1.y, y); connect(off.outPort[1], alternative.inPort); connect(t1.outPort, charge.inPort[1]); connect(t2.outPort, discharge.inPort[1]); connect(charge.outPort[1], t3.inPort); connect(discharge.outPort[1], t4.inPort); connect(alternative.outPort, off.inPort[1]); connect(and1.y, t1.condition); connect(and2.y, t2.condition); connect(greaterEqualThreshold.y, t3.condition); connect(lessEqualThreshold.y, t4.condition); connect(t1.inPort, alternative.split[1]); connect(t2.inPort, alternative.split[2]); connect(t3.outPort, alternative.join[1]); connect(t4.outPort, alternative.join[2]); connect(charge.active, multiSwitch1.u[1]); connect(discharge.active, multiSwitch1.u[2]); end BatteryControl;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.ChillerSwitch Buildings.Examples.ChillerPlant.BaseClasses.Controls.ChillerSwitch

Control unit for enabling/disabling chiller

Buildings.Examples.ChillerPlant.BaseClasses.Controls.ChillerSwitch

Information

The controls for enabling/disabling chiller are as follows: where TChi_CHWST is chiller chilled water supply temperature, TChiSet is set temperature for chilled water leaving chiller, and TDeaBan is dead band to prevent short cycling.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
TemperaturedeaBan Dead band of temperature to prevent chiller short cycling [K]

Connectors

TypeNameDescription
input RealInputchiCHWSTChiller chilled water supply temperature (water entering chiller) [K]
output BooleanOutputyControl signal for chiller. 1: Enable, 0: Disable
input RealInputTSetSet temperature of chiller [K]

Modelica definition

block ChillerSwitch "Control unit for enabling/disabling chiller" extends Modelica.Blocks.Icons.Block; Modelica.Blocks.Interfaces.RealInput chiCHWST( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="deg") "Chiller chilled water supply temperature (water entering chiller)"; Modelica.Blocks.Interfaces.BooleanOutput y "Control signal for chiller. 1: Enable, 0: Disable"; Modelica.Blocks.Interfaces.RealInput TSet( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="deg") "Set temperature of chiller"; parameter Modelica.SIunits.Temperature deaBan "Dead band of temperature to prevent chiller short cycling"; Modelica.Blocks.Logical.Hysteresis hysteresis(uLow=0, uHigh=deaBan); Modelica.Blocks.Math.Add add(k1=+1, k2=-1); equation connect(hysteresis.y, y); connect(chiCHWST, add.u1); connect(TSet, add.u2); connect(add.y, hysteresis.u); end ChillerSwitch;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.KMinusU Buildings.Examples.ChillerPlant.BaseClasses.Controls.KMinusU

Output y=k-u

Buildings.Examples.ChillerPlant.BaseClasses.Controls.KMinusU

Information

This component computes the value of

y = k - u.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
Realk Sum of u and y

Connectors

TypeNameDescription
input RealInputuInput
output RealOutputyOutput

Modelica definition

block KMinusU "Output y=k-u" extends Modelica.Blocks.Icons.Block; public parameter Real k "Sum of u and y"; Modelica.Blocks.Interfaces.RealInput u "Input"; Modelica.Blocks.Interfaces.RealOutput y "Output"; equation y = k - u; end KMinusU;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.LinearPiecewiseTwo Buildings.Examples.ChillerPlant.BaseClasses.Controls.LinearPiecewiseTwo

A two-pieces linear piecewise function

Buildings.Examples.ChillerPlant.BaseClasses.Controls.LinearPiecewiseTwo

Information

This component calcuates the output according to two piecewise linear function as

u ∈ [x0, x1]: y1 = y10 + u (y11-y10)/(x1-x0)
y2 = y20
u ∈ (x1, x2]: y1 = y11
y2 = y20 + (u-x1) (y21-y20)/(x2-x1)

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
Realx0 First interval [x0, x1]
Realx1 First interval [x0, x1] and second interval (x1, x2]
Realx2 Second interval (x1, x2]
Realy10 y[1] at u = x0
Realy11 y[1] at u = x1
Realy20 y[2] at u = x1
Realy21 y[2] at u = x2

Connectors

TypeNameDescription
input RealInputuSet point
output RealOutputy[2]Connectors of Real output signal

Modelica definition

block LinearPiecewiseTwo "A two-pieces linear piecewise function" extends Modelica.Blocks.Icons.Block; parameter Real x0 "First interval [x0, x1]"; parameter Real x1 "First interval [x0, x1] and second interval (x1, x2]"; parameter Real x2 "Second interval (x1, x2]"; parameter Real y10 "y[1] at u = x0"; parameter Real y11 "y[1] at u = x1"; parameter Real y20 "y[2] at u = x1"; parameter Real y21 "y[2] at u = x2"; Modelica.Blocks.Interfaces.RealInput u "Set point"; Modelica.Blocks.Interfaces.RealOutput y[2] "Connectors of Real output signal"; Buildings.Controls.SetPoints.Table y1Tab(table=[x0, y10; x1, y11; x2, y11]) "Table for y[1]"; Buildings.Controls.SetPoints.Table y2Tab(table=[x0, y20; x1, y20; x2, y21]) "Table for y[2]"; equation connect(u, y1Tab.u); connect(u, y2Tab.u); connect(y1Tab.y, y[1]); connect(y2Tab.y, y[2]); end LinearPiecewiseTwo;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.RequestCounter Buildings.Examples.ChillerPlant.BaseClasses.Controls.RequestCounter

Count the number of actuators that have request

Buildings.Examples.ChillerPlant.BaseClasses.Controls.RequestCounter

Information

This model counts the number of requests sent by actuators. A request is triggerred when an input singal uAct[i] is larger than uTri.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
IntegernAct Number of actuators
RealuTri Value to trigger a request from actuator

Connectors

TypeNameDescription
output IntegerOutputnIncNumber of actuators requesting control signal increase
input RealInputuAct[nAct]Input signal from actuators

Modelica definition

block RequestCounter "Count the number of actuators that have request" extends Modelica.Blocks.Icons.Block; parameter Integer nAct "Number of actuators"; parameter Real uTri "Value to trigger a request from actuator"; Modelica.Blocks.Interfaces.IntegerOutput nInc "Number of actuators requesting control signal increase"; Modelica.Blocks.Interfaces.RealInput uAct[nAct] "Input signal from actuators"; algorithm nInc := 0; for i in 1:nAct loop if uAct[i] > uTri then nInc := nInc + 1; end if; end for; end RequestCounter;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond

Trim and respond logic

Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond

Information

This model implements the trim and respond logic. The model samples the outputs of actuators every tSam. The control sequence is as follows:

Extends from Modelica.Blocks.Interfaces.DiscreteSISO (Single Input Single Output discrete control block).

Parameters

TypeNameDefaultDescription
TimesamplePeriod Sample period of component [s]
TimestartTime0First sample time instant [s]
RealuTri Value to triggering the request for actuator
RealyEqu0 y setpoint when equipment starts
RealyDec y decrement (must be negative)
RealyInc y increment (must be positive)

Connectors

TypeNameDescription
input RealInputuContinuous input signal
output RealOutputyContinuous output signal

Modelica definition

block TrimAndRespond "Trim and respond logic" extends Modelica.Blocks.Interfaces.DiscreteSISO(firstTrigger(start=false, fixed=true)); parameter Real uTri "Value to triggering the request for actuator"; parameter Real yEqu0 "y setpoint when equipment starts"; parameter Real yDec(max=0) "y decrement (must be negative)"; parameter Real yInc(min=0) "y increment (must be positive)"; Modelica.Blocks.Logical.GreaterEqualThreshold incY(threshold=0) "Outputs true if y needs to be increased"; Modelica.Blocks.Logical.Switch swi; Sampler sam(samplePeriod=samplePeriod) "Sampler"; Modelica.Blocks.Sources.Constant conYDec(k=yDec) "y decrease"; Modelica.Blocks.Sources.Constant conYInc(k=yInc) "y increase"; UnitDelay uniDel1( y_start=yEqu0, samplePeriod=samplePeriod, startTime=samplePeriod); Modelica.Blocks.Math.Add add; Modelica.Blocks.Nonlinear.Limiter lim(uMax=1, uMin=0) "State limiter"; // The UnitDelay and Sampler is reimplemented to avoid in Dymola 2016 the translation warning // The initial conditions for variables of type Boolean are not fully specified. // Dymola has selected default initial conditions. // Assuming fixed default start value for the discrete non-states: // ...firstTrigger(start = false) // ... protected block UnitDelay extends Modelica.Blocks.Discrete.UnitDelay( firstTrigger(start=false, fixed=true)); end UnitDelay; block Sampler extends Modelica.Blocks.Discrete.Sampler( firstTrigger(start=false, fixed=true)); end Sampler; equation connect(lim.y, y); connect(add.y, lim.u); connect(uniDel1.y, add.u2); connect(incY.y, swi.u2); connect(sam.y, incY.u); connect(lim.y, uniDel1.u); connect(swi.y, add.u1); connect(swi.u3, conYDec.y); connect(conYInc.y, swi.u1); connect(sam.u, u); end TrimAndRespond;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespondContinuousTimeApproximation Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespondContinuousTimeApproximation

Trim and respond logic

Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespondContinuousTimeApproximation

Information

This model implements a continuous time approximation to the trim and respond control algorithm.

Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block TrimAndRespondContinuousTimeApproximation "Trim and respond logic" extends Modelica.Blocks.Interfaces.SISO; Buildings.Controls.Continuous.LimPID conPID( Td=1, yMax=1, yMin=0, reverseAction=true, controllerType=Modelica.Blocks.Types.SimpleController.PI, Ti=120, k=0.1); Modelica.Blocks.Sources.Constant const(k=0); equation connect(const.y, conPID.u_s); connect(conPID.y, y); connect(u, conPID.u_m); end TrimAndRespondContinuousTimeApproximation;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.WSEControl Buildings.Examples.ChillerPlant.BaseClasses.Controls.WSEControl

Control unit for WSE

Buildings.Examples.ChillerPlant.BaseClasses.Controls.WSEControl

Information

This component decides if the WSE is set to on or off. The WSE is enabled when

  1. The WSE has been disabled for at least 20 minutes, and
  2. TWSE_CHWST > 0.9 TWetBul + TTowApp + TWSEApp

The WSE is disabled when

  1. The WSE has been enabled for at least 20 minutes, and
  2. TWSE_CHWRT < 1 + TWSE_CWST

where TWSE_CHWST is the chilled water supply temperature for the WSE, TWetBul is the wet bulb temperature, TTowApp is the cooling tower approach, TWSEApp is the approach for the WSE, TWSE_CHWRT is the chilled water return temperature for the WSE, and TWSE_CWST is the condenser water return temperature for the WSE.

Parameters

TypeNameDefaultDescription
TemperatureDifferencedTOff1Temperature difference to switch WSE off [K]
TemperatureDifferencedTW1Temperature difference that is added to WSE on guard [K]

Connectors

TypeNameDescription
input RealInputwseCHWSTWSE chilled water supply temperature (water entering WSE) [K]
output RealOutputy2Control signal for chiller shutoff valve
input RealInputTWetBulWet bulb temperature [K]
input RealInputtowTAppCooling tower approach [K]
input RealInputwseCWSTWSE condenser water supply temperature (water entering WSE) [K]
output RealOutputy1Control signal for WSE shutoff valve

Modelica definition

model WSEControl "Control unit for WSE" parameter Modelica.SIunits.TemperatureDifference dTOff = 1 "Temperature difference to switch WSE off"; parameter Modelica.SIunits.TemperatureDifference dTW = 1 "Temperature difference that is added to WSE on guard"; Modelica.Blocks.Interfaces.RealInput wseCHWST( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="deg") "WSE chilled water supply temperature (water entering WSE)"; Modelica.Blocks.Interfaces.RealOutput y2 "Control signal for chiller shutoff valve"; Modelica.Blocks.Interfaces.RealInput TWetBul( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="deg") "Wet bulb temperature"; Modelica.Blocks.Interfaces.RealInput towTApp( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="deg") "Cooling tower approach"; Modelica.Blocks.Interfaces.RealInput wseCWST( final quantity="ThermodynamicTemperature", final unit="K", displayUnit="deg") "WSE condenser water supply temperature (water entering WSE)"; Modelica.Blocks.Math.BooleanToReal booToRea2; Modelica.Blocks.Interfaces.RealOutput y1 "Control signal for WSE shutoff valve"; Modelica.StateGraph.InitialStepWithSignal off( nOut=1, nIn=1); Modelica.StateGraph.Transition T1( waitTime=1200, condition=wseCHWST > 0.9*TWetBul + towTApp + dTW, enableTimer=true); Modelica.StateGraph.Step on(nIn=1, nOut=1); Modelica.StateGraph.Transition T2( waitTime=1200, condition=wseCHWST < wseCWST + dTOff, enableTimer=true); Modelica.Blocks.Math.BooleanToReal booToRea1(realTrue=0, realFalse=1); inner Modelica.StateGraph.StateGraphRoot stateGraphRoot "Root of the state graph"; equation connect(booToRea2.y, y2); connect(off.outPort[1], T1.inPort); connect(T1.outPort, on.inPort[1]); connect(on.outPort[1], T2.inPort); connect(T2.outPort, off.inPort[1]); connect(booToRea1.y, y1); connect(off.active, booToRea1.u); connect(off.active, booToRea2.u); end WSEControl;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond.Sampler Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond.Sampler


Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond.Sampler

Information

Extends from Modelica.Blocks.Discrete.Sampler (Ideal sampling of continuous signals).

Parameters

TypeNameDefaultDescription
TimesamplePeriod Sample period of component [s]
TimestartTime0First sample time instant [s]

Connectors

TypeNameDescription
input RealInputuContinuous input signal
output RealOutputyContinuous output signal

Modelica definition

block Sampler extends Modelica.Blocks.Discrete.Sampler( firstTrigger(start=false, fixed=true)); end Sampler;

Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond.UnitDelay Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond.UnitDelay


Buildings.Examples.ChillerPlant.BaseClasses.Controls.TrimAndRespond.UnitDelay

Information

Extends from Modelica.Blocks.Discrete.UnitDelay (Unit Delay Block).

Parameters

TypeNameDefaultDescription
Realy_start0Initial value of output signal
TimesamplePeriod Sample period of component [s]
TimestartTime0First sample time instant [s]

Connectors

TypeNameDescription
input RealInputuContinuous input signal
output RealOutputyContinuous output signal

Modelica definition

block UnitDelay extends Modelica.Blocks.Discrete.UnitDelay( firstTrigger(start=false, fixed=true)); end UnitDelay;