Validation controller model. This example validates

Buildings.Controls.OBC.ASHRAE.G36.AHUs.MultiZone.VAV.Controller.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.MultiZone.VAV.Validation;
model Controller "Validation controller model"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.MultiZone.VAV.Controller conAHU(
    final eneStd=Buildings.Controls.OBC.ASHRAE.G36.Types.EnergyStandard.ASHRAE90_1,
    final venStd=Buildings.Controls.OBC.ASHRAE.G36.Types.VentilationStandard.ASHRAE62_1,
    final ashCliZon=Buildings.Controls.OBC.ASHRAE.G36.Types.ASHRAEClimateZone.Zone_4B,
    final minOADes=Buildings.Controls.OBC.ASHRAE.G36.Types.OutdoorAirSection.DedicatedDampersAirflow,
    final buiPreCon=Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefDamper,
    final ecoHigLimCon=Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.FixedDryBulb,
    final VUncDesOutAir_flow=0.05,
    final VDesTotOutAir_flow=0.05) "Multizone VAV AHU controller"

  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup(
    final height=4,
    final duration=3600,
    final offset=273.15 + 14) "AHU supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp VOut_flow(
    final duration=1800,
    final offset=0.02,
    final height=0.0168)
    "Measured outdoor airflow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TMixMea(
    final height=4,
    final duration=1,
    final offset=273.15 + 2,
    final startTime=0)
    "Measured mixed air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin TOut(
    final amplitude=5,
    final offset=18 + 273.15,
    final freqHz=1/3600) "Outdoor air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin ducStaPre(
    final offset=200,
    final amplitude=150,
    final freqHz=1/3600) "Duct static pressure"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine2(
    final offset=3,
    final amplitude=2,
    final freqHz=1/9600) "Duct static pressure setpoint reset requests"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine3(
    final amplitude=6,
    final freqHz=1/9600)
    "Maximum supply temperature setpoint reset"
  Buildings.Controls.OBC.CDL.Reals.Abs abs2
    "Block generates absolute value of input"
  Buildings.Controls.OBC.CDL.Reals.Abs abs3
    "Block generates absolute value of input"
  Buildings.Controls.OBC.CDL.Reals.Round round3(n=0)
    "Round real number to given digits"
  Buildings.Controls.OBC.CDL.Reals.Round round4(n=0)
    "Round real number to given digits"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger ducPreResReq
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger maxSupResReq
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant opeMod(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.occupied)
    "AHU operation mode is occupied"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant sumDesPopBreZon(
    final k=0.0125)
    "Sum of the population component design breathing zone flow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant sumDesAreBreZon(
    final k=0.03)
    "Sum of the area component design breathing zone flow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp vavBoxFlo2(
    final offset=0.08,
    final height=0.02,
    final duration=3600)
    "Ramp signal for generating VAV box flow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp vavBoxFlo1(
    final height=0.05,
    final offset=0.08,
    final duration=3600)
    "Ramp signal for generating VAV box flow rate"
  Buildings.Controls.OBC.CDL.Reals.Add add2
    "System primary airflow rate, equals to the sum of the measured discharged flow rate of all terminal units"
  Buildings.Controls.OBC.CDL.Reals.Sources.Pulse uOutAirFra_max(
    final amplitude=0.005,
    final width=0.25,
    final period=3600,
    final offset=0.015)
    "Maximum zone outdoor air fraction, equals to the maximum of primary outdoor air fraction of all zones"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp dpBui(
    final height=40,
    final offset=0,
    final duration=1800) "Building static presure"
  Buildings.Controls.OBC.CDL.Logical.Not not1
    "Logical not"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse freRes(
    final width=0.95,
    final period=3600)
    "Freeze protection reset"
  Buildings.Controls.OBC.CDL.Logical.Timer timY1(t=2)
    "Return true if equipment commanded on for sufficient time"
  Buildings.Controls.OBC.CDL.Logical.Not notY1
    "Return true if equipment commanded off"
  Buildings.Controls.OBC.CDL.Logical.Timer timNotY1(t=2)
    "Return true if equipment commanded off for sufficient time"
  Buildings.Controls.OBC.CDL.Logical.Latch lat
    "Lock status until equipment commanded off for sufficient time"
equation
  connect(TOut.y, conAHU.TOut)
  connect(ducStaPre.y, conAHU.dpDuc)
  connect(sine2.y, abs3.u)
  connect(abs3.y,round4. u)
  connect(round4.y, ducPreResReq.u)
  connect(sine3.y, abs2.u)
  connect(abs2.y, round3.u)
  connect(round3.y, maxSupResReq.u)
  connect(maxSupResReq.y, conAHU.uZonTemResReq)
  connect(ducPreResReq.y, conAHU.uZonPreResReq)
  connect(TMixMea.y, conAHU.TAirMix)
  connect(VOut_flow.y, conAHU.VAirOut_flow)
  connect(TSup.y, conAHU.TAirSup)
  connect(vavBoxFlo2.y, add2.u1)
  connect(vavBoxFlo1.y, add2.u2)
  connect(uOutAirFra_max.y, conAHU.uOutAirFra_max)
  connect(dpBui.y, conAHU.dpBui)
  connect(freRes.y,not1. u)
  connect(not1.y, conAHU.u1SofSwiRes)
  connect(sumDesPopBreZon.y, conAHU.VSumAdjPopBreZon_flow)
  connect(sumDesAreBreZon.y, conAHU.VSumAdjAreBreZon_flow)
  connect(add2.y, conAHU.VSumZonPri_flow)
  connect(opeMod.y, conAHU.uAhuOpeMod)
  connect(conAHU.y1SupFan, notY1.u)
  connect(conAHU.y1SupFan, timY1.u)
  connect(timNotY1.u, notY1.y)
  connect(timY1.passed, lat.u)
  connect(timNotY1.passed, lat.clr)
  connect(lat.y, conAHU.u1SupFan)
end Controller;


Validation controller model for generating warnng when the climate zone is not specified. This example validates

Buildings.Controls.OBC.ASHRAE.G36.AHUs.MultiZone.VAV.Controller for generating
warning when the climate zone is not specified.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.MultiZone.VAV.Validation;
model Controller_UnspecifiedClimate
  "Validation controller model for generating warnng when the climate zone is not specified"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.MultiZone.VAV.Controller conAHU(
    final eneStd=Buildings.Controls.OBC.ASHRAE.G36.Types.EnergyStandard.ASHRAE90_1,

    final venStd=Buildings.Controls.OBC.ASHRAE.G36.Types.VentilationStandard.ASHRAE62_1,

    final ashCliZon=Buildings.Controls.OBC.ASHRAE.G36.Types.ASHRAEClimateZone.Not_Specified,

    final minOADes=Buildings.Controls.OBC.ASHRAE.G36.Types.OutdoorAirSection.DedicatedDampersAirflow,

    final buiPreCon=Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefDamper,

    final ecoHigLimCon=Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.FixedDryBulb,

    final VUncDesOutAir_flow=0.05,
    final VDesTotOutAir_flow=0.05) "Multizone VAV AHU controller"

  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup(
    final height=4,
    final duration=3600,
    final offset=273.15 + 14) "AHU supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp VOut_flow(
    final duration=1800,
    final offset=0.02,
    final height=0.0168)
    "Measured outdoor airflow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TMixMea(
    final height=4,
    final duration=1,
    final offset=273.15 + 2,
    final startTime=0)
    "Measured mixed air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin TOut(
    final amplitude=5,
    final offset=18 + 273.15,
    final freqHz=1/3600) "Outdoor air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin ducStaPre(
    final offset=200,
    final amplitude=150,
    final freqHz=1/3600) "Duct static pressure"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine2(
    final offset=3,
    final amplitude=2,
    final freqHz=1/9600) "Duct static pressure setpoint reset requests"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine3(
    final amplitude=6,
    final freqHz=1/9600)
    "Maximum supply temperature setpoint reset"
  Buildings.Controls.OBC.CDL.Reals.Abs abs2
    "Block generates absolute value of input"
  Buildings.Controls.OBC.CDL.Reals.Abs abs3
    "Block generates absolute value of input"
  Buildings.Controls.OBC.CDL.Reals.Round round3(n=0)
    "Round real number to given digits"
  Buildings.Controls.OBC.CDL.Reals.Round round4(n=0)
    "Round real number to given digits"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger ducPreResReq
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger maxSupResReq
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant opeMod(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.occupied)
    "AHU operation mode is occupied"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant sumDesPopBreZon(
    final k=0.0125)
    "Sum of the population component design breathing zone flow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant sumDesAreBreZon(
    final k=0.03)
    "Sum of the area component design breathing zone flow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp vavBoxFlo2(
    final offset=0.08,
    final height=0.02,
    final duration=3600)
    "Ramp signal for generating VAV box flow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp vavBoxFlo1(
    final height=0.05,
    final offset=0.08,
    final duration=3600)
    "Ramp signal for generating VAV box flow rate"
  Buildings.Controls.OBC.CDL.Reals.Add add2
    "System primary airflow rate, equals to the sum of the measured discharged flow rate of all terminal units"
  Buildings.Controls.OBC.CDL.Reals.Sources.Pulse uOutAirFra_max(
    final amplitude=0.005,
    final width=0.25,
    final period=3600,
    final offset=0.015)
    "Maximum zone outdoor air fraction, equals to the maximum of primary outdoor air fraction of all zones"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp dpBui(
    final height=40,
    final offset=0,
    final duration=1800) "Building static presure"
  Buildings.Controls.OBC.CDL.Logical.Not not1
    "Logical not"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse freRes(
    final width=0.95,
    final period=3600)
    "Freeze protection reset"
  Buildings.Controls.OBC.CDL.Logical.Timer timY1(t=2)
    "Return true if equipment commanded on for sufficient time"
  Buildings.Controls.OBC.CDL.Logical.Not notY1
    "Return true if equipment commanded off"
  Buildings.Controls.OBC.CDL.Logical.Timer timNotY1(t=2)
    "Return true if equipment commanded off for sufficient time"
  Buildings.Controls.OBC.CDL.Logical.Latch lat
    "Lock status until equipment commanded off for sufficient time"
equation
  connect(TOut.y, conAHU.TOut)
  connect(ducStaPre.y, conAHU.dpDuc)
  connect(sine2.y, abs3.u)
  connect(abs3.y,round4. u)
  connect(round4.y, ducPreResReq.u)
  connect(sine3.y, abs2.u)
  connect(abs2.y, round3.u)
  connect(round3.y, maxSupResReq.u)
  connect(maxSupResReq.y, conAHU.uZonTemResReq)
  connect(ducPreResReq.y, conAHU.uZonPreResReq)
  connect(TMixMea.y, conAHU.TAirMix)
  connect(VOut_flow.y, conAHU.VAirOut_flow)
  connect(TSup.y, conAHU.TAirSup)
  connect(vavBoxFlo2.y, add2.u1)
  connect(vavBoxFlo1.y, add2.u2)
  connect(uOutAirFra_max.y, conAHU.uOutAirFra_max)
  connect(dpBui.y, conAHU.dpBui)
  connect(freRes.y,not1. u)
  connect(not1.y, conAHU.u1SofSwiRes)
  connect(sumDesPopBreZon.y, conAHU.VSumAdjPopBreZon_flow)
  connect(sumDesAreBreZon.y, conAHU.VSumAdjAreBreZon_flow)
  connect(add2.y, conAHU.VSumZonPri_flow)
  connect(opeMod.y, conAHU.uAhuOpeMod)
  connect(conAHU.y1SupFan,timY1. u)
  connect(timNotY1.u,notY1. y)
  connect(timNotY1.passed,lat. clr)
  connect(lat.y, conAHU.u1SupFan)
  connect(conAHU.y1SupFan, notY1.u)
  connect(timY1.passed, lat.u)
