Output outdoor airflow related calculations at the zone level. This sequence conducts calculations of the minimum outdoor airflow rate at the zone
level. It gives outputs below.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow;
block Zone
  "Output outdoor airflow related calculations at the zone level"

  parameter Real VOutPerAre_flow(
    final unit = "m3/(s.m2)")=3e-4
    "Outdoor air rate per unit area"

  parameter Real VOutPerPer_flow(unit="m3/s")=2.5e-3
    "Outdoor air rate per person"

  parameter Real AFlo(unit="m2")
    "Floor area of each zone"

  parameter Boolean have_occSen=true
    "Set to true if zones have occupancy sensor";

  parameter Boolean have_winSen=true
    "Set to true if zones have window status sensor";

  parameter Real occDen(final unit = "1/m2") = 0.05
    "Default number of person in unit area";

  parameter Real zonDisEffHea(final unit = "1") = 0.8
    "Zone air distribution effectiveness during heating";

  parameter Real zonDisEffCoo(final unit = "1") = 1.0
    "Zone air distribution effectiveness during cooling";

  parameter Real desZonDisEff(final unit = "1") = 1.0
    "Design zone air distribution effectiveness"

  parameter Real desZonPop(
    min=0,
    final unit = "1") = occDen*AFlo
    "Design zone population during peak occupancy"

  parameter Real uLow(
    final unit="K",
    final displayUnit="K",
    final quantity="ThermodynamicTemperature") = -0.5
    "If zone space temperature minus supply air temperature is less than uLow,
     then it should use heating supply air distribution effectiveness"

  parameter Real uHig(
    final unit="K",
    final displayUnit="K",
    final quantity="ThermodynamicTemperature") = 0.5
    "If zone space temperature minus supply air temperature is more than uHig,
     then it should use cooling supply air distribution effectiveness"

  parameter Real minZonPriFlo(unit="m3/s")
    "Minimum expected zone primary flow rate"

  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput nOcc if have_occSen
    "Number of occupants"

  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uWin if have_winSen
    "Window status, true if open, false if closed"

  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uReqOutAir
    "True if the AHU supply fan is on and the zone is in occupied mode"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TZon(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature") "Measured zone air temperature"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TDis(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature") "Measured discharge air temperature"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput VDis_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")
    "Zone primary airflow rate from the air handler. For single path unit, it is the same as the zone discharge airflow rate"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput VUncOut_flow_nominal(
    final min=0,
    final unit = "m3/s",
    final quantity = "VolumeFlowRate")
    "AHU level design uncorrected minimum outdoor airflow rate"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yDesZonPeaOcc(
    final min=0,
    final unit="1")
    "Design zone peak occupancy"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput VDesPopBreZon_flow(
    final min=0,
    final unit = "m3/s",
    final quantity = "VolumeFlowRate")
    "Population component breathing zone design outdoor airflow"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput VDesAreBreZon_flow(
    final min=0,
    final unit = "m3/s",
    final quantity = "VolumeFlowRate")
    "Area component breathing zone outdoor airflow"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yDesPriOutAirFra(
    final min=0,
    final unit="1")
    "Design zone primary outdoor air fraction"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput VUncOutAir_flow(
    final min=0,
    final unit = "m3/s",
    final quantity = "VolumeFlowRate")
    "Uncorrected outdoor airflow rate"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yPriOutAirFra(
    final min=0,
    final unit="1") "Primary outdoor air fraction"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput VPriAir_flow(
    final min=0,
    final unit = "m3/s",
    final quantity = "VolumeFlowRate")
    "Primary airflow rate"

protected
  Buildings.Controls.OBC.CDL.Conversions.IntegerToReal intToRea if have_occSen
    "Type converter"

  Buildings.Controls.OBC.CDL.Reals.Add breZon "Breathing zone airflow"

  Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gai(
    final k=VOutPerPer_flow) if have_occSen "Outdoor air per person"

  Buildings.Controls.OBC.CDL.Reals.Switch swi
    "If there is occupancy sensor, then using the real time occupancy; otherwise, using the default occupancy"

  Buildings.Controls.OBC.CDL.Reals.Switch swi1
    "Switch between cooling or heating distribution effectiveness"

  Buildings.Controls.OBC.CDL.Reals.Divide zonOutAirRate
    "Required zone outdoor airflow rate"

  Buildings.Controls.OBC.CDL.Reals.Divide priOutAirFra
    "Primary outdoor air fraction"

  Buildings.Controls.OBC.CDL.Reals.Add desBreZon "Breathing zone design airflow"

  Buildings.Controls.OBC.CDL.Reals.Divide desZonOutAirRate
    "Required design zone outdoor airflow rate"

  Buildings.Controls.OBC.CDL.Reals.Divide desZonPriOutAirRate
    "Design zone primary outdoor air fraction"

  Buildings.Controls.OBC.CDL.Reals.Subtract sub2
    "Zone space temperature minus supply air temperature"

  Buildings.Controls.OBC.CDL.Reals.Hysteresis hys(
    final uLow=uLow,
    final uHigh=uHig,
    final pre_y_start=true)
    "Check if cooling or heating air distribution effectiveness should be applied, with 1 degC deadband"

  Buildings.Controls.OBC.CDL.Logical.Sources.Constant occSen(
    final k=have_occSen)
    "Boolean constant to indicate if there is occupancy sensor"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant desDisEff(
    final k = desZonDisEff)
    "Design zone air distribution effectiveness"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant minZonFlo(
    final k = minZonPriFlo)
    "Minimum expected zone primary flow rate"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant disEffHea(
    final k = zonDisEffHea)
    "Zone distribution effectiveness for heating"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant disEffCoo(
    final k = zonDisEffCoo)
    "Zone distribution effectiveness fo cooling"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zerOutAir(
    final k=0)
    "Zero required outdoor airflow rate when window is open or when zone is not in occupied mode"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zerOcc(
    final k=0) if not have_occSen
    "Zero occupant when there is no occupancy sensor"

  Buildings.Controls.OBC.CDL.Logical.Sources.Constant cloWin(
    final k=false) if not have_winSen
    "Closed window status when there is no window sensor"

  Buildings.Controls.OBC.CDL.Reals.Switch swi4
    "If window is open, the required outdoor airflow rate should be zero"

  Buildings.Controls.OBC.CDL.Reals.Switch swi5
    "If supply fan is off or it is not in occupied mode, then outdoor airflow rate should be zero"

  Buildings.Controls.OBC.CDL.Reals.Max max
    "If supply fan is off, giving a small primary airflow rate to avoid division by zero"

  Buildings.Controls.OBC.CDL.Reals.Multiply breZonAre
    "Area component of the breathing zone outdoor airflow"

  Buildings.Controls.OBC.CDL.Reals.Multiply pro
    "Product of flow rate per person and floor area"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant floPerAre(
    final k=VOutPerAre_flow)
    "Flow rate per unit area"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant floAre(
    final k=AFlo) "Floor area"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant floPerPer(
    final k=VOutPerPer_flow) "Flow rate per person"

  Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter breZonPop(
    final k=occDen)
    "Default population component of the breathing zone outdoor airflow"

  Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gaiDivZer(
    final k=1E-3)
    "Gain, used to avoid division by zero if the flow rate is smaller than 0.1%"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant desPeaOcc(
    final k=desZonPop)
    "Design zone population during peak occupancy"

  Buildings.Controls.OBC.CDL.Reals.Multiply desBreZonPer
    "Population component of the breathing zone design outdoor airflow"