end Controller_UnspecifiedClimate;


Collection of validation models

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.MultiZone.VAV;
package Validation "Collection of validation models"
end Validation;


Sequences for single zone AHU control

within Buildings.Controls.OBC.ASHRAE.G36.AHUs;
package SingleZone "Sequences for single zone AHU control"
end SingleZone;


Single Zone AHU controller that composes subsequences for controlling fan speed, economizer, and supply air temperature. Block for single zone VAV control. It outputs supply fan speed, supply air temperature
setpoints for heating, economizer and cooling, zone air heating and cooling setpoints,
outdoor and return air damper positions, and valve positions of heating and cooling coils.
It is implemented according to the ASHRAE Guideline 36, Section 5.18.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV;
block Controller
  "Single Zone AHU controller that composes subsequences for controlling fan speed, economizer, and supply air temperature"

  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.EnergyStandard eneStd
    "Energy standard, ASHRAE 90.1 or Title 24";
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.VentilationStandard venStd
    "Ventilation standard, ASHRAE 62.1 or Title 24";
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer ecoHigLimCon=Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.FixedDryBulb
    "Economizer high limit control device"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.ASHRAEClimateZone ashCliZon=Buildings.Controls.OBC.ASHRAE.G36.Types.ASHRAEClimateZone.Not_Specified
    "ASHRAE climate zone"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.Title24ClimateZone tit24CliZon=Buildings.Controls.OBC.ASHRAE.G36.Types.Title24ClimateZone.Not_Specified
    "California Title 24 climate zone"
  parameter Boolean have_frePro=true
    "True: enable freeze protection"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeStat freSta=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeStat.No_freeze_stat
    "Type of freeze stat"
  parameter Boolean have_winSen=false
    "Check if the zone has window status sensor"
  parameter Boolean have_occSen=false
    "Check if the zone has occupancy sensor"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.CoolingCoil cooCoi=Buildings.Controls.OBC.ASHRAE.G36.Types.CoolingCoil.WaterBased
    "Cooling coil type"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil heaCoi=Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Heating coil type"
  parameter Boolean have_CO2Sen=true
    "True: the zone has CO2 sensor"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl buiPreCon=
      Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.BarometricRelief
    "Type of building pressure control system"
  parameter Boolean have_ahuRelFan=true
    "True: relief fan is part of AHU; False: the relief fans group that may associate multiple AHUs"
  parameter Real VAreBreZon_flow(unit="m3/s")=0
    "Design area component of the breathing zone outdoor airflow"
  parameter Real VPopBreZon_flow(unit="m3/s")=0
    "Design population component of the breathing zone outdoor airflow"

  // ----------- parameters for setpoint adjustment -----------
  parameter Boolean have_locAdj=true
    "True: the zone has local setpoint adjustment knob"
  parameter Boolean sepAdj=true
    "True: cooling and heating setpoint can be adjusted separately"
  parameter Boolean ignDemLim=true
    "Flag, set to true to exempt individual zone from demand limit setpoint adjustment"
  parameter Real TActCoo_max(
    unit="K",
    displayUnit="degC")=300.15
    "Maximum cooling setpoint during on"
  parameter Real TActCoo_min(
    unit="K",
    displayUnit="degC")=295.15
    "Minimum cooling setpoint during on"
  parameter Real TActHea_max(
    unit="K",
    displayUnit="degC")=295.15
    "Maximum heating setpoint during on"
  parameter Real TActHea_min(
    unit="K",
    displayUnit="degC")=291.15
    "Minimum heating setpoint during on"
  parameter Real TWinOpeCooSet(
    unit="K",
    displayUnit="degC")=322.15
    "Cooling setpoint when window is open"
  parameter Real TWinOpeHeaSet(
    unit="K",
    displayUnit="degC")=277.15
    "Heating setpoint when window is open"
  parameter Real incTSetDem_1(unit="K")=0.5
    "Cooling setpoint increase value (degC) when cooling demand limit level 1 is imposed"
  parameter Real incTSetDem_2(unit="K")=1
    "Cooling setpoint increase value (degC) when cooling demand limit level 2 is imposed"
  parameter Real incTSetDem_3(unit="K")=2
    "Cooling setpoint increase value (degC) when cooling demand limit level 3 is imposed"
  parameter Real decTSetDem_1(unit="K")=0.5
    "Heating setpoint decrease value (degC) when heating demand limit level 1 is imposed"
  parameter Real decTSetDem_2(unit="K")=1
    "Heating setpoint decrease value (degC) when heating demand limit level 2 is imposed"
  parameter Real decTSetDem_3(unit="K")=2
    "Heating setpoint decrease value (degC) when heating demand limit level 3 is imposed"
  parameter Real preWarCooTim(unit="s")=10800
    "Maximum cool-down or warm-up time"
  parameter Real TZonFreProOn(
    unit="K",
    displayUnit="degC")=277.15
    "Threshold temperature to activate the freeze protection mode"
  parameter Real TZonFreProOff(
    unit="K",
    displayUnit="degC")=280.15
    "Threshold temperature to end the freeze protection mode"
  parameter Real bouLim=1
    "Threshold of temperature difference for indicating the end of setback or setup mode"
  parameter Real uLow=-0.1
    "Low limit of the hysteresis for checking temperature difference"
  parameter Real uHigh=0.1
    "High limit of the hysteresis for checking temperature difference"

  // ----------- parameters for cooling and heating loop -----------
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController cooLooCon=
     Buildings.Controls.OBC.CDL.Types.SimpleController.PI "Cooling loop controller type"
  parameter Real kCoo(unit="1/K")=0.1
    "Gain for cooling control loop signal"
  parameter Real TiCoo(unit="s")=900
    "Time constant of integrator block for cooling control loop signal"
  parameter Real TdCoo(unit="s")=0.1
    "Time constant of derivative block for cooling control loop signal"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController heaLooCon=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Heating loop controller type"
  parameter Real kHea(unit="1/K")=0.1
    "Gain for heating control loop signal"
  parameter Real TiHea(unit="s")=900
    "Time constant of integrator block for heating control loop signal"
  parameter Real TdHea(unit="s")=0.1
    "Time constant of derivative block for heating control loop signal"

  // ----------- parameters for supply setpoints settings -----------
  parameter Real TSup_max(
    unit="K",
    displayUnit="degC")=303.15
    "Maximum supply air temperature for heating"
  parameter Real TSup_min(
    unit="K",
    displayUnit="degC")=291.15
    "Minimum supply air temperature for cooling"
  parameter Real TSupDew_max(
    unit="K",
    displayUnit="degC")=290.15
    "Maximum supply air dew-point temperature. It's typically only needed in humid type “A” climates. A typical value is 17°C.
    For mild and dry climates, a high set point (e.g. 24°C) should be entered for maximum efficiency"
  parameter Real TSupDea_min(
    unit="K",
    displayUnit="degC")=294.15
    "Minimum supply temperature when it is in deadband state"
  parameter Real TSupDea_max(
    unit="K",
    displayUnit="degC")=297.15
    "Maximum supply temperature when it is in deadband state"
  parameter Real temPoiOne=0.5
    "Point 1 on x-axis of control map for temperature control, when it is in heating state"
  parameter Real temPoiTwo=0.25
    "Point 2 on x-axis of control map for temperature control, when it is in cooling state"
  parameter Real temPoiThr=0.5
    "Point 3 on x-axis of control map for temperature control, when it is in cooling state"
  parameter Real temPoiFou=0.75
    "Point 4 on x-axis of control map for temperature control, when it is in cooling state"
  parameter Real maxHeaSpe(unit="1")=1
    "Maximum fan speed for heating"
  parameter Real maxCooSpe(unit="1")=1
    "Maximum fan speed for cooling"
  parameter Real minSpe(unit="1")=0.1
    "Minimum fan speed"
  parameter Real spePoiOne=0.5
    "Point 1 on x-axis of control map for speed control, when it is in heating state"
  parameter Real spePoiTwo=0.25
    "Point 2 on x-axis of control map for speed control, when it is in cooling state"
  parameter Real spePoiThr=0.5
    "Point 3 on x-axis of control map for speed control, when it is in cooling state"
  parameter Real spePoiFou=0.75
    "Point 4 on x-axis of control map for speed control, when it is in cooling state"
  parameter Real looHys=0.05
    "Loop output hysteresis below which the output will be seen as zero"

  // ----------- parameters for minimum outdoor airflow setpoints -----------
  parameter Boolean permit_occStandby=true
    "True: occupied-standby mode is permitted"
  parameter Real zonDisEff_cool=1.0
    "Zone cooling air distribution effectiveness"
  parameter Real zonDisEff_heat=0.8
    "Zone heating air distribution effectiveness"
  parameter Real VOccMin_flow=0
    "Zone minimum outdoor airflow for occupants"
  parameter Real VAreMin_flow=0
    "Zone minimum outdoor airflow for building area"
  parameter Real VZonMin_flow=0
    "Design zone minimum airflow setpoint"

  // ----------- parameters for economizer control -----------
  parameter Real uMin(unit="1")=0.1
    "Lower limit of controller output at which the dampers are at their limits"
  parameter Real uMax(unit="1")=0.9
    "Upper limit of controller output at which the dampers are at their limits"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController ecoModCon=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"
  parameter Real kMod=1 "Gain of modulation controller"
  parameter Real TiMod(unit="s")=300
    "Time constant of modulation controller integrator block"
  parameter Real TdMod(unit="s")=0.1
    "Time constant of derivative block for modulation controller"
  parameter Real supFanSpe_min(unit="1")=0.1
    "Minimum supply fan operation speed"
  parameter Real supFanSpe_max(unit="1")=0.9
    "Maximum supply fan operation speed"
  parameter Real VOutMin_flow(unit="m3/s")=1.0
    "Calculated minimum outdoor airflow rate"
  parameter Real VOutDes_flow(unit="m3/s")=2.0
    "Calculated design outdoor airflow rate"
  parameter Real outDamMinFloMinSpe(unit="1")=0.4
    "Outdoor air damper position to supply minimum outdoor airflow at minimum fan speed"
  parameter Real outDamMinFloMaxSpe(unit="1")=0.3
    "Outdoor air damper position to supply minimum outdoor airflow at maximum fan speed"
  parameter Real outDamDesFloMinSpe(unit="1")=0.9
    "Outdoor air damper position to supply design outdoor airflow at minimum fan speed"
  parameter Real outDamDesFloMaxSpe(unit="1")=0.8
    "Outdoor air damper position to supply design outdoor airflow at maximum fan speed"
  parameter Real outDamPhy_max(unit="1")=1.0
    "Physically fixed maximum position of the outdoor air damper"
  parameter Real outDamPhy_min(unit="1")=0.0
    "Physically fixed minimum position of the outdoor air damper"
  parameter Real retDamPhy_max(unit="1")=1.0
    "Physically fixed maximum position of the return air damper"
  parameter Real retDamPhy_min(unit="1")=0.0
    "Physically fixed minimum position of the return air damper"
  parameter Real delTOutHys(
    unit="K",
    displayUnit="K")=1
    "Delta between the temperature hysteresis high and low limit"

  // ----------- parameters for cooling coil control -----------
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController cooCoiCon=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"
  parameter Real kCooCoi(unit="1/K")=0.1
    "Gain for cooling coil control loop signal"
  parameter Real TiCooCoi(unit="s")=900
    "Time constant of integrator block for cooling coil control loop signal"
  parameter Real TdCooCoi(unit="s")=0.1
    "Time constant of derivative block for cooling coil control loop signal"

  // ----------- parameters for freeze protection -----------
  parameter Integer minHotWatReq=2
    "Minimum heating hot-water plant request to active the heating plant"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController freHeaCoiCon=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Heating coil controller"
  parameter Real kFreHea=1 "Gain of coil controller"
  parameter Real TiFreHea(unit="s")=0.5
    "Time constant of integrator block"
  parameter Real TdFreHea(unit="s")=0.1
    "Time constant of derivative block"
  parameter Real yMaxFreHea=1
    "Upper limit of output"
  parameter Real yMinFreHea=0
    "Lower limit of output"

  // ----------- parameters for building pressure control -----------
  parameter Real relDam_min(unit="1")=0.1
    "Relief-damper position that maintains a building pressure of 12 Pa while the economizer damper is positioned to provide minimum outdoor air while the supply fan is at minimum speed"
  parameter Real relDam_max(unit="1")=1
    "Relief-damper position that maintains a building pressure of 12 Pa while the economizer damper is fully open and the fan speed is at cooling maximum"
  parameter Real speDif=-0.1
    "Speed difference between supply and return fan to maintain building pressure at desired pressure"
  parameter Real dpBuiSet(
    unit="Pa",
    displayUnit="Pa")=12
    "Building static pressure difference relative to ambient (positive to pressurize the building)"
  parameter Real relFanSpe_min(
    final min=0,
    final max=1)= 0.1
    "Relief fan minimum speed"
  parameter Real kRelFan(unit="1")=1
    "Gain of relief fan controller, normalized using dpBuiSet"

  // ----------- Advanced -----------
  parameter Real posHys=0.01 "Hysteresis for damper position check"
  parameter Real Thys(unit="K")=0.25
    "Hysteresis for checking temperature difference"
  parameter Real delEntHys(unit="J/kg")=1000
    "Delta between the enthalpy hysteresis high and low limits"
  parameter Real floHys(unit="m3/s")=0.01*VOutMin_flow
    "Near zero flow rate, below which the flow rate or difference will be seen as zero"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TOut(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Outside air temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput cooDowTim(
    final unit="s",
    final quantity="Time")
    "Cool-down time retrieved from optimal cool-down block"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput warUpTim(
    final unit="s",
    final quantity="Time")
    "Warm-up time retrieved from optimal warm-up block"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1Occ
    "Current occupancy period, true if it is in occupant period"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput tNexOcc(
    final unit="s",
    final quantity="Time")
    "Time to next occupied period"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TZon(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Measured zone temperatures"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TOccHeaSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Zone occupied heating setpoint temperatures"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TOccCooSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Zone occupied cooling setpoint temperatures"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TUnoHeaSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Zone unoccupied heating setpoint temperatures"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TUnoCooSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Zone unoccupied cooling setpoint temperatures"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput setAdj
    if have_locAdj and not sepAdj
    "Setpoint adjustment value"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput cooSetAdj
    if have_locAdj and sepAdj
    "Cooling setpoint adjustment value"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput heaSetAdj
    if have_locAdj and sepAdj
    "Heating setpoint adjustment value"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1OccSen if have_occSen
    "Occupancy sensor (occupied=true, unoccupied=false)"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uCooDemLimLev
    "Cooling demand limit level"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uHeaDemLimLev
    "Heating demand limit level"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput ppmCO2Set if have_CO2Sen
    "CO2 concentration setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput ppmCO2 if have_CO2Sen
    "Detected CO2 concentration"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TAirSup(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1Win if have_winSen
    "Window status, normally closed (true), when windows open, it becomes false"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput hOut(
    final unit="J/kg",
    final quantity="SpecificEnergy")
    if (ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.DifferentialEnthalpyWithFixedDryBulb
     or ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.FixedEnthalpyWithFixedDryBulb)
    "Outdoor air enthalpy"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput hAirRet(
    final unit="J/kg",
    final quantity="SpecificEnergy")
    if (eneStd == Buildings.Controls.OBC.ASHRAE.G36.Types.EnergyStandard.ASHRAE90_1
     and ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.DifferentialEnthalpyWithFixedDryBulb)
    "Return air enthalpy"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TAirRet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    if ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.DifferentialDryBulb
    "Used only for fixed plus differential dry bulb temperature high limit cutoff"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1FreSta if freSta ==
    Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeStat.Hardwired_to_BAS
    "Freeze protection stat signal. The stat is normally close (the input is normally true), when enabling freeze protection, the input becomes false"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1SofSwiRes
    if (freSta == Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeStat.No_freeze_stat
     or freSta == Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeStat.Hardwired_to_equipment)
    "Freeze protection reset signal from software switch"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput dpBui(
    final unit="Pa",
    displayUnit="Pa",
    final quantity="PressureDifference") if have_ahuRelFan and buiPreCon ==
    Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefFan
    "Measured building static pressure difference, relative to ambient (positive if pressurized)"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1RelFan if buiPreCon ==
    Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefFan and not
    have_ahuRelFan
    "Relief fan commanded on"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uRelFan(
    final min=0,
    final max=1,
    final unit="1") if buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefFan
     and not have_ahuRelFan
    "Relief fan commanded speed"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TAirMix(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    if heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Measured mixed air temperature, used for freeze protection"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uOutDam(
    final min=0,
    final max=1,
    final unit="1") if buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefDamper
    "Outdoor damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uSupFan_actual(
    final min=0,
    final max=1,
    final unit="1")
    "Actual supply fan speed"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uCooCoi_actual(
    final min=0,
    final max=1,
    final unit="1")
    "Cooling coil valve actual position"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uHeaCoi_actual(
    final min=0,
    final max=1,
    final unit="1")
    if heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Heating coil valve actual position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TSupHeaEcoSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Temperature setpoint for heating coil and for economizer"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TSupCooSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Cooling supply air temperature setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonHeaSet(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Zone heating setpoint temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonCooSet(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Zone cooling setpoint temperature"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput y1EneCHWPum
 if have_frePro
    "Commanded on to energize chilled water pump"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDam(
    final min=0,
    final max=1,
    final unit="1")
    "Return air damper commanded position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDam(
    final min=0,
    final max=1,
    final unit="1")
    "Outdoor air damper commanded position"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput y1SupFan
    "Supply fan commanded on"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput ySupFan(
    final min=0,
    final max=1,
    final unit="1")
    "Supply fan commanded speed"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput y1RetFan if (buiPreCon
     == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanMeasuredAir
     or buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanDp)
    "Return fan commanded on"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetFan(
    final min=0,
    final max=1,
    final unit="1") if (buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanMeasuredAir
     or buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanDp)
    "Return fan commanded speed"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput y1RelFan if buiPreCon ==
    Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefFan
    "Relief fan commanded on"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRelFan(
    final min=0,
    final max=1,
    final unit="1") if buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefFan
    "Relief fan commanded speed"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yCooCoi(
    final min=0,
    final max=1,
    final unit="1") "Cooling coil valve commanded position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yHeaCoi(
    final min=0,
    final max=1,
    final unit="1")
    if heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Heating coil valve commanded position"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yAla if have_frePro
    "Alarm level"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRelDam(
    final min=0,
    final max=1,
    final unit="1") if buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefDamper
     or (have_ahuRelFan and buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefFan)
    "Relief damper commanded position"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput y1ExhDam if (buiPreCon
     == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanMeasuredAir
     or buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanDp)
    "Exhaust damper command on"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yChiWatResReq
    "Chilled water reset request"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yChiPlaReq
    "Chiller plant request"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yHotWatResReq
    if heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Hot water reset request"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yHotWatPlaReq
    if heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Hot water plant request"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.Supply setPoiVAV(
    final TSup_max=TSup_max,
    final TSup_min=TSup_min,
    final TSupDew_max=TSupDew_max,
    final TSupDea_min=TSupDea_min,
    final TSupDea_max=TSupDea_max,
    final maxHeaSpe=maxHeaSpe,
    final maxCooSpe=maxCooSpe,
    final minSpe=minSpe,
    final looHys=looHys,
    final temPoiOne=temPoiOne,
    final temPoiTwo=temPoiTwo,
    final temPoiThr=temPoiThr,
    final temPoiFou=temPoiFou,
    final spePoiOne=spePoiOne,
    final spePoiTwo=spePoiTwo,
    final spePoiThr=spePoiThr,
    final spePoiFou=spePoiFou)
    "Supply air set point and fan signal for single zone VAV system"
  Buildings.Controls.OBC.CDL.Reals.PIDWithReset cooPI(
    final controllerType=cooLooCon,
    final k=kCoo,
    final Ti=TiCoo,
    final Td=TdCoo,
    final reverseActing=false)
    "Zone cooling control signal"
  Buildings.Controls.OBC.CDL.Reals.PIDWithReset heaPI(
    final controllerType=heaLooCon,
    final k=kHea,
    final Ti=TiHea,
    final Td=TdHea)
    "Zone heating control signal"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Controller conEco(
    final eneStd=eneStd,
    final ecoHigLimCon=ecoHigLimCon,
    final ashCliZon=ashCliZon,
    final tit24CliZon=tit24CliZon,
    final have_heaCoi=heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased or heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.Electric,
    final uMin=uMin,
    final uMax=uMax,
    final controllerTypeMod=ecoModCon,
    final kMod=kMod,
    final TiMod=TiMod,
    final TdMod=TdMod,
    final delTOutHys=delTOutHys,
    final delEntHys=delEntHys,
    final floHys=floHys,
    final supFanSpe_min=supFanSpe_min,
    final supFanSpe_max=supFanSpe_max,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    final outDamMinFloMinSpe=outDamMinFloMinSpe,
    final outDamMinFloMaxSpe=outDamMinFloMaxSpe,
    final outDamDesFloMinSpe=outDamDesFloMinSpe,
    final outDamDesFloMaxSpe=outDamDesFloMaxSpe,
    final outDamPhy_max=outDamPhy_max,
    final outDamPhy_min=outDamPhy_min,
    final retDamPhy_max=retDamPhy_max,
    final retDamPhy_min=retDamPhy_min) "Economizer control sequence"
  Buildings.Controls.OBC.ASHRAE.G36.VentilationZones.ASHRAE62_1.Setpoints
    outAirSetPoi(
    final have_winSen=have_winSen,
    final have_occSen=have_occSen,
    final have_CO2Sen=have_CO2Sen,
    final have_SZVAV=true,
    final permit_occStandby=permit_occStandby,
    final VAreBreZon_flow=VAreBreZon_flow,
    final VPopBreZon_flow=VPopBreZon_flow,
    final VMin_flow=0,
    final zonDisEff_cool=zonDisEff_cool,
    final zonDisEff_heat=zonDisEff_heat,
    final dTHys=Thys) if venStd == Buildings.Controls.OBC.ASHRAE.G36.Types.VentilationStandard.ASHRAE62_1
    "Output the minimum outdoor airflow rate setpoint, when using ASHRAE 62.1"
  Buildings.Controls.OBC.ASHRAE.G36.ThermalZones.ZoneStates zonSta "Zone state"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.unoccupied)
    "Unoccupied mode"
  Buildings.Controls.OBC.CDL.Integers.Equal intEqu
    "Check if current operation mode is unoccupied mode"
  Buildings.Controls.OBC.CDL.Logical.Not switch "If in unoccupied mode, switch off"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.ModeAndSetPoints modSetPoi(
    final have_winSen=have_winSen,
    final have_occSen=have_occSen,
    final have_locAdj=have_locAdj,
    final sepAdj=sepAdj,
    final ignDemLim=ignDemLim,
    final TActCoo_max=TActCoo_max,
    final TActCoo_min=TActCoo_min,
    final TActHea_max=TActHea_max,
    final TActHea_min=TActHea_min,
    final TWinOpeCooSet=TWinOpeCooSet,
    final TWinOpeHeaSet=TWinOpeHeaSet,
    final incTSetDem_1=incTSetDem_1,
    final incTSetDem_2=incTSetDem_2,
    final incTSetDem_3=incTSetDem_3,
    final decTSetDem_1=decTSetDem_1,
    final decTSetDem_2=decTSetDem_2,
    final decTSetDem_3=decTSetDem_3,
    final bouLim=bouLim,
    final uLow=uLow,
    final uHigh=uHigh,
    final preWarCooTim=preWarCooTim,
    final TZonFreProOn=TZonFreProOn,
    final TZonFreProOff=TZonFreProOff)
    "Output zone setpoint with operation mode selection"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.CoolingCoil cooCoiVal(
    final controllerTypeCooCoi=cooCoiCon,
    final kCooCoi=kCooCoi,
    final TiCooCoi=TiCooCoi,
    final TdCooCoi=TdCooCoi) "Controller for cooling coil valve"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.FreezeProtection frePro(
    final buiPreCon=buiPreCon,
    final freSta=freSta,
    final heaCoi=heaCoi,
    final minHotWatReq=minHotWatReq,
    final heaCoiCon=freHeaCoiCon,
    final k=kFreHea,
    final Ti=TiFreHea,
    final Td=TdFreHea,
    final yMax=yMaxFreHea,
    final yMin=yMinFreHea,
    final Thys=Thys) "Freeze protection"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.PlantRequests plaReq(
    final heaCoi=heaCoi,
    final Thys=Thys,
    final posHys=posHys) "Plant request"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.ReliefDamper relDam(
    final relDam_min=relDam_min,
    final relDam_max=relDam_max,
    final posHys=posHys) if buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefDamper
    "Relief damper control"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.ReturnFan retFan(
    final speDif=speDif) if (buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanMeasuredAir
     or buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReturnFanDp)
    "Return fan control"
  Buildings.Controls.OBC.CDL.Integers.Switch intSwi
    if heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Hot water plant request"
  Buildings.Controls.OBC.CDL.Integers.GreaterThreshold freProMod
    if heaCoi==Buildings.Controls.OBC.ASHRAE.G36.Types.HeatingCoil.WaterBased
    "Check if it is in freeze protection mode"
  Buildings.Controls.OBC.ASHRAE.G36.VentilationZones.Title24.Setpoints minFlo(
    final have_winSen=have_winSen,
    final have_occSen=have_occSen,
    final have_CO2Sen=have_CO2Sen,
    final have_SZVAV=true,
    final VOccMin_flow=VOccMin_flow,
    final VAreMin_flow=VAreMin_flow,
    final VMin_flow=VZonMin_flow) if venStd == Buildings.Controls.OBC.ASHRAE.G36.Types.VentilationStandard.California_Title_24
    "Output the minimum outdoor airflow rate setpoint, when using Title 24"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.SetPoints.ReliefFan relFanCon(
    final relFanSpe_min=relFanSpe_min,
    final dpBuiSet=dpBuiSet,
    final k=kRelFan) if have_ahuRelFan and buiPreCon == Buildings.Controls.OBC.ASHRAE.G36.Types.PressureControl.ReliefFan
    "Control of relief fan when it is part of AHU"

equation
  connect(modSetPoi.tNexOcc, tNexOcc)
  connect(conEco.TAirSup, TAirSup)
  connect(setPoiVAV.TSupHeaEcoSet, conEco.TSupHeaEcoSet)
  connect(setPoiVAV.TSupHeaEcoSet, TSupHeaEcoSet)
  connect(setPoiVAV.TSupCooSet, TSupCooSet)
  connect(outAirSetPoi.TDis, TAirSup)
  connect(TOut, setPoiVAV.TOut)
  connect(conEco.TOut, setPoiVAV.TOut)
  connect(zonSta.yZonSta, conEco.uZonSta)
  connect(conInt.y, intEqu.u2)
  connect(intEqu.y, switch.u)
  connect(modSetPoi.THeaSet, heaPI.u_s)
  connect(modSetPoi.TCooSet, cooPI.u_s)
  connect(outAirSetPoi.u1Win, u1Win)
  connect(modSetPoi.u1Occ, u1Occ)
  connect(TZon, modSetPoi.TZon)
  connect(TZon, cooPI.u_m)
  connect(conEco.hOut, hOut)
  connect(conEco.TAirRet, TAirRet)
  connect(switch.y, cooCoiVal.u1SupFan)
  connect(zonSta.yZonSta, cooCoiVal.uZonSta)
  connect(cooCoiVal.TAirSup, TAirSup)
  connect(switch.y, conEco.u1SupFan)
  connect(heaPI.y, setPoiVAV.uHea)
  connect(heaPI.y, zonSta.uHea)
  connect(cooPI.y, setPoiVAV.uCoo)
  connect(cooPI.y, zonSta.uCoo)
  connect(switch.y, heaPI.trigger)
  connect(switch.y, cooPI.trigger)
  connect(modSetPoi.TCooSet, TZonCooSet)
  connect(TZon, heaPI.u_m)
  connect(intEqu.u1, modSetPoi.yOpeMod)
  connect(setPoiVAV.TSupCooSet, cooCoiVal.TSupCooSet)
  connect(TZon, setPoiVAV.TZon)
  connect(TZon, outAirSetPoi.TZon)
  connect(warUpTim, modSetPoi.warUpTim)
  connect(u1Win, modSetPoi.u1Win)
  connect(u1OccSen, modSetPoi.u1OccSen)
  connect(modSetPoi.TCooSet, setPoiVAV.TCooSet)
  connect(modSetPoi.THeaSet, setPoiVAV.THeaSet)
  connect(heaSetAdj, modSetPoi.heaSetAdj)
  connect(setAdj, modSetPoi.setAdj)
  connect(u1OccSen, outAirSetPoi.u1Occ)
  connect(outAirSetPoi.ppmCO2, ppmCO2)
  connect(outAirSetPoi.VMinOA_flow, conEco.VOutMinSet_flow)
  connect(conEco.yOutDam_min, frePro.uOutDamPosMin)
  connect(conEco.yOutDam, frePro.uOutDam)
  connect(conEco.yHeaCoi, frePro.uHeaCoi)
  connect(conEco.yRetDam, frePro.uRetDam)
  connect(TAirSup, frePro.TAirSup)
  connect(frePro.u1SofSwiRes, u1SofSwiRes)
  connect(frePro.u1FreSta, u1FreSta)
  connect(setPoiVAV.y, frePro.uSupFan)
  connect(uRelFan, frePro.uRelFan)
  connect(cooCoiVal.yCooCoi, frePro.uCooCoi)
  connect(TAirMix, frePro.TAirMix)
  connect(frePro.y1EneCHWPum, y1EneCHWPum)
  connect(frePro.yRetDam, yRetDam)
  connect(frePro.yOutDam, yOutDam)
  connect(frePro.ySupFan, ySupFan)
  connect(switch.y, relDam.u1SupFan)
  connect(switch.y, retFan.u1SupFan)
  connect(relDam.yRelDam, yRelDam)
  connect(retFan.y1ExhDam, y1ExhDam)
  connect(retFan.uSupFan_actual, uSupFan_actual)
  connect(frePro.yRetFan, yRetFan)
  connect(frePro.yRelFan, yRelFan)
  connect(frePro.yCooCoi, yCooCoi)
  connect(frePro.yHeaCoi, yHeaCoi)
  connect(retFan.yRetFan, frePro.uRetFan)
  connect(frePro.yFreProSta, conEco.uFreProSta)
  connect(TAirSup, plaReq.TAirSup)
  connect(setPoiVAV.TSupCooSet, plaReq.TSupCoo)
  connect(plaReq.uCooCoi_actual, uCooCoi_actual)
  connect(setPoiVAV.TSupHeaEcoSet, plaReq.TSupHeaEco)
  connect(plaReq.uHeaCoi_actual, uHeaCoi_actual)
  connect(plaReq.yChiWatResReq, yChiWatResReq)
  connect(plaReq.yChiPlaReq, yChiPlaReq)
  connect(plaReq.yHotWatResReq, yHotWatResReq)
  connect(freProMod.y, intSwi.u2)
  connect(plaReq.yHotWatPlaReq, intSwi.u3)
  connect(frePro.yFreProSta, freProMod.u)
  connect(frePro.yHotWatPlaReq, intSwi.u1)
  connect(frePro.yAla, yAla)
  connect(intSwi.y, yHotWatPlaReq)
  connect(uOutDam, relDam.uOutDam)
  connect(conEco.yOutDam_min, relDam.uOutDam_min)
  connect(cooSetAdj, modSetPoi.cooSetAdj)
  connect(ppmCO2Set, outAirSetPoi.ppmCO2Set)
  connect(hAirRet, conEco.hAirRet)
  connect(u1Win, minFlo.u1Win)
  connect(u1OccSen, minFlo.u1Occ)
  connect(ppmCO2Set, minFlo.ppmCO2Set)
  connect(ppmCO2, minFlo.ppmCO2)
  connect(cooDowTim, modSetPoi.cooDowTim)
  connect(uCooDemLimLev, modSetPoi.uCooDemLimLev)
  connect(uHeaDemLimLev, modSetPoi.uHeaDemLimLev)
  connect(modSetPoi.yOpeMod, setPoiVAV.uOpeMod)
  connect(modSetPoi.yOpeMod, outAirSetPoi.uOpeMod)
  connect(modSetPoi.yOpeMod, minFlo.uOpeMod)
  connect(modSetPoi.yOpeMod, conEco.uOpeMod)
  connect(modSetPoi.THeaSet, TZonHeaSet)
  connect(TOccHeaSet,modSetPoi.TOccHeaSet)
  connect(TOccCooSet,modSetPoi.TOccCooSet)
  connect(TUnoHeaSet,modSetPoi.TUnoHeaSet)
  connect(TUnoCooSet,modSetPoi.TUnoCooSet)
  connect(minFlo.VMinOA_flow, conEco.VOutMinSet_flow)
  connect(uSupFan_actual, conEco.uSupFan_actual)
  connect(switch.y, frePro.u1SupFan)
  connect(retFan.y1RetFan, frePro.u1RetFan)
  connect(u1RelFan, frePro.u1RelFan)
  connect(frePro.y1RetFan, y1RetFan)
  connect(frePro.y1RelFan, y1RelFan)
  connect(frePro.y1SupFan, y1SupFan)
  connect(relFanCon.y1RelFan, frePro.u1RelFan)
  connect(relFanCon.yRelFan, frePro.uRelFan)
  connect(switch.y, relFanCon.u1SupFan)
  connect(dpBui, relFanCon.dpBui)
  connect(relFanCon.yDam, yRelDam)