equation
  connect(gai.y, swi.u1)
 connect(swi.y, breZon.u2)
  connect(disEffCoo.y, swi1.u1)
  connect(disEffHea.y, swi1.u3)
  connect(breZon.y, zonOutAirRate.u1)
  connect(swi1.y, zonOutAirRate.u2)
  connect(desDisEff.y, desZonOutAirRate.u2)
  connect(desBreZon.y, desZonOutAirRate.u1)
  connect(desZonOutAirRate.y, desZonPriOutAirRate.u1)
  connect(minZonFlo.y, desZonPriOutAirRate.u2)
  connect(swi.u2, occSen.y)
  connect(TDis, sub2.u2)
  connect(TZon, sub2.u1)
  connect(sub2.y, hys.u)
  connect(hys.y, swi1.u2)
  connect(zerOcc.y, swi.u1)
  connect(intToRea.y, gai.u)
  connect(nOcc, intToRea.u)
  connect(desZonPriOutAirRate.y, yDesPriOutAirFra)
  connect(priOutAirFra.y, yPriOutAirFra)
  connect(zerOutAir.y, swi4.u1)
  connect(zonOutAirRate.y, swi4.u3)
  connect(swi5.y, VUncOutAir_flow)
  connect(swi5.y, priOutAirFra.u1)
  connect(uWin, swi4.u2)
  connect(cloWin.y, swi4.u2)
  connect(uReqOutAir, swi5.u2)
  connect(VDis_flow, max.u1)
  connect(max.y, priOutAirFra.u2)
  connect(max.y, VPriAir_flow)
  connect(floAre.y, breZonAre.u1)
  connect(floPerAre.y, breZonAre.u2)
  connect(breZonAre.y, desBreZon.u2)
  connect(breZonAre.y, breZon.u1)
  connect(floPerPer.y, pro.u1)
  connect(floAre.y, pro.u2)
  connect(breZonPop.y, swi.u3)
  connect(pro.y, breZonPop.u)
  connect(VUncOut_flow_nominal, gaiDivZer.u)
  connect(gaiDivZer.y, max.u2)
  connect(floPerPer.y, desBreZonPer.u2)
  connect(desPeaOcc.y, desBreZonPer.u1)
  connect(desBreZonPer.y, desBreZon.u1)
  connect(desPeaOcc.y, yDesZonPeaOcc)
  connect(desBreZonPer.y, VDesPopBreZon_flow)
  connect(breZonAre.y, VDesAreBreZon_flow)
  connect(zerOutAir.y, swi5.u3)
  connect(swi4.y, swi5.u1)
end Zone;


Validate the sequences of setting AHU level minimum outdoor airflow rate. This model shows how to compose the subsequences to find the minimum outdoor
airflow setpoint of an AHU unit that serves three zones.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow.Validation;
model OutdoorAirFlow
  "Validate the sequences of setting AHU level minimum outdoor airflow rate"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow.Zone
    zon1(
    AFlo=40,
    have_winSen=false,
    desZonPop=4,
    minZonPriFlo=0.08) "Outdoor airflow related calculations for zone 1"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow.Zone
    zon2(
    AFlo=35,
    desZonPop=4,
    minZonPriFlo=0.08) "Outdoor airflow related calculations for zone 2"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow.Zone
    zon3(
    AFlo=30,
    desZonPop=3,
    minZonPriFlo=0.06) "Outdoor airflow related calculations for zone 3"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow.AHU
    ahu1(VPriSysMax_flow=0.6, peaSysPop=12)
    "AHU level minimum outdoor airflow setpoint"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow.SumZone
    zonToAhu(final numZon=3) "From zone level to AHU level"

protected
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant supFan(k=true)
    "Status of supply fan"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant opeMod(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.OperationModes.occupied)
    "AHU operation mode is Occupied"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp numOfOcc2(
    duration=3600,
    height=3)
    "Occupant number in zone 2"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt1
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp numOfOcc3(
    duration=3600,
    height=3,
    startTime=900) "Occupant number in zone 3"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt2
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant winSta(k=false)
    "Status of windows"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse winSta1(period=3600)
    "Status of windows"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp numOfOcc4(
    duration=3600,
    startTime=900,
    height=2) "Occupant number"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt3
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TZon(
    height=6,
    offset=280.15,
    duration=3600) "Measured zone temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TDis(
    height=4,
    duration=3600,
    offset=281.15) "Terminal unit discharge air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zonPriFloRat(k=0.1)
    "Measured primary flow rate at VAV box"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zonPriFloRat1(k=0.12)
    "Measured primary flow rate at VAV box"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zonPriFloRat2(k=0.09)
    "Measured primary flow rate at VAV box"

equation
  connect(zon1.yDesZonPeaOcc,zonToAhu. uDesZonPeaOcc[1])
  connect(zon2.yDesZonPeaOcc,zonToAhu. uDesZonPeaOcc[2])
  connect(zon3.yDesZonPeaOcc,zonToAhu. uDesZonPeaOcc[3])
  connect(zon1.VDesPopBreZon_flow,zonToAhu. VDesPopBreZon_flow[1])
  connect(zon2.VDesPopBreZon_flow,zonToAhu. VDesPopBreZon_flow[2])
  connect(zon3.VDesPopBreZon_flow,zonToAhu. VDesPopBreZon_flow[3])
  connect(zon1.VDesAreBreZon_flow,zonToAhu. VDesAreBreZon_flow[1])
  connect(zon2.VDesAreBreZon_flow,zonToAhu. VDesAreBreZon_flow[2])
  connect(zon3.VDesAreBreZon_flow,zonToAhu. VDesAreBreZon_flow[3])
  connect(zon1.yDesPriOutAirFra,zonToAhu. uDesPriOutAirFra[1])
  connect(zon2.yDesPriOutAirFra,zonToAhu. uDesPriOutAirFra[2])
  connect(zon3.yDesPriOutAirFra,zonToAhu. uDesPriOutAirFra[3])
  connect(zon1.VUncOutAir_flow,zonToAhu. VUncOutAir_flow[1])
  connect(zon2.VUncOutAir_flow,zonToAhu. VUncOutAir_flow[2])
  connect(zon3.VUncOutAir_flow,zonToAhu. VUncOutAir_flow[3])
  connect(zon1.yPriOutAirFra,zonToAhu. uPriOutAirFra[1])
  connect(zon2.yPriOutAirFra,zonToAhu. uPriOutAirFra[2])
  connect(zon3.yPriOutAirFra,zonToAhu. uPriOutAirFra[3])
  connect(zon1.VPriAir_flow,zonToAhu. VPriAir_flow[1])
  connect(zon2.VPriAir_flow,zonToAhu. VPriAir_flow[2])
  connect(zon3.VPriAir_flow,zonToAhu. VPriAir_flow[3])
  connect(zonToAhu.ySumDesZonPop,ahu1. sumDesZonPop)
  connect(zonToAhu.VSumDesPopBreZon_flow,ahu1. VSumDesPopBreZon_flow)
  connect(zonToAhu.VSumDesAreBreZon_flow,ahu1. VSumDesAreBreZon_flow)
  connect(zonToAhu.yDesSysVenEff,ahu1. uDesSysVenEff)
  connect(zonToAhu.VSumUncOutAir_flow,ahu1. VSumUncOutAir_flow)
  connect(zonToAhu.uOutAirFra_max,ahu1. uOutAirFra_max)
  connect(zonToAhu.VSumSysPriAir_flow,ahu1. VSumSysPriAir_flow)
  connect(ahu1.yAveOutAirFraPlu,zonToAhu. yAveOutAirFraPlu)
  connect(supFan.y,ahu1. uSupFan)
  connect(opeMod.y,ahu1. uOpeMod)
  connect(ahu1.yReqOutAir, zon1.uReqOutAir)
  connect(ahu1.yReqOutAir, zon2.uReqOutAir)
  connect(ahu1.yReqOutAir, zon3.uReqOutAir)
  connect(numOfOcc2.y,reaToInt1. u)
  connect(numOfOcc3.y, reaToInt2.u)
  connect(reaToInt1.y, zon1.nOcc)
  connect(reaToInt2.y, zon2.nOcc)
  connect(numOfOcc4.y, reaToInt3.u)
  connect(reaToInt3.y, zon3.nOcc)
  connect(winSta1.y, zon3.uWin)
  connect(winSta.y, zon2.uWin)
  connect(TZon.y, zon1.TZon)
  connect(TZon.y, zon2.TZon)
  connect(TZon.y, zon3.TZon)
  connect(TDis.y, zon1.TDis)
  connect(TDis.y, zon2.TDis)
  connect(TDis.y, zon3.TDis)
  connect(zonPriFloRat2.y, zon3.VDis_flow)
  connect(zonPriFloRat1.y, zon2.VDis_flow)
  connect(zonPriFloRat.y, zon1.VDis_flow)
  connect(ahu1.VDesUncOutAir_flow, zon1.VUncOut_flow_nominal)
  connect(ahu1.VDesUncOutAir_flow, zon2.VUncOut_flow_nominal)
  connect(ahu1.VDesUncOutAir_flow, zon3.VUncOut_flow_nominal)
end OutdoorAirFlow;


Collection of validation models

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.OutdoorAirFlow;
package Validation "Collection of validation models"
end Validation;


Validate the controller of an actuated exhaust damper without fan. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ExhaustDamper.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.Validation;
model ExhaustDamper
  "Validate the controller of an actuated exhaust damper without fan"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ExhaustDamper
    exhDamPos(k=0.1) "Block of controlling actuated exhaust damper without fan"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant supFan(k=true)
    "Supply fan status"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp meaBuiPre(
    height=8,
    duration=1200,
    offset=8,
    startTime=0)
    "Measured indoor building static pressure"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ExhaustDamper
    exhDamPos1(k=0.5)
    "Block of controlling actuated exhaust damper without fan"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ExhaustDamper
    exhDamPos2(k=1) "Block of controlling actuated exhaust damper without fan"