end Controller;


within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone;
package VAV "Sequences for single zone VAV AHU control"
end VAV;


Single zone VAV AHU economizer control sequence. Single zone VAV AHU economizer control sequence that calculates
outdoor and return air damper positions based on Section 5.18.5, 5.18.6, 5.18.7, 5.1.17
of ASHRAE Guidline 36, May 2020.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers;
block Controller "Single zone VAV AHU economizer control sequence"

  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.EnergyStandard eneStd
    "Energy standard, ASHRAE 90.1 or Title 24";
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer ecoHigLimCon
    "Economizer high limit control device";
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.ASHRAEClimateZone ashCliZon=Buildings.Controls.OBC.ASHRAE.G36.Types.ASHRAEClimateZone.Not_Specified
    "ASHRAE climate zone"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.Title24ClimateZone tit24CliZon=Buildings.Controls.OBC.ASHRAE.G36.Types.Title24ClimateZone.Not_Specified
    "California Title 24 climate zone"
  parameter Boolean have_heaCoi=true
    "True if the air handling unit has heating coil"
  parameter Real uMin(
    final min=0.1,
    final max=0.9,
    final unit="1") = 0.1
    "Lower limit of controller output at which the dampers are at their limits"
  parameter Real uMax(
    final min=0.1,
    final max=1,
    final unit="1") = 0.9
    "Upper limit of controller output at which the dampers are at their limits"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerTypeMod=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"
  parameter Real kMod(final unit="1/K")=1
    "Gain of modulation controller"
  parameter Real TiMod(
    final unit="s",
    final quantity="Time")=300
    "Time constant of modulation controller integrator block"
  parameter Real TdMod(
    final unit="s",
    final quantity="Time")=0.1
    "Time constant of derivative block for modulation controller"

  parameter Real delTOutHys(
    final unit="K",
    final displayUnit="K",
    final quantity="TemperatureDifference")=1
    "Delta between the temperature hysteresis high and low limit"

  parameter Real delEntHys(
    final unit="J/kg",
    final quantity="SpecificEnergy")=1000
    "Delta between the enthalpy hysteresis high and low limits"
  parameter Real floHys(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=0.01
    "Near zero flow rate, below which the flow rate or difference will be seen as zero"

  parameter Real supFanSpe_min(
    final min=0,
    final max=1,
    final unit="1") = 0.1 "Minimum supply fan operation speed"
  parameter Real supFanSpe_max(
    final min=0,
    final max=1,
    final unit="1") = 0.9
    "Maximum supply fan operation speed"
  parameter Real VOutMin_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=1.0
    "Calculated minimum outdoor airflow rate"
  parameter Real VOutDes_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=2.0
    "Calculated design outdoor airflow rate"
  parameter Real outDamMinFloMinSpe(
    final min=outDamPhy_min,
    final max=outDamPhy_max,
    final unit="1") = 0.4
    "Outdoor air damper position to supply minimum outdoor airflow at minimum fan speed"
  parameter Real outDamMinFloMaxSpe(
    final min=outDamPhy_min,
    final max=outDamPhy_max,
    final unit="1") = 0.3
    "Outdoor air damper position to supply minimum outdoor airflow at maximum fan speed"
  parameter Real outDamDesFloMinSpe(
    final min=outDamMinFloMinSpe,
    final max=outDamPhy_max,
    final unit="1") = 0.9
    "Outdoor air damper position to supply design outdoor airflow at minimum fan speed"
  parameter Real outDamDesFloMaxSpe(
    final min=outDamMinFloMaxSpe,
    final max=outDamPhy_max,
    final unit="1") = 0.8
    "Outdoor air damper position to supply design outdoor airflow at maximum fan speed"
  parameter Real outDamPhy_max(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the outdoor air damper"
  parameter Real outDamPhy_min(
    final min=0,
    final max=1,
    final unit="1") = 0
    "Physically fixed minimum position of the outdoor air damper"
  parameter Real retDamPhy_max(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the return air damper"
  parameter Real retDamPhy_min(
    final min=0,
    final max=1,
    final unit="1") = 0
    "Physically fixed minimum position of the return air damper"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TOut(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Outdoor air temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TAirRet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    if ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.DifferentialDryBulb
    "Used only for fixed plus differential dry bulb temperature high limit cutoff"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput hOut(
    final unit="J/kg",
    final quantity="SpecificEnergy")
    if (ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.DifferentialEnthalpyWithFixedDryBulb
     or ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.FixedEnthalpyWithFixedDryBulb)
    "Outdoor air enthalpy"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput hAirRet(
    final unit="J/kg",
    final quantity="SpecificEnergy")
    if (eneStd == Buildings.Controls.OBC.ASHRAE.G36.Types.EnergyStandard.ASHRAE90_1
     and ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.DifferentialEnthalpyWithFixedDryBulb)
    "Return air enthalpy"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TAirSup(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TSupHeaEcoSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Supply air temperature heating setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput VOutMinSet_flow(
    final min=VOutMin_flow,
    final max=VOutDes_flow,
    final unit="m3/s",
    final quantity="VolumeFlowRate")
    "Minimum outdoor airflow setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uSupFan_actual(
    final min=supFanSpe_min,
    final max=supFanSpe_max,
    final unit="1")
    "Actual supply fan speed"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uZonSta "Zone state signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uFreProSta
    "Freeze protection status"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uOpeMod "AHU operation mode status signal"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1SupFan
    "Supply fan proven on"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDam_min(
    final min=0,
    final max=1,
    final unit="1")
    "Outdoor damper minimum position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yHeaCoi(
    final unit="1",
    final min=0,
    final max=1) if have_heaCoi
    "Heating coil commanded valve position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDam(
    final min=0,
    final max=1,
    final unit="1")
    "Return air damper commanded position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDam(
    final min=0,
    final max=1,
    final unit="1")
    "Outdoor air damper commanded position"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis(
    final use_enthalpy=ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.DifferentialEnthalpyWithFixedDryBulb
                       or ecoHigLimCon == Buildings.Controls.OBC.ASHRAE.G36.Types.ControlEconomizer.FixedEnthalpyWithFixedDryBulb,
    final retDamPhy_max=retDamPhy_max,
    final delTOutHys=delTOutHys,
    final delEntHys=delEntHys,
    final retDamPhy_min=retDamPhy_min)
    "Single zone VAV AHU economizer enable/disable sequence"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
    damLim(
    final supFanSpe_min=supFanSpe_min,
    final supFanSpe_max=supFanSpe_max,
    final outDamPhy_max=outDamPhy_max,
    final outDamPhy_min=outDamPhy_min,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    final outDamMinFloMinSpe=outDamMinFloMinSpe,
    final outDamMinFloMaxSpe=outDamMinFloMaxSpe,
    final outDamDesFloMinSpe=outDamDesFloMinSpe,
    final outDamDesFloMaxSpe=outDamDesFloMaxSpe,
    final floHys=floHys)
    "Single zone VAV AHU economizer minimum outdoor air requirement damper limit sequence"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Modulation
    mod(
    final have_heaCoi=have_heaCoi,
    final controllerType=controllerTypeMod,
    final k=kMod,
    final Ti=TiMod,
    final Td=TdMod,
    final uMin=uMin,
    final uMax=uMax)
    "Single zone VAV AHU economizer damper modulation sequence"
  Buildings.Controls.OBC.ASHRAE.G36.Generic.AirEconomizerHighLimits ecoHigLim(
    final eneStd=eneStd,
    final ecoHigLimCon=ecoHigLimCon,
    final ashCliZon=ashCliZon,
    final tit24CliZon=tit24CliZon) "High limits"
equation
  connect(u1SupFan, enaDis.u1SupFan)
  connect(uFreProSta, enaDis.uFreProSta)
  connect(hOut, enaDis.hOut)
  connect(TOut, enaDis.TOut)
  connect(u1SupFan, damLim.u1SupFan)
  connect(uOpeMod, damLim.uOpeMod)
  connect(uFreProSta, damLim.uFreProSta)
  connect(damLim.yOutDam_max, enaDis.uOutDam_max)
  connect(enaDis.yOutDam_max, mod.uOutDam_max)
  connect(enaDis.yRetDam_max, mod.uRetDam_max)
  connect(damLim.yOutDam_min, mod.uOutDam_min)
  connect(enaDis.yRetDam_min, mod.uRetDam_min)
  connect(uZonSta, enaDis.uZonSta)
  connect(uSupFan_actual, damLim.uSupFan_actual)
  connect(VOutMinSet_flow, damLim.VOutMinSet_flow)
  connect(mod.yHeaCoi, yHeaCoi)
  connect(damLim.yOutDam_min, enaDis.uOutDam_min)
  connect(TAirSup, mod.TSup)
  connect(TSupHeaEcoSet, mod.TSupHeaEcoSet)
  connect(u1SupFan, mod.u1SupFan)
  connect(mod.yRetDam, yRetDam)
  connect(mod.yOutDam, yOutDam)
  connect(damLim.yOutDam_min, yOutDam_min)
  connect(ecoHigLim.TCut, enaDis.TCut)
  connect(ecoHigLim.hCut, enaDis.hCut)
  connect(TAirRet, ecoHigLim.TRet)
  connect(hAirRet, ecoHigLim.hRet)
end Controller;


within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV;
package Economizers "Economizer control of single zone VAV AHU"
end Economizers;


Single zone VAV AHU economizer enable/disable switch. This is a single zone VAV AHU economizer enable/disable sequence
based on Section 5.18.7 and Section 5.1.17 of ASHRAE Guideline 36, May 2020. Additional
conditions included in the sequence are:

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences;
block Enable
  "Single zone VAV AHU economizer enable/disable switch"

  parameter Boolean use_enthalpy = true
    "Set to true to evaluate outdoor air (OA) enthalpy in addition to temperature"
  parameter Real delTOutHys(
    final unit="K",
    final displayUnit="K",
    final quantity="TemperatureDifference")=1
    "Delta between the temperature hysteresis high and low limit"
  parameter Real delEntHys(
    final unit="J/kg",
    final quantity="SpecificEnergy")=1000
    "Delta between the enthalpy hysteresis high and low limits"
  parameter Real retDamPhy_max(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the return air damper"
  parameter Real retDamPhy_min(
    final min=0,
    final max=1,
    final unit="1") = 0
    "Physically fixed minimum position of the return air damper"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TOut(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Outdoor air temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TCut(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "OA temperature high limit cutoff. For differential dry bulb temperature condition use return air temperature measurement"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput hOut(
    final unit="J/kg",
    final quantity="SpecificEnergy") if use_enthalpy
    "Outdoor air enthalpy"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput hCut(
    final unit="J/kg",
    final quantity="SpecificEnergy") if use_enthalpy
    "OA enthalpy high limit cutoff. For differential enthalpy use return air enthalpy measurement"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1SupFan
    "Supply fan on/off status signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uFreProSta
    "Freeze protection stage status signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uZonSta
    "Zone state status signal"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uOutDam_max(
    final unit="1",
    final min=0,
    final max=1)
    "Maximum outdoor air damper position, get from damper position limits sequence"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uOutDam_min(
    final unit="1",
    final min=0,
    final max=1)
    "Minimum outdoor air damper position, get from damper position limits sequence"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDam_max(
    final min=0,
    final max=1,
    final unit="1")
    "Maximum outdoor air damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDam_max(
    final min=retDamPhy_min,
    final max=retDamPhy_max,
    final unit="1")
    "Maximum return air damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDam_min(
    final min=retDamPhy_min,
    final max=retDamPhy_max,
    final unit="1")
    "Minimum return air damper position"

  Buildings.Controls.OBC.CDL.Logical.And andFrePro
    "Logical and that checks freeze protection stage"
  Buildings.Controls.OBC.CDL.Logical.And andEnaDis
    "Logical and that checks freeze protection stage and zone state"
  Buildings.Controls.OBC.CDL.Logical.TrueFalseHold truFalHol(
    trueHoldDuration=600) "10 min on/off delay"

protected
  final parameter Real TOutHigLimCutHig(
    final unit="K",
    final displayUnit="K",
    final quantity="TemperatureDifference") = 0
    "Hysteresis high limit cutoff";
  final parameter Real TOutHigLimCutLow = TOutHigLimCutHig - delTOutHys
    "Hysteresis low limit cutoff";
  final parameter Real hOutHigLimCutHig(
    final unit="J/kg",
    final quantity="SpecificEnergy") = 0
    "Hysteresis block high limit cutoff";
  final parameter Real hOutHigLimCutLow = hOutHigLimCutHig - delEntHys
    "Hysteresis block low limit cutoff";

  Buildings.Controls.OBC.CDL.Logical.Sources.Constant entSubst(
    final k=false) if not use_enthalpy
    "Deactivates outdoor air enthalpy condition if there is no enthalpy sensor"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant retDamPhyMin(
    final k=retDamPhy_min)
    "Physically fixed minimum position of the return air damper"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant retDamPhyMax(
    final k=retDamPhy_max)
    "Physically fixed maximum position of the return air damper. This is the initial condition of the return air damper"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysOutTem(
    final uHigh=TOutHigLimCutHig,
    final uLow=TOutHigLimCutLow)
    "Outdoor air temperature hysteresis for fixed or differential dry bulb temperature cutoff conditions"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysOutEnt(
    final uLow=hOutHigLimCutLow,
    final uHigh=hOutHigLimCutHig) if use_enthalpy
    "Outdoor air enthalpy hysteresis for fixed or differential enthalpy cutoff conditions"
  Buildings.Controls.OBC.CDL.Reals.Subtract sub2 if use_enthalpy
    "Add block that determines the difference between hOut and hOutCut"
  Buildings.Controls.OBC.CDL.Reals.Subtract sub1
    "Add block that determines difference the between TOut and TOutCut"
  Buildings.Controls.OBC.CDL.Reals.Switch maxOutDam
    "Set maximum OA damper position to minimum at disable (after time delay)"
  Buildings.Controls.OBC.CDL.Reals.Switch minRetDam
    "Keep minimum RA damper position at physical maximum for a short time period after disable"
  Buildings.Controls.OBC.CDL.Logical.Not not2
    "Logical not that starts the timer at disable signal "
  Buildings.Controls.OBC.CDL.Logical.And and1 "Logical and checks supply fan status"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage0)
    "Freeze protection stage 0"
  Buildings.Controls.OBC.CDL.Integers.Equal intEqu
    "Logical block to check if the freeze protection is deactivated"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt1(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.ZoneStates.heating)
    "Heating zone state"
  Buildings.Controls.OBC.CDL.Integers.Equal intEqu1
    "Logical block to check if the freeze protection is deactivated"
  Buildings.Controls.OBC.CDL.Logical.Not not3
    "Negation for check of freeze protection status"
  Buildings.Controls.OBC.CDL.Logical.Or or2
    "Check if either the temperature or the enthalpy condition is satisfied"

equation
  connect(maxOutDam.y, yOutDam_max)
  connect(TOut, sub1.u1)
  connect(TCut, sub1.u2)
  connect(sub1.y, hysOutTem.u)
  connect(hOut, sub2.u1)
  connect(hCut, sub2.u2)
  connect(sub2.y, hysOutEnt.u)
  connect(uOutDam_min, maxOutDam.u1)
  connect(uOutDam_max, maxOutDam.u3)
  connect(andEnaDis.y, not2.u)
  connect(minRetDam.y, yRetDam_min)
  connect(truFalHol.y, and1.u1)
  connect(u1SupFan, and1.u2)
  connect(retDamPhyMax.y, minRetDam.u1)
  connect(retDamPhyMin.y, minRetDam.u3)
  connect(retDamPhyMax.y, yRetDam_max)
  connect(not2.y, minRetDam.u2)
  connect(not2.y, maxOutDam.u2)
  connect(conInt.y,intEqu. u2)
  connect(conInt1.y,intEqu1. u2)
  connect(intEqu1.y,not3. u)
  connect(uZonSta, intEqu1.u1)
  connect(uFreProSta, intEqu.u1)
  connect(hysOutTem.y, or2.u1)
  connect(hysOutEnt.y, or2.u2)
  connect(entSubst.y, or2.u2)
  connect(or2.y, truFalHol.u)
  connect(not3.y, andFrePro.u2)
  connect(andFrePro.u1, intEqu.y)
  connect(and1.y, andEnaDis.u1)
  connect(andEnaDis.u2, andFrePro.y)
end Enable;


Single zone VAV AHU minimum outdoor air control - damper position limits. This block implements the single zone VAV AHU minimum outdoor air control with a single
common damper for minimum outdoor air and economizer functions based on outdoor airflow
setpoint (VOutMinSet_flow) and supply fan speed (uSupFanSpe_actual),
designed in line with Section 5.18.6 of ASHRAE Guidline 36, May 2020.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences;
block Limits "Single zone VAV AHU minimum outdoor air control - damper position limits"

  parameter Real supFanSpe_min(
    final min=0,
    final max=1,
    final unit="1") = 0.1 "Minimum supply fan operation speed"
  parameter Real supFanSpe_max(
    final min=0,
    final max=1,
    final unit="1") = 1 "Maximum supply fan operation speed"
  parameter Real outDamMinFloMinSpe(
    final min=outDamPhy_min,
    final max=outDamPhy_max,
    final unit="1") = 0.4
    "OA damper position to supply minimum outdoor airflow at minimum fan speed"
  parameter Real outDamMinFloMaxSpe(
    final min=outDamPhy_min,
    final max=outDamPhy_max,
    final unit="1") = 0.3
    "OA damper position to supply minimum outdoor airflow at maximum fan speed"
  parameter Real outDamDesFloMinSpe(
    final min=outDamMinFloMinSpe,
    final max=outDamPhy_max,
    final unit="1") = 0.9
    "OA damper position to supply design outdoor airflow at minimum fan speed"
  parameter Real outDamDesFloMaxSpe(
    final min=outDamMinFloMaxSpe,
    final max=outDamPhy_max,
    final unit="1") = 0.8
    "OA damper position to supply design outdoor airflow at maximum fan speed"
  parameter Real VOutMin_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate") "Calculated minimum outdoor airflow rate"
  parameter Real VOutDes_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")
    "Calculated design outdoor airflow rate"
  parameter Real outDamPhy_max(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the outdoor air damper"
  parameter Real outDamPhy_min(
    final min=0,
    final max=1,
    final unit="1") = 0
    "Physically fixed minimum position of the outdoor air damper"
  parameter Real floHys(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=0.01
    "Near zero flow rate, below which the flow rate or difference will be seen as zero"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput uSupFan_actual(
    final min=0,
    final max=1,
    final unit="1")
    "Actual supply fan speed"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput VOutMinSet_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate",
    final min=VOutMin_flow,
    final max=VOutDes_flow)
    "Minimum outdoor airflow setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uOpeMod
    "AHU operation mode status signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uFreProSta
    "Freeze protection status signal"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1SupFan
    "Supply fan status signal"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDam_min(
    final min=outDamPhy_min,
    final max=outDamPhy_max,
    final unit="1") "Minimum outdoor air damper position limit"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDam_max(
    final min=outDamPhy_min,
    final max=outDamPhy_max,
    final unit="1") "Maximum outdoor air damper position limit"

protected
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yFanMinSig(
    final k=supFanSpe_min) "Minimum supply fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPhyPosMinSig(
    final k=outDamPhy_min)
    "Physically fixed minimum position of the outdoor air damper"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPhyPosMaxSig(
    final k=outDamPhy_max)
    "Physically fixed maximum position of the outdoor air damper"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yFanMaxSig(
    final k=supFanSpe_max) "Maximum supply fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutMin_minSpeSig(
    final k=outDamMinFloMinSpe)
    "OA damper position to supply minimum outdoor airflow at minimum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutDes_minSpeSig(
    final k=outDamDesFloMinSpe)
    "OA damper position to supply design outdoor airflow at minimum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutMin_maxSpeSig(
    final k=outDamMinFloMaxSpe)
    "OA damper position to supply minimum outdoor airflow at maximum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutDes_maxSpeSig(
    final k=outDamDesFloMaxSpe)
    "OA damper position to supply design outdoor airflow at maximum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant minVOutSig(
    final k=VOutMin_flow) "Minimum outdoor airflow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant desVOutSig(
    final k=VOutDes_flow) "Design outdoor airflow rate"
  Buildings.Controls.OBC.CDL.Reals.Line yDam_VOutMin_curSpe(
    final limitBelow=true,
    final limitAbove=true)
    "Calculates OA damper position required to supply minimum outdoor airflow at current fan speed"
  Buildings.Controls.OBC.CDL.Reals.Line yDam_VOutDes_curSpe(
    final limitBelow=true,
    final limitAbove=true)
    "Calculates OA damper position required to supply design outdoor airflow at current fan speed"
  Buildings.Controls.OBC.CDL.Reals.Line minVOutSetCurFanSpePos(
    final limitBelow=true,
    final limitAbove=true)
    "Calculates OA damper position required to supply minimum outdoor airflow setpoint at current fan speed"
  Buildings.Controls.OBC.CDL.Reals.Switch enaDis
    "Logical switch to enable damper position limit calculation or disable it (set min limit to physical minimum)"
  Buildings.Controls.OBC.CDL.Logical.Not not1 "Logical not block"
  Buildings.Controls.OBC.CDL.Reals.Switch enaDis1
    "Logical switch to enable damper position limit calculation or disable it (set max limit to physical minimum)"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage1)
    "Freeze protection stage 1"
  Buildings.Controls.OBC.CDL.Integers.LessEqual intLesEqu
    "Check if freeze protection stage is stage 0"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt1(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.occupied)
    "Occupied mode index"
  Buildings.Controls.OBC.CDL.Integers.Equal intEqu1 "Check if operation mode is occupied"
  Buildings.Controls.OBC.CDL.Logical.And and1 "Logical and"
  Buildings.Controls.OBC.CDL.Logical.And and2 "Logical and"
  Buildings.Controls.OBC.CDL.Reals.Switch enaDis2
    "Zero minimum damper position when the min OA is near zero"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zer(
    final k=0)
    "Zero minimum damper position"
  Buildings.Controls.OBC.CDL.Reals.GreaterThreshold noZerMin(
    final t=floHys,
    final h=0.5*floHys) "Check if the min OA is greater than zero"

equation
  connect(minVOutSig.y, minVOutSetCurFanSpePos.x1)
  connect(desVOutSig.y, minVOutSetCurFanSpePos.x2)
  connect(yDam_VOutMin_curSpe.y, minVOutSetCurFanSpePos.f1)
  connect(yDam_VOutDes_curSpe.y, minVOutSetCurFanSpePos.f2)
  connect(yDam_VOutDes_minSpeSig.y, yDam_VOutDes_curSpe.f1)
  connect(yDam_VOutDes_maxSpeSig.y, yDam_VOutDes_curSpe.f2)
  connect(yDam_VOutMin_minSpeSig.y, yDam_VOutMin_curSpe.f1)
  connect(yDam_VOutMin_maxSpeSig.y, yDam_VOutMin_curSpe.f2)
  connect(uSupFan_actual, yDam_VOutMin_curSpe.u)
  connect(yFanMaxSig.y, yDam_VOutMin_curSpe.x2)
  connect(yFanMinSig.y, yDam_VOutMin_curSpe.x1)
  connect(yFanMinSig.y, yDam_VOutDes_curSpe.x1)
  connect(yFanMaxSig.y, yDam_VOutDes_curSpe.x2)
  connect(VOutMinSet_flow, minVOutSetCurFanSpePos.u)
  connect(uSupFan_actual, yDam_VOutDes_curSpe.u)
  connect(not1.y, enaDis.u2)
  connect(outDamPhyPosMinSig.y, enaDis.u1)
  connect(minVOutSetCurFanSpePos.y, enaDis.u3)
  connect(outDamPhyPosMinSig.y, enaDis1.u1)
  connect(outDamPhyPosMaxSig.y, enaDis1.u3)
  connect(enaDis1.y, yOutDam_max)
  connect(not1.y, enaDis1.u2)
  connect(uOpeMod, intEqu1.u1)
  connect(conInt1.y, intEqu1.u2)
  connect(intLesEqu.u2, conInt.y)
  connect(uFreProSta, intLesEqu.u1)
  connect(and2.y, not1.u)
  connect(VOutMinSet_flow, noZerMin.u)
  connect(noZerMin.y, enaDis2.u2)
  connect(enaDis.y, enaDis2.u1)
  connect(enaDis2.y, yOutDam_min)
  connect(zer.y, enaDis2.u3)

  connect(intLesEqu.y, and1.u1)
  connect(and1.u2, intEqu1.y)
  connect(and1.y, and2.u2)
  connect(u1SupFan, and2.u1)