equation
  connect(meaBuiPre.y, exhDamPos.dpBui)
  connect(supFan.y, exhDamPos.uSupFan)

  connect(supFan.y, exhDamPos1.uSupFan)
  connect(supFan.y, exhDamPos2.uSupFan)
  connect(meaBuiPre.y, exhDamPos1.dpBui)
  connect(meaBuiPre.y, exhDamPos2.dpBui)
end ExhaustDamper;


Collection of validation models

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


Validate model for calculating return fan control with direct building pressure
  of multi zone VAV AHU. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ReturnFanDirectPressure
for exhaust air damper and return fan control with direct building pressure measurement
for systems with multiple
zones.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.Validation;
model ReturnFanDirectPressure
  "Validate model for calculating return fan control with direct building pressure
  of multi zone VAV AHU"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ReturnFanDirectPressure
    retFanPre(k=0.1) "Return fan control with direct building pressure"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse yFan(period=4000)
    "Supply fan status"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp dpBui(
    height=40,
    offset=0,
    duration=1800) "Building static presure"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ReturnFanDirectPressure
    retFanPre1(k=0.5) "Return fan control with direct building pressure"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.ReturnFanDirectPressure
    retFanPre2 "Return fan control with direct building pressure"

equation
  connect(yFan.y, retFanPre.uFan)
  connect(dpBui.y, retFanPre.dpBui)
  connect(yFan.y, retFanPre1.uFan)
  connect(yFan.y, retFanPre2.uFan)
  connect(dpBui.y, retFanPre1.dpBui)
  connect(dpBui.y, retFanPre2.dpBui)
end ReturnFanDirectPressure;


Validate SupplyFan. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplyFan.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.Validation;
model SupplyFan "Validate SupplyFan"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplyFan
    conSupFan(
    Td=1,
    controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PI,
    maxSet=400,
    k=0.001,
    Ti=10) "Block outputs supply fan speed"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplyFan
    conSupFan1(
    have_perZonRehBox=true,
    Td=1,
    controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PI,
    maxSet=400,
    k=0.001,
    Ti=10) "Block outputs supply fan speed"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplyFan
    conSupFan2(
    have_duaDucBox=false,
    have_airFloMeaSta=true,
    Td=1,
    controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PI,
    maxSet=400,
    k=0.001,
    Ti=10) "Block outputs supply fan speed"

protected
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp ram(
    duration=28800,
    height=6) "Ramp signal for generating operation mode"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine(
    freqHz=1/14400,
    offset=3,
    amplitude=2)    "Generate sine signal "
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine1(
    freqHz=1/14400,
    offset=200,
    amplitude=150) "Generate sine signal"
  Buildings.Controls.OBC.CDL.Reals.Abs abs
    "Block generates absolute value of input"
  Buildings.Controls.OBC.CDL.Reals.Abs abs1
    "Block generates absolute value of input"
  Buildings.Controls.OBC.CDL.Reals.Round round2(n=0)
    "Round real number to given digits"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt1
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt2
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Reals.Round round1(n=0)
    "Round real number to given digits"

equation
  connect(sine1.y, conSupFan.ducStaPre)
  connect(sine.y, abs1.u)
  connect(ram.y, abs.u)
  connect(abs1.y, round2.u)
  connect(round2.y, reaToInt1.u)
  connect(reaToInt1.y, conSupFan.uZonPreResReq)
  connect(abs.y, round1.u)
  connect(round1.y, reaToInt2.u)
  connect(reaToInt2.y, conSupFan.uOpeMod)

  connect(reaToInt2.y, conSupFan2.uOpeMod)
  connect(reaToInt1.y, conSupFan2.uZonPreResReq)
  connect(sine1.y, conSupFan2.ducStaPre)
  connect(reaToInt2.y, conSupFan1.uOpeMod)
  connect(reaToInt1.y, conSupFan1.uZonPreResReq)
  connect(sine1.y, conSupFan1.ducStaPre)
end SupplyFan;


Validate model for controlling coil valve postion of multi zone VAV AHU. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplySignals
for a change of the supply air temperature setpoint, measured supply air temperature and
the supply fan status, to specify coil valve positions, and generate control
loop signal.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.Validation;
model SupplySignals_Valve
  "Validate model for controlling coil valve postion of multi zone VAV AHU"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplySignals
    supSig
    "Output valve position and supply air temperature control loop signal"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse supFanSta(period=7200)
    "Supply fan status"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin TSup(
    amplitude=2,
    offset=16 + 273.15,
    freqHz=1/7200) "Supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSupSet(
    height=3,
    duration=7200,
    offset=15 + 273.15)
    "Supply air temperature setpoint"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplySignals
    supSig1
    "Output valve position and supply air temperature control loop signal"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanOn(k=true) "Fan on"

equation
  connect(TSupSet.y,supSig.TSupSet)
  connect(TSup.y, supSig.TSup)
  connect(supFanSta.y, supSig.uSupFan)
  connect(TSupSet.y,supSig1.TSupSet)
  connect(TSup.y, supSig1.TSup)
  connect(fanOn.y, supSig1.uSupFan)
end SupplySignals_Valve;


Validate model for calculating supply air temperature of multi zone VAV AHU. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplyTemperature
for a change of outdoor temperature, operation mode, supply fan status, maximum
supply temperature, to specify the supply air temperature for systems with multiple
zones.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.Validation;
model SupplyTemperature
  "Validate model for calculating supply air temperature of multi zone VAV AHU"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.SetPoints.SupplyTemperature
    conTSupSet "Supply air temperature setpoint for multi zone system"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant setZonTem(
    k=22.5 + 273.15) "Average of heating and cooling setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin outTem(
    amplitude=5,
    freqHz=1/86400,
    offset=18 + 273.15) "Outdoor air temperature"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse supFanSta(period=43200)
    "Supply fan status"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp opeMod(
    offset=1,
    height=1,
    duration=90000) "Operation mode"
  Buildings.Controls.OBC.CDL.Reals.Abs abs
    "Block generates absolute value of input"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine(
    amplitude=6, freqHz=1/86400)
    "Block generates sine signal"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt1
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Reals.Round round1(n=0)
    "Round real number to given digits"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt2
    "Convert real to integer"
  Buildings.Controls.OBC.CDL.Reals.Round round2(n=0)
    "Round real number to given digits"

equation
  connect(supFanSta.y, conTSupSet.uSupFan)
  connect(outTem.y, conTSupSet.TOut)
  connect(setZonTem.y, conTSupSet.TZonSetAve)
  connect(sine.y, abs.u)
  connect(opeMod.y, round2.u)
  connect(round2.y, reaToInt2.u)
  connect(abs.y, round1.u)
  connect(round1.y, reaToInt1.u)
  connect(reaToInt1.y, conTSupSet.uZonTemResReq)
  connect(reaToInt2.y, conTSupSet.uOpeMod)
end SupplyTemperature;


Validation controller model. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.Controller.

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

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.MultiZone.VAV.Controller conAHU(
      VPriSysMax_flow=0.35, peaSysPop=6) "Multizone VAV AHU controller"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TSetRooCooOn(
    final k=273.15 + 24)
    "Cooling on setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TSetRooHeaOn(
    final k=273.15 + 20) "Heating on setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut(
    final k=297.15)
    "Outdoor temperature high limit cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup(
    height=4,
    duration=3600,
    offset=273.15 + 14) "AHU supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp VOut_flow(
    duration=1800,
    offset=0.02,
    height=0.0168)
    "Measured outdoor airflow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TMixMea(
    height=4,
    duration=1,
    offset=273.15 + 2,
    startTime=0)
    "Measured mixed air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin TOut(
    amplitude=5,
    offset=18 + 273.15,
    freqHz=1/3600) "Outdoor air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin ducStaPre(
    offset=200,
    amplitude=150,
    freqHz=1/3600) "Duct static pressure"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine2(
    offset=3,
    amplitude=2,
    freqHz=1/9600) "Duct static pressure setpoint reset requests"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sine3(
    amplitude=6,
    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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.OperationModes.occupied)
    "AHU operation mode is occupied"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant sumDesZonPop(
    final k=5)
    "Sum of design zone population"
  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.Constant desSysVenEff(
    final k=1)
    "Design system ventilation efficiency"
  Buildings.Controls.OBC.CDL.Reals.Sources.Pulse uncOutAir(
    amplitude=0.01,
    width=0.25,
    period=3600,
    offset=0.0375) "Sum of all zones required uncorrected outdoor airflow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp vavBoxFlo2(
    offset=1,
    height=0.5,
    duration=3600)
    "Ramp signal for generating VAV box flow rate"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp vavBoxFlo1(
    height=1.5,
    offset=1,
    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(
    amplitude=0.005,
    width=0.25,
    period=3600,
    offset=0.015)
    "Maximum zone outdoor air fraction, equals to the maximum of primary outdoor air fraction of all zones"

equation
  connect(TSetRooHeaOn.y, conAHU.TZonHeaSet)
  connect(TSetRooCooOn.y, conAHU.TZonCooSet)
  connect(TOut.y, conAHU.TOut)
  connect(ducStaPre.y, conAHU.ducStaPre)
  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(opeMod.y, conAHU.uOpeMod)
  connect(maxSupResReq.y, conAHU.uZonTemResReq)
  connect(ducPreResReq.y, conAHU.uZonPreResReq)
  connect(TMixMea.y, conAHU.TMix)
  connect(VOut_flow.y, conAHU.VOut_flow)
  connect(TOutCut.y, conAHU.TOutCut)
  connect(TSup.y, conAHU.TSup)
  connect(sumDesZonPop.y, conAHU.sumDesZonPop)
  connect(sumDesPopBreZon.y, conAHU.VSumDesPopBreZon_flow)
  connect(sumDesAreBreZon.y, conAHU.VSumDesAreBreZon_flow)
  connect(desSysVenEff.y, conAHU.uDesSysVenEff)
  connect(uncOutAir.y, conAHU.VSumUncOutAir_flow)
  connect(vavBoxFlo2.y, add2.u1)
  connect(vavBoxFlo1.y, add2.u2)
  connect(add2.y, conAHU.VSumSysPriAir_flow)
  connect(uOutAirFra_max.y, conAHU.uOutAirFra_max)
end Controller;


Collection of validation models

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


Sequences for single zone AHU control

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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.

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

  parameter Boolean have_winSen "Check if the zone has window status sensor";
  parameter Boolean have_occSen  "Set to true if zones have occupancy sensor";
  parameter Real TZonHeaOn(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=293.15
    "Heating setpoint during on"
  parameter Real TZonHeaOff(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=285.15
    "Heating setpoint during off"
  parameter Real TZonCooOn(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=297.15
    "Cooling setpoint during on"
  parameter Real TZonCooOff(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=303.15
    "Cooling setpoint during off"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerTypeCoo=
     Buildings.Controls.OBC.CDL.Types.SimpleController.PI "Type of controller"
  parameter Real kCoo(final unit="1/K") = 0.1
    "Gain for cooling control loop signal"
  parameter Real TiCoo(
    final unit="s",
    final quantity="Time")=900
    "Time constant of integrator block for cooling control loop signal"
  parameter Real TdCoo(
    final unit="s",
    final quantity="Time")=0.1
    "Time constant of derivative block for cooling control loop signal"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerTypeHea=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"
  parameter Real kHea(final unit="1/K")=0.1
    "Gain for heating control loop signal"
  parameter Real TiHea(
    final unit="s",
    final quantity="Time")=900
    "Time constant of integrator block for heating control loop signal"
  parameter Real TdHea(
    final unit="s",
    final quantity="Time")=0.1
    "Time constant of derivative block for heating control loop signal"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerTypeCooCoi=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"
  parameter Real kCooCoi(final unit="1/K")=0.1
    "Gain for cooling coil control signal"
  parameter Real TiCooCoil(
    final unit="s",
    final quantity="Time")=900
    "Time constant of integrator block for cooling coil control signal"
  parameter Real TdCooCoil(
    final unit="s",
    final quantity="Time")=0.1
    "Time constant of derivative block for cooling coil control signal"
  parameter Real TSupSetMax(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Maximum supply air temperature for heating"
  parameter Real TSupSetMin(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Minimum supply air temperature for cooling"
  parameter Real yHeaMax(min=0, max=1, unit="1")
    "Maximum fan speed for heating"
  parameter Real yMin(min=0, max=1, unit="1")
    "Minimum fan speed"
  parameter Real yCooMax(min=0, max=1, unit="1") = 1
    "Maximum fan speed for cooling"
  parameter Real VOutPerAre_flow(final unit="m3/(s.m2)") = 3e-4
    "Outdoor air rate per unit area"
  parameter Real VOutPerPer_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate") = 2.5e-3
    "Outdoor air rate per person"
  parameter Real AFlo(final unit="m2", final quantity="Area")
    "Floor area"
  parameter Real occDen(final unit="1/m2") = 0.05
    "Default number of person in unit area"
  parameter Real zonDisEffHea(final unit="1") = 0.8
    "Zone air distribution effectiveness during heating"
  parameter Real zonDisEffCoo(final unit="1") = 1.0
    "Zone air distribution effectiveness during cooling"
  parameter Boolean use_enthalpy=false
    "Set to true if enthalpy measurement is used in addition to temperature measurement"
  parameter Boolean use_fixed_plus_differential_drybulb=false
    "Set to true to only evaluate fixed plus differential dry bulb temperature high limit cutoff;
    shall not be used with enthalpy"
  parameter Boolean use_TMix=true
    "Set to true if mixed air temperature measurement is enabled"
  parameter Boolean use_G36FrePro=false
    "Set to true if G36 freeze protection is implemented"
  parameter Real delEntHis(
    final unit="J/kg",
    final quantity="SpecificEnergy")=1000
    "Delta between the enthalpy hysteresis high and low 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 uMin(
    final min=0,
    final max=1,
    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,
    final max=1,
    final unit="1") = 0.9
    "Upper limit of controller output uTSup at which the dampers are at their limits"
  parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerTypeFre=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"
  parameter Real kFre(final unit="1/K") = 0.1
    "Gain for mixed air temperature tracking for freeze protection, used if use_TMix=true"
  parameter Real TiFre(
    final unit="s",
    final quantity="Time")=120
    "Time constant of controller for mixed air temperature tracking for freeze protection. Require TiFre < TiMinOut"
  parameter Real TdFre(
    final unit="s",
    final quantity="Time")=0.1
     "Time constant of derivative block for freeze protection"
  parameter Real TFreSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=277.15
    "Lower limit for mixed air temperature for freeze protection, used if use_TMix=true"
  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 yDam_VOutMin_minSpe(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1") = 0.4
    "OA damper position to supply minimum outdoor airflow at minimum fan speed"
  parameter Real yDam_VOutMin_maxSpe(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1") = 0.3
    "OA damper position to supply minimum outdoor airflow at maximum fan speed"
  parameter Real yDam_VOutDes_minSpe(
    final min=yDam_VOutMin_minSpe,
    final max=outDamPhyPosMax,
    final unit="1") = 0.9
    "OA damper position to supply design outdoor airflow at minimum fan speed"
  parameter Real yDam_VOutDes_maxSpe(
    final min=yDam_VOutMin_maxSpe,
    final max=outDamPhyPosMax,
    final unit="1") = 0.8
    "OA damper position to supply design outdoor airflow at maximum fan speed"
  parameter Real outDamPhyPosMax(
    final min=0,
    final max=1,
    final unit="1") = 1.0
    "Physically fixed maximum position of the outdoor air damper"
  parameter Real outDamPhyPosMin(
    final min=0,
    final max=1,
    final unit="1") = 0.0
    "Physically fixed minimum position of the outdoor air damper"
  parameter Real retDamPhyPosMax(
    final min=0,
    final max=1,
    final unit="1") = 1.0
    "Physically fixed maximum position of the return air damper"
  parameter Real retDamPhyPosMin(
    final min=0,
    final max=1,
    final unit="1") = 0.0
    "Physically fixed minimum position of the return air damper"
  parameter Boolean cooAdj=false
    "Flag, set to true if both cooling and heating setpoint are adjustable separately"
  parameter Boolean heaAdj=false
    "Flag, set to true if heating setpoint is adjustable"
  parameter Boolean sinAdj=false
    "Flag, set to true if both cooling and heating setpoint are adjustable through a single common knob"
  parameter Boolean ignDemLim=false
    "Flag, set to true to exempt individual zone from demand limit setpoint adjustment"
  parameter Real TZonCooOnMax(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=300.15 "Maximum cooling setpoint during on"
  parameter Real TZonCooOnMin(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=295.15 "Minimum cooling setpoint during on"
  parameter Real TZonHeaOnMax(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=295.15 "Maximum heating setpoint during on"
  parameter Real TZonHeaOnMin(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=291.15 "Minimum heating setpoint during on"
  parameter Real TZonCooSetWinOpe(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=322.15 "Cooling setpoint when window is open"
  parameter Real TZonHeaSetWinOpe(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=277.15 "Heating setpoint when window is open"
  parameter Real incTSetDem_1=0.56
    "Cooling setpoint increase value (degC) when cooling demand limit level 1 is imposed"
  parameter Real incTSetDem_2=1.1
    "Cooling setpoint increase value (degC) when cooling demand limit level 2 is imposed"
  parameter Real incTSetDem_3=2.2
    "Cooling setpoint increase value (degC) when cooling demand limit level 3 is imposed"
  parameter Real decTSetDem_1=0.56
    "Heating setpoint decrease value (degC) when heating demand limit level 1 is imposed"
  parameter Real decTSetDem_2=1.1
    "Heating setpoint decrease value (degC) when heating demand limit level 2 is imposed"
  parameter Real decTSetDem_3=2.2
    "Heating setpoint decrease value (degC) when heating demand limit level 3 is imposed"
  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"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TOut(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Outside air temperature"
  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.RealInput cooDowTim(
    final unit="s",
    final quantity="Time")
    "Cool-down time retrieved from optimal cool-down block"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput tNexOcc
    "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.BooleanInput uOcc
    "Current occupancy period, true if it is in occupant period"
  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 TSup(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TCut(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Economizer high limit cutoff. Fixed dry bulb or differential dry bulb temeprature"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TMix(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature") if use_TMix
    "Measured mixed air temperature, used for freeze protection if use_TMix is true"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput nOcc(final unit="1")
    if have_occSen "Number of occupants"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uWin if have_winSen
    "Window status, true if open, false if closed"
  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
    "Economizer enthalpy high limit cutoff. Fixed enthalpy or differential enthalpy"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TRet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    if use_fixed_plus_differential_drybulb
    "Used only for fixed plus differential dry bulb temperature high limit cutoff"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uFreProSta
    if use_G36FrePro
    "Freeze protection status, used if use_G36FrePro=true"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TSupHeaEco(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Temperature setpoint for heating coil and for economizer"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TSupCoo(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Cooling supply air temperature setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yFan(
    final min=0,
    final max=1,
    final unit="1") "Fan speed"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonHeaSet(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Heating setpoint temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonCooSet(
    final unit="K",
    displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Cooling setpoint temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yHeaCoi(
    final min=0,
    final max=1,
    final unit="1") "Heating coil control signal"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yCooCoi(
    final min=0,
    final max=1,
    final unit="1") "Cooling coil control signal"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDamPos(
    final min=0,
    final max=1,
    final unit="1")
    "Outdoor air damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDamPos(
    final min=0,
    final max=1,
    final unit="1")
    "Return air damper position"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.ModeAndSetPoints
    modSetPoi(
    final have_winSen=have_winSen,
    final have_occSen=have_occSen,
    final THeaSetOcc=TZonHeaOn,
    final THeaSetUno=TZonHeaOff,
    final TCooSetOcc=TZonCooOn,
    final TCooSetUno=TZonCooOff,
    final cooAdj=cooAdj,
    final heaAdj=heaAdj,
    final sinAdj=sinAdj,
    final ignDemLim=ignDemLim,
    final TZonCooOnMax=TZonCooOnMax,
    final TZonCooOnMin=TZonCooOnMin,
    final TZonHeaOnMax=TZonHeaOnMax,
    final TZonHeaOnMin=TZonHeaOnMin,
    final TZonCooSetWinOpe=TZonCooSetWinOpe,
    final TZonHeaSetWinOpe=TZonHeaSetWinOpe,
    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 uLow=uLow,
    final uHigh=uHigh) "Zone setpoint and operation mode"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Supply
    setPoiVAV(
    final TSupSetMax=TSupSetMax,
    final TSupSetMin=TSupSetMin,
    final yHeaMax=yHeaMax,
    final yMin=yMin,
    final yCooMax=yCooMax)
    "Supply air set point and fan signal for single zone VAV system"
  Buildings.Controls.OBC.CDL.Reals.PIDWithReset cooPI(
    final reverseActing=false,
    final controllerType=controllerTypeCoo,
    final k=kCoo,
    final Ti=TiCoo,
    final Td=TdCoo)
    "Zone cooling control signal"
  Buildings.Controls.OBC.CDL.Reals.PIDWithReset heaPI(
    final controllerType=controllerTypeHea,
    final k=kHea,
    final Ti=TiHea,
    final Td=TdHea)
    "Zone heating control signal"
  Buildings.Controls.OBC.CDL.Reals.Average ave
    "Average of zone heating and cooling setpoint"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller
    conEco(
    final use_TMix=use_TMix,
    final use_G36FrePro=use_G36FrePro,
    final delTOutHis=uHigh - uLow,
    final delEntHis=delEntHis,
    final controllerTypeMod=controllerTypeMod,
    final kMod=kMod,
    final TiMod=TiMod,
    final TdMod=TdMod,
    final uMin=uMin,
    final uMax=uMax,
    final controllerTypeFre=controllerTypeFre,
    final kFre=kFre,
    final TiFre=TiFre,
    final TdFre=TdFre,
    final TFreSet=TFreSet,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    final yDam_VOutMin_maxSpe=yDam_VOutMin_maxSpe,
    final yDam_VOutDes_minSpe=yDam_VOutDes_minSpe,
    final yDam_VOutDes_maxSpe=yDam_VOutDes_maxSpe,
    final outDamPhyPosMax=outDamPhyPosMax,
    final outDamPhyPosMin=outDamPhyPosMin,
    final retDamPhyPosMax=retDamPhyPosMax,
    final retDamPhyPosMin=retDamPhyPosMin,
    final use_enthalpy=use_enthalpy,
    final use_fixed_plus_differential_drybulb=
        use_fixed_plus_differential_drybulb,
    final yFanMin=0,
    final yFanMax=1) "Economizer control sequence"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.OutsideAirFlow
    outAirSetPoi(
    final AFlo=AFlo,
    final have_occSen=have_occSen,
    final VOutPerAre_flow=VOutPerAre_flow,
    final VOutPerPer_flow=VOutPerPer_flow,
    final occDen=occDen,
    final zonDisEffHea=zonDisEffHea,
    final zonDisEffCoo=zonDisEffCoo,
    final uLow=uLow,
    final uHigh=uHigh) "Output the minimum outdoor airflow rate setpoint "
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.ZoneState zonSta
    "Zone state"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.CoolingCoil
    cooCoi(final controllerTypeCooCoi=controllerTypeCooCoi, kCooCoi=kCooCoi)
    "Controller for cooling coil valve"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant win(
    final k=false) if not have_winSen
    "Window status"
  Buildings.Controls.OBC.CDL.Reals.GreaterThreshold havOcc(
    final t=0.5) if have_occSen "Check if there is occupant"

equation
  connect(ave.y, setPoiVAV.TZonSet)
  connect(TCut, conEco.TCut)
  connect(conEco.TSup, TSup)
  connect(setPoiVAV.TSupHeaEco, conEco.THeaSupSet)
  connect(setPoiVAV.y, conEco.uSupFanSpe)
  connect(TMix, conEco.TMix)
  connect(setPoiVAV.TSupHeaEco, TSupHeaEco)
  connect(setPoiVAV.TSupCoo, TSupCoo)
  connect(setPoiVAV.y, yFan)
  connect(conEco.yRetDamPos, yRetDamPos)
  connect(conEco.yOutDamPos, yOutDamPos)
  connect(outAirSetPoi.TDis, TSup)
  connect(conEco.VOutMinSet_flow, outAirSetPoi.VOutMinSet_flow)
  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(outAirSetPoi.uWin, uWin)
  connect(TZon, cooPI.u_m)
  connect(nOcc, outAirSetPoi.nOcc)
  connect(uFreProSta, conEco.uFreProSta)
  connect(conEco.hOut, hOut)
  connect(conEco.hCut, hCut)
  connect(conEco.TRet, TRet)
  connect(conEco.yHeaCoi, yHeaCoi)
  connect(cooCoi.yCooCoi, yCooCoi)
  connect(switch.y, cooCoi.uSupFan)
  connect(zonSta.yZonSta, cooCoi.uZonSta)
  connect(cooCoi.TSup, TSup)
  connect(switch.y, outAirSetPoi.uSupFan)
  connect(switch.y, conEco.uSupFan)
  connect(switch.y, setPoiVAV.uFan)
  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(TZon, heaPI.u_m)
  connect(setPoiVAV.TSupCoo, cooCoi.TSupCoo)
  connect(TZon, setPoiVAV.TZon)
  connect(TZon, outAirSetPoi.TZon)
  connect(modSetPoi.TZonHeaSet, heaPI.u_s)
  connect(modSetPoi.TZonHeaSet, ave.u2)
  connect(modSetPoi.TZonHeaSet, TZonHeaSet)
  connect(modSetPoi.TZonCooSet, ave.u1)
  connect(modSetPoi.TZonCooSet, cooPI.u_s)
  connect(modSetPoi.TZonCooSet, TZonCooSet)
  connect(TZon, modSetPoi.TZon)
  connect(tNexOcc, modSetPoi.tNexOcc)
  connect(uOcc, modSetPoi.uOcc)
  connect(modSetPoi.yOpeMod, outAirSetPoi.uOpeMod)
  connect(modSetPoi.yOpeMod, conEco.uOpeMod)
  connect(modSetPoi.yOpeMod, intEqu.u1)
  connect(win.y, modSetPoi.uWin)
  connect(uWin, modSetPoi.uWin)
  connect(win.y, outAirSetPoi.uWin)
  connect(nOcc, havOcc.u)
  connect(havOcc.y, modSetPoi.uOccSen)
  connect(modSetPoi.warUpTim, warUpTim)
  connect(modSetPoi.cooDowTim, cooDowTim)
  connect(modSetPoi.uCooDemLimLev, uCooDemLimLev)
  connect(modSetPoi.uHeaDemLimLev, uHeaDemLimLev)
end Controller;


Controller for cooling coil valve. This block outputs the cooling coil control signal if the fan is on and the zone status
is uZonSta = Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.cooling.
Otherwise, the control signal for the coil is set to 0.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV;
model CoolingCoil "Controller for cooling coil valve"

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

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TSupCoo(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Cooling supply air temperature setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TSup(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Supply air temperature measurement"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uZonSta "Zone state"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uSupFan "Supply fan status"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yCooCoi "Cooling coil control signal"

  Buildings.Controls.OBC.CDL.Reals.PIDWithReset cooCoiPI(
    final reverseActing=false,
    final controllerType=controllerTypeCooCoi,
    final k=kCooCoi,
    final Ti=TiCooCoi,
    final Td=TdCooCoi) "Cooling coil control signal"

protected
  Buildings.Controls.OBC.CDL.Integers.Equal intEqu
    "Logical block to check if zone is in cooling state"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant conInt(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.cooling)
    "Cooling state value"
  Buildings.Controls.OBC.CDL.Reals.Switch switch "Switch to assign cooling coil control signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant const(k=0) "Cooling off mode"
  Buildings.Controls.OBC.CDL.Logical.And and2 "Conditions for cooling state"

equation
  connect(const.y, switch.u3)
  connect(cooCoiPI.trigger, uSupFan)
  connect(cooCoiPI.u_s, TSupCoo)
  connect(cooCoiPI.u_m, TSup)
  connect(switch.y, yCooCoi)
  connect(intEqu.y, and2.u1)
  connect(and2.u2, uSupFan)
  connect(and2.y, switch.u2)
  connect(conInt.y, intEqu.u1)
  connect(uZonSta, intEqu.u2)
  connect(cooCoiPI.y, switch.u1)
end CoolingCoil;


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


Select the zone state. Block that outputs the zone state. It first checks if the zone is in heating state;
if not, it checks if the zone is in cooling state; otherwise it is in deadband state.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV;
block ZoneState "Select the zone state"
  parameter Real uLow(final unit = "1") = 0.01
    "Hysteresis parameter uLow for heating and cooling control signals to avoid chattering";
  parameter Real uHigh(final unit = "1") = 0.05
    "Hysteresis parameter uHigh for heating and cooling control signals to avoid chattering";

  Buildings.Controls.OBC.CDL.Interfaces.RealInput uHea "Heating control signal"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uCoo "Cooling control signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yZonSta "Zone state"

protected
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToIntHea(
    final integerFalse=0,
    final integerTrue=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.heating)
    "Convert Boolean to Integer number"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToIntCoo(
    final integerFalse=0,
    final integerTrue=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.cooling)
    "Convert Boolean to Integer number"
  Buildings.Controls.OBC.CDL.Logical.Nor isDea "In deadband state"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToIntDea(
    final integerFalse=0,
    final integerTrue=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.deadband)
    "Convert Boolean to Integer number"
  Buildings.Controls.OBC.CDL.Logical.And isHea "In heating state if both conditions are true"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysUHea(
    final uLow=uLow,
    final uHigh=uHigh)
    "Check if it is in heating state"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysUCoo(
    final uLow=uLow,
    final uHigh=uHigh)
    "Check if it is in cooling state"
  Buildings.Controls.OBC.CDL.Reals.Subtract uHeaMinUCoo
    "Difference between uHea and uCoo"
  Buildings.Controls.OBC.CDL.Logical.And isCoo "In cooling state if both inputs are true"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysU(
    final uLow=-uLow,
    final uHigh=uLow)
    "Check if heating control signal is bigger than cooling control signal"
  Buildings.Controls.OBC.CDL.Logical.Not notHea "Not in heating state"
  Buildings.Controls.OBC.CDL.Integers.Add addInt "Add two integer inputs"
  Buildings.Controls.OBC.CDL.Integers.Add addInt1 "Add two integer inputs"

equation
  connect(isDea.y, booToIntDea.u)
  connect(hysUHea.y, isHea.u1)
  connect(uHea, hysUHea.u)
  connect(uCoo,hysUCoo. u)
  connect(uCoo, uHeaMinUCoo.u2)
  connect(uHea, uHeaMinUCoo.u1)
  connect(isCoo.y, booToIntCoo.u)
  connect(hysUCoo.y, isCoo.u2)
  connect(uHeaMinUCoo.y, hysU.u)
  connect(isHea.y, booToIntHea.u)
  connect(isHea.y, notHea.u)
  connect(hysU.y, isHea.u2)
  connect(notHea.y, isCoo.u1)
  connect(isCoo.y, isDea.u2)
  connect(isHea.y, isDea.u1)
  connect(booToIntHea.y, addInt.u1)
  connect(booToIntCoo.y, addInt.u2)
  connect(addInt.y, addInt1.u1)
  connect(booToIntDea.y, addInt1.u2)
  connect(addInt1.y, yZonSta)
end ZoneState;


Single zone VAV AHU economizer control sequence. Single zone VAV AHU economizer control sequence that calculates
outdoor and return air damper positions based on ASHRAE
Guidline 36, PART 5 sections: P.4.d, P.5, P.9, P.3.b, A.17.

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

  parameter Boolean use_enthalpy = false
    "Set to true if enthalpy measurement is used in addition to temperature measurement"
  parameter Boolean use_fixed_plus_differential_drybulb = false
    "Set to true to only evaluate fixed plus differential dry bulb temperature high limit cutoff;
    shall not be used with enthalpy"
  parameter Boolean use_TMix=true
    "Set to true if mixed air temperature measurement is enabled";
  parameter Boolean use_G36FrePro=false
    "Set to true if G36 freeze protection is implemented";

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

  parameter Real delEntHis(
    final unit="J/kg",
    final quantity="SpecificEnergy")=1000
    "Delta between the enthalpy hysteresis high and low 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 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 controllerTypeFre=
    Buildings.Controls.OBC.CDL.Types.SimpleController.PI
    "Type of controller"

  parameter Real kFre(final unit="1/K") = 0.1
    "Gain for mixed air temperature tracking for freeze protection, used if use_TMix=true"

  parameter Real TiFre(
    final unit="s",
    final quantity="Time")=120
    "Time constant of controller for mixed air temperature tracking for freeze protection. Require TiFre < TiMinOut"

  parameter Real TdFre(
    final unit="s",
    final quantity="Time")=0.1
     "Time constant of derivative block for freeze protection"

  parameter Real TFreSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature") = 277.15
    "Lower limit for mixed air temperature for freeze protection, used if use_TMix=true"

  parameter Real yFanMin(
    final min=0,
    final max=1,
    final unit="1") = 0.1 "Minimum supply fan operation speed"
  parameter Real yFanMax(
    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 yDam_VOutMin_minSpe(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1") = 0.4
    "Outdoor air damper position to supply minimum outdoor airflow at minimum fan speed"
  parameter Real yDam_VOutMin_maxSpe(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1") = 0.3
    "Outdoor air damper position to supply minimum outdoor airflow at maximum fan speed"
  parameter Real yDam_VOutDes_minSpe(
    final min=yDam_VOutMin_minSpe,
    final max=outDamPhyPosMax,
    final unit="1") = 0.9
    "Outdoor air damper position to supply design outdoor airflow at minimum fan speed"
  parameter Real yDam_VOutDes_maxSpe(
    final min=yDam_VOutMin_maxSpe,
    final max=outDamPhyPosMax,
    final unit="1") = 0.8
    "Outdoor air damper position to supply design outdoor airflow at maximum fan speed"
  parameter Real outDamPhyPosMax(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the outdoor air damper"
  parameter Real outDamPhyPosMin(
    final min=0,
    final max=1,
    final unit="1") = 0
    "Physically fixed minimum position of the outdoor air damper"
  parameter Real retDamPhyPosMax(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the return air damper"
  parameter Real retDamPhyPosMin(
    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 THeaSupSet(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Supply air temperature heating setpoint"
  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 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")
    "Outdoor air temperature high limit cutoff. For differential dry bulb temeprature condition use return air temperature measurement"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TRet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    if use_fixed_plus_differential_drybulb
    "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 use_enthalpy "Outdoor air enthalpy"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput hCut(final unit="J/kg",
      final quantity="SpecificEnergy")
                                     if use_enthalpy
    "Outdoor air enthalpy high limit cutoff. For differential enthalpy use return air enthalpy measurement"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TMix(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature") if use_TMix
    "Measured mixed air temperature, used for freeze protection"

  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 uSupFanSpe(
    final min=yFanMin,
    final max=yFanMax,
    final unit="1")
    "Supply fan speed"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uZonSta "Zone state signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uFreProSta if use_G36FrePro
    "Freeze protection status"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uOpeMod "AHU operation mode status signal"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uSupFan "Supply fan status"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDamPos(
    final min=0,
    final max=1,
    final unit="1")
    "Return air damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDamPos(
    final min=0,
    final max=1,
    final unit="1")
    "Outdoor air damper position"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis(
    final retDamPhyPosMax=retDamPhyPosMax,
    final use_enthalpy=use_enthalpy,
    final use_fixed_plus_differential_drybulb=
        use_fixed_plus_differential_drybulb,
    final delTOutHis=delTOutHis,
    final delEntHis=delEntHis,
    final retDamPhyPosMin=retDamPhyPosMin)
    "Single zone VAV AHU economizer enable/disable sequence"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits
    damLim(
    final yFanMin=yFanMin,
    final yFanMax=yFanMax,
    final outDamPhyPosMax=outDamPhyPosMax,
    final outDamPhyPosMin=outDamPhyPosMin,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    final yDam_VOutMin_minSpe=yDam_VOutMin_minSpe,
    final yDam_VOutMin_maxSpe=yDam_VOutMin_maxSpe,
    final yDam_VOutDes_minSpe=yDam_VOutDes_minSpe,
    final yDam_VOutDes_maxSpe=yDam_VOutDes_maxSpe)
    "Single zone VAV AHU economizer minimum outdoor air requirement damper limit sequence"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Modulation
    mod(
    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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Generic.FreezeProtectionMixedAir
    freProTMix(
    final controllerType=controllerTypeFre,
    final k=kFre,
    final Ti=TiFre,
    final Td=TdFre,
    final TFreSet=TFreSet) if use_TMix
    "Block that tracks TMix against a freeze protection setpoint"

protected
  Buildings.Controls.OBC.CDL.Reals.Max retDamMinFre
    "Minimum position for return air damper due to freeze protection"
  Buildings.Controls.OBC.CDL.Reals.Min outDamMaxFre
    "Maximum control signal for outdoor air damper due to freeze protection"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant noTMix1(k=1) if not use_TMix
    "Ignore min evaluation if there is no TMix sensor"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant noTMix(k=0) if not use_TMix
    "Ignore max evaluation if there is no TMix sensor"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.FreezeProtectionStages.stage0)
                                                                                if not use_G36FrePro
    "Freeze protection status is 0. Used if G36 freeze protection is not implemented"

public
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yHeaCoi
    "Heating coil control signal"
equation
  connect(uSupFan, enaDis.uSupFan)
  connect(uFreProSta, enaDis.uFreProSta)
  connect(TRet, enaDis.TRet)
  connect(hCut, enaDis.hCut)
  connect(hOut, enaDis.hOut)
  connect(TCut, enaDis.TCut)
  connect(TOut, enaDis.TOut)
  connect(uSupFan, damLim.uSupFan)
  connect(uOpeMod, damLim.uOpeMod)
  connect(uFreProSta, damLim.uFreProSta)
  connect(damLim.yOutDamPosMax, enaDis.uOutDamPosMax)
  connect(enaDis.yOutDamPosMax, mod.uOutDamPosMax)
  connect(enaDis.yRetDamPosMax, mod.uRetDamPosMax)
  connect(damLim.yOutDamPosMin, mod.uOutDamPosMin)
  connect(enaDis.yRetDamPosMin, mod.uRetDamPosMin)
  connect(uZonSta, enaDis.uZonSta)
  connect(uSupFanSpe, damLim.uSupFanSpe)
  connect(VOutMinSet_flow, damLim.VOutMinSet_flow)
  connect(outDamMaxFre.u2, noTMix1.y)
  connect(retDamMinFre.u1, noTMix.y)
  connect(retDamMinFre.y, yRetDamPos)
  connect(outDamMaxFre.y, yOutDamPos)
  connect(mod.yRetDamPos, retDamMinFre.u2)
  connect(mod.yOutDamPos, outDamMaxFre.u1)
  connect(freProTMix.yFrePro, retDamMinFre.u1)
  connect(freProTMix.yFreProInv, outDamMaxFre.u2)
  connect(freProSta.y, enaDis.uFreProSta)
  connect(freProSta.y, damLim.uFreProSta)
  connect(uSupFan, mod.uSupFan)

  connect(mod.yHeaCoi, yHeaCoi)
  connect(damLim.yOutDamPosMin, enaDis.uOutDamPosMin)
  connect(TMix, freProTMix.TMix)
  connect(TSup, mod.TSup)
  connect(THeaSupSet, mod.THeaSupSet)
end Controller;


within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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 ASHRAE G36 PART 5.5 and PART 5.A.17. Additional
conditions included in the sequence are:

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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 Boolean use_fixed_plus_differential_drybulb = false
    "Set to true to evaluate fixed plus differential dry bulb temperature high limit cutoff;
    shall not be used with enthalpy"
  parameter Real delTOutHis(
    final unit="K",
    final displayUnit="K",
    final quantity="TemperatureDifference")=1
    "Delta between the temperature hysteresis high and low limit"
  parameter Real delEntHis(
    final unit="J/kg",
    final quantity="SpecificEnergy")=1000
    "Delta between the enthalpy hysteresis high and low limits"
  parameter Real retDamPhyPosMax(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the return air damper"
  parameter Real retDamPhyPosMin(
    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 hOut(
    final unit="J/kg",
    final quantity="SpecificEnergy") if use_enthalpy
    "Outdoor air enthalpy"
  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 temeprature condition use return air temperature measurement"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TRet(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature") if use_fixed_plus_differential_drybulb
    "Used only for fixed plus differential dry bulb temperature high limit cutoff"
  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.RealInput uOutDamPosMin(
    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.RealInput uOutDamPosMax(
    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.BooleanInput uSupFan
    "Supply fan on/off status signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uZonSta
    "Zone state status signal"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uFreProSta
    "Freeze protection stage status signal"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDamPosMax(
    final min=0,
    final max=1,
    final unit="1")
    "Maximum outdoor air damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDamPosMin(
    final min=retDamPhyPosMin,
    final max=retDamPhyPosMax,
    final unit="1")
    "Minimum return air damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDamPosMax(
    final min=retDamPhyPosMin,
    final max=retDamPhyPosMax,
    final unit="1")
    "Maximum return air damper position"

  Buildings.Obsolete.Controls.OBC.CDL.Logical.And3 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"
  Buildings.Controls.OBC.CDL.Logical.Xor xor
    "Either fixed+differential temperature cutoff or others"
protected
  final parameter Real TOutHigLimCutHig(
    final unit="K",
    final displayUnit="K",
    final quantity="TemperatureDifference") = 0
    "Hysteresis high limit cutoff";
  final parameter Real TOutHigLimCutLow = TOutHigLimCutHig - delTOutHis
    "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 - delEntHis
    "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 retDamPhyPosMinSig(
    final k=retDamPhyPosMin)
    "Physically fixed minimum position of the return air damper"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant retDamPhyPosMaxSig(
    final k=retDamPhyPosMax)
    "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 outDamSwitch "Set maximum OA damper position to minimum at disable (after time delay)"
  Buildings.Controls.OBC.CDL.Reals.Switch minRetDamSwitch
    "Keep minimum RA damper position at physical maximum for a short time period after disable"
  Buildings.Controls.OBC.CDL.Logical.Nor nor1 "Logical nor"
  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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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.Reals.Subtract sub3
     if use_fixed_plus_differential_drybulb
    "Add block that determines difference the between TOut and TOutCut"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysCutTem(final uHigh=
        TOutHigLimCutHig, final uLow=TOutHigLimCutLow) if use_fixed_plus_differential_drybulb
    "Outdoor air temperature hysteresis for both fixed and differential dry bulb temperature cutoff conditions"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant entSubst1(final k=false)
    if not use_fixed_plus_differential_drybulb
    "Deactivates the option if not using both fixed and differential dry bulb"
  Buildings.Controls.OBC.CDL.Logical.Nor nor2
    if use_fixed_plus_differential_drybulb "Logical nor"
equation
  connect(outDamSwitch.y, yOutDamPosMax)
  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(hysOutTem.y, nor1.u1)
  connect(hysOutEnt.y, nor1.u2)
  connect(entSubst.y, nor1.u2)
  connect(uOutDamPosMin, outDamSwitch.u1)
  connect(uOutDamPosMax, outDamSwitch.u3)
  connect(andEnaDis.y, not2.u)
  connect(minRetDamSwitch.y, yRetDamPosMin)
  connect(truFalHol.y, and1.u1)
  connect(and1.y, andEnaDis.u1)
  connect(uSupFan, and1.u2)
  connect(retDamPhyPosMaxSig.y, minRetDamSwitch.u1)
  connect(retDamPhyPosMinSig.y, minRetDamSwitch.u3)
  connect(retDamPhyPosMaxSig.y, yRetDamPosMax)
  connect(not2.y, minRetDamSwitch.u2)
  connect(not2.y, outDamSwitch.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(intEqu.y, andEnaDis.u2)
  connect(not3.y, andEnaDis.u3)
  connect(TRet, sub3.u2)
  connect(TOut, sub3.u1)
  connect(sub3.y, hysCutTem.u)
  connect(hysCutTem.y, nor2.u2)
  connect(nor2.u1, hysOutTem.y)
  connect(nor2.y, xor.u1)
  connect(entSubst1.y, xor.u1)
  connect(nor1.y, xor.u2)
  connect(xor.y, truFalHol.u)
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),
designed in line with ASHRAE Guidline 36, PART 5.P.4.d.

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

  parameter Real yFanMin(
    final min=0,
    final max=1,
    final unit="1") = 0.1 "Minimum supply fan operation speed"
  parameter Real yFanMax(
    final min=0,
    final max=1,
    final unit="1") = 1 "Maximum supply fan operation speed"
  parameter Real yDam_VOutMin_minSpe(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1") = 0.4
    "OA damper position to supply minimum outdoor airflow at minimum fan speed"
  parameter Real yDam_VOutMin_maxSpe(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1") = 0.3
    "OA damper position to supply minimum outdoor airflow at maximum fan speed"
  parameter Real yDam_VOutDes_minSpe(
    final min=yDam_VOutMin_minSpe,
    final max=outDamPhyPosMax,
    final unit="1") = 0.9
    "OA damper position to supply design outdoor airflow at minimum fan speed"
  parameter Real yDam_VOutDes_maxSpe(
    final min=yDam_VOutMin_maxSpe,
    final max=outDamPhyPosMax,
    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 outDamPhyPosMax(
    final min=0,
    final max=1,
    final unit="1") = 1
    "Physically fixed maximum position of the outdoor air damper"
  parameter Real outDamPhyPosMin(
    final min=0,
    final max=1,
    final unit="1") = 0
    "Physically fixed minimum position of the outdoor air damper"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput uSupFanSpe(
    final min=0,
    final max=1,
    final unit="1")
    "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 uSupFan
    "Supply fan status signal"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDamPosMin(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1")
    "Minimum outdoor air damper position limit"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDamPosMax(
    final min=outDamPhyPosMin,
    final max=outDamPhyPosMax,
    final unit="1")
    "Maximum outdoor air damper position limit"

protected
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yFanMinSig(
    final k=yFanMin) "Minimum supply fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPhyPosMinSig(
    final k=outDamPhyPosMin)
    "Physically fixed minimum position of the outdoor air damper"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPhyPosMaxSig(
    final k=outDamPhyPosMax)
    "Physically fixed maximum position of the outdoor air damper"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yFanMaxSig(
    final k=yFanMax) "Maximum supply fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutMin_minSpeSig(
    final k=yDam_VOutMin_minSpe)
    "OA damper position to supply minimum outdoor airflow at minimum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutDes_minSpeSig(
    final k=yDam_VOutDes_minSpe)
    "OA damper position to supply design outdoor airflow at minimum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutMin_maxSpeSig(
    final k=yDam_VOutMin_maxSpe)
    "OA damper position to supply minimum outdoor airflow at maximum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant yDam_VOutDes_maxSpeSig(
    final k=yDam_VOutDes_maxSpe)
    "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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.OperationModes.occupied)
    "Occupied mode index"
  Buildings.Controls.OBC.CDL.Integers.Equal intEqu1 "Check if operation mode is occupied"
  Buildings.Obsolete.Controls.OBC.CDL.Logical.And3 and3 "Logical and"

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(enaDis.y, yOutDamPosMin)
  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(uSupFanSpe, 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(uSupFanSpe, 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, yOutDamPosMax)
  connect(not1.y, enaDis1.u2)
  connect(uOpeMod, intEqu1.u1)
  connect(conInt1.y, intEqu1.u2)
  connect(intLesEqu.u2, conInt.y)
  connect(uFreProSta, intLesEqu.u1)
  connect(uSupFan, and3.u1)
  connect(intLesEqu.y, and3.u2)
  connect(intEqu1.y, and3.u3)
  connect(and3.y, not1.u)
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 ASHRAE
Guidline 36 (G36), PART 5.P.3.b. 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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Limits and

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

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

  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 THeaSupSet(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature") "Supply air temperature heating setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uSupFan "Supply fan status"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uOutDamPosMin(
    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 uOutDamPosMax(
    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 uRetDamPosMin(
    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 uRetDamPosMax(
    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") "Heating coil control signal"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yOutDamPos(
    final min=0,
    final max=1,
    final unit="1") "Economizer damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yRetDamPos(
    final min=0,
    final max=1,
    final unit="1") "Return air damper 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)
    "Heating coil signal is linearly proportional to the control signal between signal limits"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant heaCoiMaxLimSig(final k=1)
    "Maximal control loop signal for the heating coil"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant heaCoiMinLimSig(final k=0)
    "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 "Enable or disable the heating coil"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant Off(
    final k=0) "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(THeaSupSet, 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(uOutDamPosMin, outDamPos.f2)
  connect(uRetDamPosMin, retDamPos.f1)
  connect(uRetDamPosMax, retDamPos.f2)
  connect(Off.y, enaDis.u3)
  connect(uSupFan, enaDis.u2)
  connect(HeaCoi.y, enaDis.u1)
  connect(enaDis.y, yHeaCoi)
  connect(uOutDamPosMax, outDamPos.f1)
  connect(retDamPos.y, yRetDamPos)
  connect(outDamPos.y, yOutDamPos)
  connect(uSupFan, uTSup.trigger)
end Modulation;


Subsequences for economizer control

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
for the zone state and freeze protection stage control signals.

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

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Enable
    enaDis "Single zone VAV AHU enable disable sequence"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.FreezeProtectionStages.stage0)
    "Freeze protection status is stage0"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant zonSta(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.heating)
    "Zone state is heating"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta1(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.FreezeProtectionStages.stage1)
    "Freeze protection status is stage1"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant zonSta1(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.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, enaDis.TCut)
  connect(TOutCut.y, enaDis1.TCut)
  connect(TOutBelowCutoff.y, enaDis1.TOut)
  connect(hOutBelowCutoff.y, enaDis.hOut)
  connect(hOutCut.y, enaDis.hCut)
  connect(hOutBelowCutoff.y, enaDis1.hOut)
  connect(hOutCut.y, enaDis1.hCut)
  connect(zonSta.y, enaDis.uZonSta)
  connect(freProSta.y, enaDis.uFreProSta)
  connect(freProSta1.y, enaDis1.uFreProSta)
  connect(zonSta1.y, enaDis1.uZonSta)
  connect(outDamPosMax.y, enaDis.uOutDamPosMax)
  connect(outDamPosMin.y, enaDis.uOutDamPosMin)
  connect(outDamPosMin.y, enaDis1.uOutDamPosMin)
  connect(outDamPosMax.y, enaDis1.uOutDamPosMax)
  connect(supFanSta.y, enaDis.uSupFan)
  connect(supFanSta.y, enaDis1.uSupFan)
end Enable_FreProSta_ZonSta;