end Limits;


Outdoor and return air damper position modulation sequence for single zone VAV AHU. This is a single zone VAV AHU economizer modulation block. It calculates
the outdoor and return air damper positions based on the single zone VAV AHU
supply air temperature control loop signal. Economizer dampers are modulated
based on the calculated heating supply air temperature setpoint.
The implementation is in line with Section 5.18.5.1 and 5.18.5.2 of ASHRAE
Guidline 36, May 2020.
Damper positions are linearly mapped to
the supply air control loop signal. This is a final sequence in the
composite single zone VAV AHU economizer control sequence. Damper position
limits, which are the inputs to the sequence, are the outputs of

Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits and

Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
sequences.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences;
block Modulation "Outdoor and return air damper position modulation sequence for single zone VAV AHU"

  parameter Boolean have_heaCoi = true
    "True if the air handling unit has heating coil"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerType=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"
  parameter Real k(
    final unit="1/K") = 1 "Gain of controller";
  parameter Real Ti(
    final unit="s",
    final quantity="Time")=300
    "Time constant of modulation controller integrator block"
  parameter Real Td(
    final unit="s",
    final quantity="Time")=0.1
    "Time constant of derivative block for cooling control loop signal"

  parameter Real uMin(
    final min=0.1,
    final max=0.9,
    final unit="1") = 0.1
    "Lower limit of controller output uTSup at which the dampers are at their limits"
  parameter Real uMax(
    final min=0.1,
    final max=1,
    final unit="1") = 0.9
    "Upper limit of controller output uTSup at which the dampers are at their limits"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TSup(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TSupHeaEcoSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Supply air temperature heating setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput u1SupFan
    "Supply fan status"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uOutDam_min(
    final min=0,
    final max=1,
    final unit="1")
    "Minimum economizer damper position limit as returned by the damper position limits sequence"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uOutDam_max(
    final min=0,
    final max=1,
    final unit="1") "Maximum economizer damper position limit as returned by the economizer enable-disable sequence.
    If the economizer is disabled, this value equals uOutDamPosMin"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uRetDam_min(
    final min=0,
    final max=1,
    final unit="1")
    "Minimum return air damper position limit as returned by the economizer enable-disable sequence"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uRetDam_max(
    final min=0,
    final max=1,
    final unit="1")
    "Maximum return air damper position limit as returned by the economizer enable-disable sequence"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yHeaCoi(
    final min=0,
    final max=1,
    final unit="1") if have_heaCoi "Heating coil commanded valve position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDam(
    final min=0,
    final max=1,
    final unit="1") "Economizer damper commanded position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDam(
    final min=0,
    final max=1,
    final unit="1") "Return air damper commanded position"

  Buildings.Controls.OBC.CDL.Reals.PIDWithReset uTSup(
    final controllerType=controllerType,
    final k=k,
    final Ti=Ti,
    final Td=Td,
    final yMax=1,
    final yMin=0)
    "Contoller that outputs a signal based on the error between the measured SAT and SAT heating setpoint"

protected
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamMinLimSig(
    final k=uMin) "Minimal control loop signal for the outdoor air damper"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant retDamMaxLimSig(
    final k=uMax) "Maximal control loop signal for the return air damper"

  Buildings.Controls.OBC.CDL.Reals.Line outDamPos(
    final limitBelow=true,
    final limitAbove=true)
    "Damper position is linearly proportional to the control signal between signal limits"
  Buildings.Controls.OBC.CDL.Reals.Line retDamPos(
    final limitBelow=true,
    final limitAbove=true)
    "Damper position is linearly proportional to the control signal between signal limits"
  Buildings.Controls.OBC.CDL.Reals.Line HeaCoi(
    final limitBelow=true,
    final limitAbove=true) if have_heaCoi
    "Heating coil signal is linearly proportional to the control signal between signal limits"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant heaCoiMaxLimSig(
    final k=1) if have_heaCoi
    "Maximal control loop signal for the heating coil"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant heaCoiMinLimSig(
    final k=0) if have_heaCoi
    "Minimum control loop signal for the heating coil"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant uMaxHeaCoi(
    final k=1)
    "Maximal control loop signal for the heating coil"
  Buildings.Controls.OBC.CDL.Reals.Switch enaDis if have_heaCoi
    "Enable or disable the heating coil"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant Off(
    final k=0) if have_heaCoi
    "Off signal for heating coil"

equation
  connect(retDamMaxLimSig.y,retDamPos. x2)
  connect(uTSup.y, retDamPos.u)
  connect(uTSup.y, outDamPos.u)
  connect(outDamMinLimSig.y, outDamPos.x1)
  connect(retDamMaxLimSig.y, outDamPos.x2)
  connect(outDamMinLimSig.y, retDamPos.x1)
  connect(HeaCoi.u, retDamPos.u)
  connect(TSupHeaEcoSet, uTSup.u_s)
  connect(TSup, uTSup.u_m)
  connect(heaCoiMinLimSig.y, HeaCoi.f1)
  connect(heaCoiMaxLimSig.y, HeaCoi.f2)
  connect(retDamMaxLimSig.y, HeaCoi.x1)
  connect(uMaxHeaCoi.y, HeaCoi.x2)
  connect(uOutDam_min, outDamPos.f2)
  connect(uRetDam_min, retDamPos.f1)
  connect(uRetDam_max, retDamPos.f2)
  connect(Off.y, enaDis.u3)
  connect(u1SupFan, enaDis.u2)
  connect(HeaCoi.y, enaDis.u1)
  connect(enaDis.y, yHeaCoi)
  connect(uOutDam_max, outDamPos.f1)
  connect(retDamPos.y, yRetDam)
  connect(outDamPos.y, yOutDam)
  connect(u1SupFan, uTSup.trigger)
end Modulation;


Subsequences for economizer control

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers;
package Subsequences "Subsequences for economizer control"
end Subsequences;


Model validates economizer disable for heating zone state and activated freeze protection. This example validates

Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
for the zone state and freeze protection stage control signals.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Validation;
model Enable_FreProSta_ZonSta
  "Model validates economizer disable for heating zone state and activated freeze protection"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis "Single zone VAV AHU enable disable sequence"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis1 "Single zone VAV AHU enable disable sequence"

protected
  final parameter Real TOutCutoff(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")=297.15
    "Outdoor temperature high limit cutoff";
  final parameter Real hOutCutoff(
    final unit="J/kg",
    final quantity = "SpecificEnergy")=65100
    "Outdoor air enthalpy high limit cutoff";

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutBelowCutoff(
    final k=TOutCutoff - 2)
    "Outdoor air temperature cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut(
    final k=TOutCutoff)
    "Outdoor temperature high limit cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutBelowCutoff(
    final k=hOutCutoff - 1000)
    "Outdoor air enthalpy is slightly below the cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutCut(
    final k=hOutCutoff) "Outdoor air enthalpy cutoff"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage0)
    "Freeze protection status is stage0"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant zonSta(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.ZoneStates.heating)
    "Zone state is heating"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta1(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage1)
    "Freeze protection status is stage1"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant zonSta1(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.ZoneStates.deadband)
    "Zone state is deadband"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMax(
    final k=0.9)
    "Maximal allowed economizer damper position"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMin(
    final k=0.1)
    "Minimal allowed economizer damper position"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant supFanSta(
    final k=true) "Supply fan status"

equation
  connect(TOutBelowCutoff.y, enaDis.TOut)
  connect(TOutCut.y, enaDis1.TCut)
  connect(TOutBelowCutoff.y, enaDis1.TOut)
  connect(hOutBelowCutoff.y, enaDis.hOut)
  connect(hOutBelowCutoff.y, enaDis1.hOut)
  connect(zonSta.y, enaDis.uZonSta)
  connect(freProSta.y, enaDis.uFreProSta)
  connect(freProSta1.y, enaDis1.uFreProSta)
  connect(zonSta1.y, enaDis1.uZonSta)
  connect(outDamPosMax.y, enaDis.uOutDam_max)
  connect(outDamPosMin.y, enaDis.uOutDam_min)
  connect(outDamPosMin.y, enaDis1.uOutDam_min)
  connect(outDamPosMax.y, enaDis1.uOutDam_max)
  connect(supFanSta.y, enaDis.u1SupFan)
  connect(supFanSta.y, enaDis1.u1SupFan)
  connect(TOutCut.y, enaDis.TCut)
  connect(hOutCut.y, enaDis.hCut)
  connect(hOutCut.y, enaDis1.hCut)
end Enable_FreProSta_ZonSta;


Model validates economizer disable in case outdoor air conditions are above cutoff. This example validates

Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
for the following control signals: TOut, TOutCut,
hOut, hOutCut.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Validation;
model Enable_TOut_hOut
  "Model validates economizer disable in case outdoor air conditions are above cutoff"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis "Single zone VAV AHU economizer enable disable sequence"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis1 "Single zone VAV AHU economizer enable disable sequence"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis2(use_enthalpy=false)
    "Single zone VAV AHU economizer enable disable sequence"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut(
    final k=TOutCutoff) "Outdoor air temperature cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutCut1(
    final k=hOutCutoff) "Outdoor air enthalpy cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin TOut(
    final amplitude=4,
    final freqHz=1/3600,
    final offset=TOutCutoff - 2,
    final startTime=10) "Outdoor air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin hOut(
    final amplitude=4000,
    final freqHz=1/3600,
    final offset=hOutCutoff - 2200,
    final startTime=10) "Outdoor air enthalpy"

protected
  final parameter Real TOutCutoff(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")=297.15
    "Outdoor temperature high limit cutoff";
  final parameter Real hOutCutoff(
    final unit="J/kg",
    final quantity = "SpecificEnergy")=65100
    "Outdoor air enthalpy high limit cutoff";
  final parameter Real outDamPosMin=0.1
    "Minimum outdoor air damper position";
  final parameter Real outDamPosMax=0.9
    "Minimum return air damper position";
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutCut(
    final k=hOutCutoff) "Outdoor air enthalpy cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut1(
    final k=TOutCutoff) "Outdoor air temperature cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutBelowCutoff(
    final k=hOutCutoff - 1000)
    "Outdoor air enthalpy is slightly below the cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutBelowCutoff(
    final k=TOutCutoff - 2)
    "Outdoor air temperature is slightly below the cutoff"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant zoneState(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.ZoneStates.deadband)
    "Zone State is deadband"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMaxSig(
    final k=outDamPosMax)
    "Maximal allowed economizer damper position"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMinSig(
    final k=outDamPosMin)
    "Minimal allowed economizer damper position"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage0)
    "Freeze Protection Status - Disabled"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant supFanSta(
    final k=true) "Supply fan status signal"

equation
  connect(TOutCut.y, enaDis.TCut)
  connect(hOutCut.y, enaDis.hCut)
  connect(freProSta.y, enaDis.uFreProSta)
  connect(outDamPosMaxSig.y, enaDis.uOutDam_max)
  connect(outDamPosMinSig.y, enaDis.uOutDam_min)
  connect(enaDis.uZonSta, zoneState.y)
  connect(TOutCut1.y, enaDis1.TCut)
  connect(hOutCut1.y, enaDis1.hCut)
  connect(hOutBelowCutoff.y, enaDis.hOut)
  connect(TOutBelowCutoff.y, enaDis1.TOut)
  connect(freProSta.y, enaDis1.uFreProSta)
  connect(zoneState.y, enaDis1.uZonSta)
  connect(outDamPosMaxSig.y, enaDis1.uOutDam_max)
  connect(outDamPosMinSig.y, enaDis1.uOutDam_min)
  connect(TOutCut.y, enaDis2.TCut)
  connect(freProSta.y, enaDis2.uFreProSta)
  connect(zoneState.y, enaDis2.uZonSta)
  connect(outDamPosMaxSig.y, enaDis2.uOutDam_max)
  connect(outDamPosMinSig.y, enaDis2.uOutDam_min)
  connect(supFanSta.y, enaDis.u1SupFan)
  connect(supFanSta.y, enaDis1.u1SupFan)
  connect(supFanSta.y, enaDis2.u1SupFan)
  connect(TOut.y, enaDis.TOut)
  connect(TOut.y, enaDis2.TOut)
  connect(hOut.y, enaDis1.hOut)
end Enable_TOut_hOut;


Validation model for the Single zone VAV AHU minimum outdoor air control - damper position limits. This example validates

Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
for the following control signals: VOut_flow, VOutMinSet_flow.
The control loop is always enabled in this example.

within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Validation;
model Limits_Disable
  "Validation model for the Single zone VAV AHU minimum outdoor air control - damper position limits"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
    damLim1(
    final supFanSpe_min=supFanSpe_min,
    final supFanSpe_max=supFanSpe_max,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow)
    "Single zone VAV AHU minimum outdoor air control - damper position limits"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
    damLim2(
    final supFanSpe_min=supFanSpe_min,
    final supFanSpe_max=supFanSpe_max,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow)
    "Single zone VAV AHU minimum outdoor air control - damper position limits"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
    damLim3(
    final supFanSpe_min=supFanSpe_min,
    final supFanSpe_max=supFanSpe_max,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow)
    "Single zone VAV AHU minimum outdoor air control - damper position limits"

protected
  final parameter Real supFanSpe_min=0.1 "Minimum supply fan operation speed";
  final parameter Real supFanSpe_max=0.9 "Maximum supply fan operation speed";
  final parameter Real VOutDes_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=2.0
    "Calculated design outdoor airflow rate";
  final parameter Real VOutMin_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=1.0
    "Calculated minimum outdoor airflow rate";
  final parameter Real VOutSet_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=0.71
    "Example volumetric airflow setpoint, 15cfm/occupant, 100 occupants";
  final parameter Real minVOutSet_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=0.61
    "Volumetric airflow sensor output, minimum value in the example";
  final parameter Real incVOutSet_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=0.2
    "Maximum increase in airflow volume during the example simulation";

  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp SupFanSpeSig(
    final duration=1800,
    final offset=supFanSpe_min,
    final height=supFanSpe_max - supFanSpe_min) "Supply fan speed signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp VOutMinSetSig(
    final duration=1800,
    final offset=VOutMin_flow,
    final height=VOutDes_flow - VOutMin_flow) "Constant minimum outdoor airflow setpoint"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanStatus1(
    final k=false) "Fan is off"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta1(
    k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage1)
    "Freeze protection stage is 1"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant operationMode1(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.occupied)
    "AHU operation mode is Occupied"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanStatus2(
    final k=true) "Fan is on"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta2(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage1)
    "Freeze protection stage is 1"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant operationMode2(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.warmUp)
    "AHU operation mode is NOT occupied"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanStatus3(
    final k=true) "Fan is on"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta3(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage2)
    "Freeze protection stage is 2"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant operationMode3(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.occupied)
    "AHU operation mode is occupied"

equation
  connect(SupFanSpeSig.y, damLim1.uSupFan_actual)
  connect(VOutMinSetSig.y, damLim2.VOutMinSet_flow)
  connect(fanStatus1.y, damLim1.u1SupFan)
  connect(freProSta1.y, damLim1.uFreProSta)
  connect(operationMode1.y, damLim1.uOpeMod)
  connect(fanStatus2.y, damLim2.u1SupFan)
  connect(freProSta2.y,damLim2. uFreProSta)
  connect(operationMode2.y,damLim2. uOpeMod)
  connect(fanStatus3.y, damLim3.u1SupFan)
  connect(freProSta3.y,damLim3. uFreProSta)
  connect(operationMode3.y,damLim3. uOpeMod)
  connect(VOutMinSetSig.y, damLim3.VOutMinSet_flow)
  connect(VOutMinSetSig.y, damLim1.VOutMinSet_flow)
  connect(SupFanSpeSig.y, damLim2.uSupFan_actual)
  connect(SupFanSpeSig.y, damLim3.uSupFan_actual)
end Limits_Disable;


within Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Validation;
model Limits_FanSpe_VOut_flow
  "Validation model for the Single zone VAV AHU minimum outdoor air control - damper position limits"

  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
    damLim(
    final supFanSpe_min=supFanSpe_min,
    final supFanSpe_max=supFanSpe_max,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow)
    "Single zone VAV AHU minimum outdoor air control - damper position limits"
  Buildings.Controls.OBC.ASHRAE.G36.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
    damLim1(
    final supFanSpe_min=supFanSpe_min,
    final supFanSpe_max=supFanSpe_max,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow)
    "Single zone VAV AHU minimum outdoor air control - damper position limits"

protected
  final parameter Real supFanSpe_min=0.1 "Minimum supply fan operation speed";
  final parameter Real supFanSpe_max=0.9 "Maximum supply fan operation speed";
  final parameter Real fanSpe = (supFanSpe_max + supFanSpe_min)/2 "Constant supply fan speed";
  final parameter Real VOutDes_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=2.0
    "Calculated design outdoor airflow rate";
  final parameter Real VOutMin_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=1.0
    "Calculated minimum outdoor airflow rate";
  final parameter Real VOutSet_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=(VOutDes_flow + VOutMin_flow)/2
    "Constant minimum outdoor airflow setpoint";

  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanStatus(
    final k=true) "Fan is on"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.FreezeProtectionStages.stage0)
    "Freeze protection status - disabled"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant operationMode(
    final k=Buildings.Controls.OBC.ASHRAE.G36.Types.OperationModes.occupied)
    "Operation mode - occupied"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant VOutMinSetSig(
    final k=VOutSet_flow)
    "Constant minimum outdoor airflow setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp SupFanSpeSig(
    final duration=1800,
    final offset=supFanSpe_min,
    final height=supFanSpe_max - supFanSpe_min) "Supply fan speed signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp VOutMinSetSig1(
    final duration=1800,
    final offset=VOutMin_flow,
    final height=VOutDes_flow - VOutMin_flow) "Constant minimum outdoor airflow setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant SupFanSpeSig1(
    final k=fanSpe) "Supply fan speed signal"

equation
  connect(freProSta.y, damLim.uFreProSta)
  connect(damLim.u1SupFan, fanStatus.y)
  connect(operationMode.y, damLim.uOpeMod)
  connect(fanStatus.y, damLim1.u1SupFan)
  connect(operationMode.y, damLim1.uOpeMod)
  connect(freProSta.y, damLim1.uFreProSta)
  connect(VOutMinSetSig.y, damLim.VOutMinSet_flow)
  connect(SupFanSpeSig.y, damLim.uSupFan_actual)
  connect(SupFanSpeSig1.y, damLim1.uSupFan_actual)
  connect(VOutMinSetSig1.y, damLim1.VOutMinSet_flow)
end Limits_FanSpe_VOut_flow;