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

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

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

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut(
    final k=TOutCutoff) "Outdoor air temperature cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutCut1(
    final k=hOutCutoff) "Outdoor air enthalpy cutoff"
  Buildings.Obsolete.Controls.OBC.CDL.Logical.TriggeredTrapezoid TOut(
    final rising=1000,
    final falling=800,
    final amplitude=4,
    final offset=TOutCutoff - 2) "Outoor air temperature"
  Buildings.Obsolete.Controls.OBC.CDL.Logical.TriggeredTrapezoid hOut(
    final amplitude=4000,
    final offset=hOutCutoff - 2200,
    final rising=1000,
    final falling=800) "Outdoor air enthalpy"

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

  Enable enaDis4(use_enthalpy=false, use_fixed_plus_differential_drybulb=true)
    "Test fixed and differential dry bulb"
  Buildings.Obsolete.Controls.OBC.CDL.Logical.TriggeredTrapezoid TRet(
    final rising=1000,
    final falling=800,
    final amplitude=4,
    final offset=TOutCutoff - 4) "Outoor air temperature"
protected
  final parameter Real TOutCutoff(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")=297.15
    "Outdoor temperature high limit cutoff";
  final parameter Real hOutCutoff(
    final unit="J/kg",
    final quantity = "SpecificEnergy")=65100
    "Outdoor air enthalpy high limit cutoff";
  final parameter Real outDamPosMin=0.1
    "Minimum outdoor air damper position";
  final parameter Real outDamPosMax=0.9
    "Minimum return air damper position";
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutCut(
    final k=hOutCutoff) "Outdoor air enthalpy cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut1(
    final k=TOutCutoff) "Outdoor air temperature cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutBelowCutoff(
    final k=hOutCutoff - 1000)
    "Outdoor air enthalpy is slightly below the cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutBelowCutoff(
    final k=TOutCutoff - 2)
    "Outdoor air temperature is slightly below the cutoff"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant zoneState(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.deadband)
                                                                             "Zone State is deadband"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMaxSig(
    final k=outDamPosMax)
    "Maximal allowed economizer damper position"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMinSig(
    final k=outDamPosMin)
    "Minimal allowed economizer damper position"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.FreezeProtectionStages.stage0)
    "Freeze Protection Status - Disabled"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant supFanSta(
    final k=true) "Supply fan status signal"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul(
    final shift=10,
    final period=2000) "Boolean pulse signal"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
    final shift=10,
    final period=2000) "Boolean pulse signal"
  Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul2(final shift=10,
      final period=2000) "Boolean pulse signal"
equation
  connect(TOutCut.y, enaDis.TCut)
  connect(hOutCut.y, enaDis.hCut)
  connect(freProSta.y, enaDis.uFreProSta)
  connect(outDamPosMaxSig.y, enaDis.uOutDamPosMax)
  connect(outDamPosMinSig.y, enaDis.uOutDamPosMin)
  connect(enaDis.uZonSta, zoneState.y)
  connect(TOutCut1.y, enaDis1.TCut)
  connect(hOutCut1.y, enaDis1.hCut)
  connect(hOutBelowCutoff.y, enaDis.hOut)
  connect(TOutBelowCutoff.y, enaDis1.TOut)
  connect(booPul.y, TOut.u)
  connect(TOut.y, enaDis.TOut)
  connect(booPul1.y, hOut.u)
  connect(hOut.y, enaDis1.hOut)
  connect(freProSta.y, enaDis1.uFreProSta)
  connect(zoneState.y, enaDis1.uZonSta)
  connect(outDamPosMaxSig.y, enaDis1.uOutDamPosMax)
  connect(outDamPosMinSig.y, enaDis1.uOutDamPosMin)
  connect(TOut.y, enaDis2.TOut)
  connect(TOutCut.y, enaDis2.TCut)
  connect(freProSta.y, enaDis2.uFreProSta)
  connect(zoneState.y, enaDis2.uZonSta)
  connect(outDamPosMaxSig.y, enaDis2.uOutDamPosMax)
  connect(outDamPosMinSig.y, enaDis2.uOutDamPosMin)
  connect(supFanSta.y, enaDis.uSupFan)
  connect(supFanSta.y, enaDis1.uSupFan)
  connect(supFanSta.y, enaDis2.uSupFan)
  connect(enaDis4.uFreProSta, enaDis2.uFreProSta)
  connect(enaDis4.uZonSta, enaDis2.uZonSta)
  connect(enaDis4.uSupFan, enaDis2.uSupFan)
  connect(enaDis4.uOutDamPosMax, enaDis2.uOutDamPosMax)
  connect(enaDis4.uOutDamPosMin, enaDis2.uOutDamPosMin)
  connect(TOutCut1.y, enaDis4.TCut)
  connect(TOutBelowCutoff.y, enaDis4.TOut)
  connect(booPul2.y, TRet.u)
  connect(TRet.y, enaDis4.TRet)
end Enable_TOut_hOut;


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

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

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

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

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

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

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


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

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

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

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

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


Validation model for single zone VAV AHU outdoor and return air damper position modulation sequence. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Modulation
for supply air temeperature TSup and supply air temperature heating setpoint TSupSet
control signals.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Validation;
model Modulation_TSup
  "Validation model for single zone VAV AHU outdoor and return air damper position modulation sequence"

  final parameter Real TSupSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")=291.15
    "Supply air temperature setpoint";

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Subsequences.Modulation
    mod "Economizer modulation sequence"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TSupSetSig(
    final k=TSupSet) "Supply air temperature setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup(
    final duration=900,
    final height=4,
    final offset=TSupSet - 2) "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMin(final k=0.1)
    "Minimum outdoor air damper position"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPosMax(final k=0.9)
    "Maximum outdoor air damper position"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant RetDamPosMin(final k=0.1)
    "Minimum return air damper position"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant RetDamPosMax(final k=0.9)
    "Maximum return air damper position"

  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanStatus(k=true)
    "Fan is on"
equation
  connect(TSupSetSig.y, mod.THeaSupSet)
  connect(TSup.y,mod.TSup)
  connect(RetDamPosMax.y, mod.uRetDamPosMax)
  connect(RetDamPosMin.y, mod.uRetDamPosMin)
  connect(outDamPosMax.y, mod.uOutDamPosMax)
  connect(outDamPosMin.y, mod.uOutDamPosMin)
  connect(mod.uSupFan, fanStatus.y)
end Modulation_TSup;


Collection of validation models

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


Validation model for disabling the single zone VAV AHU economizer modulation and damper position limit control loops. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller
for control signals which disable modulation control loop only (economizer block)
and both minimum outdoor airflow and modulation control loops (economizer1 block).

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Validation;
model Controller_Disable
  "Validation model for disabling the single zone VAV AHU economizer modulation and damper position limit control loops"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller
    economizer(
    final use_enthalpy=true,
    final yFanMin=yFanMin,
    final yFanMax=yFanMax,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    use_TMix=false,
    use_G36FrePro=true) "Single zone VAV AHU economizer"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller
    economizer1(
    final use_enthalpy=true,
    final yFanMin=yFanMin,
    final yFanMax=yFanMax,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    use_TMix=false,
    use_G36FrePro=true) "Single zone VAV AHU economizer"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller
    economizer2(
    final yFanMin=yFanMin,
    final yFanMax=yFanMax,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    use_TMix=true,
    use_G36FrePro=false,
    final use_enthalpy=false) "Single zone VAV AHU economizer"

protected
  final parameter Real TOutCutoff(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")=297.15
    "Outdoor temperature high limit cutoff";
  final parameter Real hOutCutoff(
    final unit="J/kg",
    final quantity="SpecificEnergy")=65100
    "Outdoor air enthalpy high limit cutoff";
  final parameter Real TSupSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")=291.15 "Supply air temperature setpoint";
  final parameter Real yFanMin(
    final min=0,
    final max=1,
    final unit="1")=0.1 "Minimum supply fan operation speed";
  final parameter Real yFanMax(
    final min=0,
    final max=1,
    final unit="1")=0.9 "Maximum supply fan operation speed";
  final parameter Real VOutMin_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=1.0
    "Calculated minimum outdoor airflow rate";
  final parameter Real VOutDes_flow(
    final unit="m3/s",
    final quantity="VolumeFlowRate")=2.0
    "Calculated design outdoor airflow rate";

  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanSta(
    final k=true) "Fan is on"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.FreezeProtectionStages.stage0)
    "Freeze protection stage is 0"
  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 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 hOutBelowCutoff(
    final k=hOutCutoff - 40000)
    "Outdoor air enthalpy is below the cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TSupSetSig(
    final k=TSupSet) "Heating supply air temperature setpoint"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta2(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.FreezeProtectionStages.stage2)
    "Freeze protection stage is 2"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant hOutCut(
    final k=hOutCutoff) "Outdoor air enthalpy cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutBelowCutoff(
    final k=TOutCutoff - 30)
    "Outdoor air temperature is below the cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut1(
    final k=TOutCutoff) "Outdoor temperature high limit cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup(
    final height=4,
    final offset=TSupSet - 2,
    final duration=1800) "Supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp VOutMinSetSig(
    final duration=1800,
    final offset=VOutMin_flow,
    final height=VOutDes_flow - VOutMin_flow)
    "Minimum outdoor airflow setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp SupFanSpeSig(
    final duration=1800,
    final offset=yFanMin,
    final height=yFanMax - yFanMin) "Supply fan speed signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin sin1(
    amplitude=20,
    freqHz=1/1800,
    offset=272.15,
    startTime=0) "Mixed air temperature"

equation
  connect(fanSta.y, economizer.uSupFan)
  connect(freProSta.y, economizer.uFreProSta)
  connect(TOutBelowCutoff.y, economizer.TOut)
  connect(TOutCut1.y,economizer.TCut)
  connect(hOutBelowCutoff.y, economizer.hOut)
  connect(hOutCut.y,economizer.hCut)
  connect(TSup.y, economizer.TSup)
  connect(TSupSetSig.y, economizer.THeaSupSet)
  connect(TOutCut1.y,economizer1.TCut)
  connect(TOutBelowCutoff.y, economizer1.TOut)
  connect(hOutCut.y,economizer1.hCut)
  connect(hOutBelowCutoff.y, economizer1.hOut)
  connect(TSup.y, economizer1.TSup)
  connect(TSupSetSig.y, economizer1.THeaSupSet)
  connect(fanSta.y, economizer1.uSupFan)
  connect(freProSta2.y, economizer1.uFreProSta)
  connect(zonSta.y, economizer.uZonSta)
  connect(opeMod.y, economizer.uOpeMod)
  connect(opeMod.y, economizer1.uOpeMod)
  connect(zonSta.y, economizer1.uZonSta)
  connect(VOutMinSetSig.y, economizer.VOutMinSet_flow)
  connect(SupFanSpeSig.y, economizer.uSupFanSpe)
  connect(VOutMinSetSig.y, economizer1.VOutMinSet_flow)
  connect(SupFanSpeSig.y, economizer1.uSupFanSpe)
  connect(fanSta.y, economizer2.uSupFan)
  connect(TOutBelowCutoff.y, economizer2.TOut)
  connect(TOutCut1.y,economizer2.TCut)
  connect(TSup.y, economizer2.TSup)
  connect(TSupSetSig.y, economizer2.THeaSupSet)
  connect(VOutMinSetSig.y, economizer2.VOutMinSet_flow)
  connect(SupFanSpeSig.y, economizer2.uSupFanSpe)
  connect(sin1.y, economizer2.TMix)
  connect(opeMod.y, economizer2.uOpeMod)
  connect(zonSta.y, economizer2.uZonSta)
end Controller_Disable;


Validation model for single zone VAV AHU economizer operation: damper modulation and minimum ooutdoor air requirement damper position limits. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller control loops:
minimum outdoor air damper position limits control loop (economizer block) and modulation
control loop (economizer1 block) for VOut_flow and TSup control signals.
Both control loops are enabled during the validation test.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Validation;
model Controller_Mod_DamLim
  "Validation model for single zone VAV AHU economizer operation: damper modulation and minimum ooutdoor air requirement damper position limits"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller
    economizer(
    final use_enthalpy=true,
    final yFanMin=yFanMin,
    final yFanMax=yFanMax,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    use_G36FrePro=true,
    use_TMix=false) "Single zone VAV AHU economizer"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Economizers.Controller
    economizer1(
    final use_enthalpy=false,
    final yFanMin=yFanMin,
    final yFanMax=yFanMax,
    final VOutMin_flow=VOutMin_flow,
    final VOutDes_flow=VOutDes_flow,
    use_G36FrePro=true,
    use_TMix=false) "Single zone VAV AHU economizer"

protected
  parameter Real TOutCutoff(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")=297.15
    "Outdoor temperature high limit cutoff";
  parameter Real hOutCutoff(
    final unit="J/kg",
    final quantity="SpecificEnergy")=65100
    "Outdoor air enthalpy high limit cutoff";
  parameter Real TSupSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")=291.15
    "Supply air temperature Heating setpoint";
  parameter Real TSup(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")=290.15
    "Measured supply air temperature";
  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";

  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanSta(
    k=true) "Fan is on"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant freProSta(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.FreezeProtectionStages.stage0)
    "Freeze protection status is 0"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant zonSta(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.ZoneStates.deadband)
    "Zone State is deadband"
  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 hOutBelowCutoff(
    final k=hOutCutoff - 10000)
    "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.Reals.Sources.Constant TOutBelowCutoff(
    final k=TOutCutoff - 5)
    "Outdoor air temperature is slightly below the cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOutCut1(
    final k=TOutCutoff) "Outdoor temperature high limit cutoff"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TSupSetSig(
    final k=TSupSet) "Heating supply air temperature setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TSupSig(
    final k=TSup) "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSupSig1(
    final duration=900,
    final height=2,
    final offset=TSupSet - 1) "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp VOutMinSetSig(
    final duration=1800,
    final offset=VOutMin_flow,
    final height=VOutDes_flow - VOutMin_flow) "Minimum outdoor airflow setpoint"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp SupFanSpeSig(
    final duration=1800,
    final offset=yFanMin,
    final height=yFanMax - yFanMin) "Supply fan speed signal"

equation
  connect(fanSta.y, economizer.uSupFan)
  connect(freProSta.y, economizer.uFreProSta)
  connect(opeMod.y, economizer.uOpeMod)
  connect(zonSta.y, economizer.uZonSta)
  connect(TOutBelowCutoff.y, economizer.TOut)
  connect(TOutCut1.y,economizer.TCut)
  connect(hOutBelowCutoff.y, economizer.hOut)
  connect(hOutCut.y,economizer.hCut)
  connect(TSupSetSig.y, economizer.THeaSupSet)
  connect(TSupSig.y, economizer.TSup)
  connect(TOutBelowCutoff.y, economizer1.TOut)
  connect(TOutCut1.y,economizer1.TCut)
  connect(TSupSig1.y, economizer1.TSup)
  connect(TSupSetSig.y, economizer1.THeaSupSet)
  connect(fanSta.y, economizer1.uSupFan)
  connect(freProSta.y, economizer1.uFreProSta)
  connect(hOutBelowCutoff.y, economizer1.hOut)
  connect(hOutCut.y,economizer1.hCut)
  connect(opeMod.y, economizer1.uOpeMod)
  connect(zonSta.y, economizer1.uZonSta)
  connect(VOutMinSetSig.y, economizer.VOutMinSet_flow)
  connect(VOutMinSetSig.y, economizer1.VOutMinSet_flow)
  connect(SupFanSpeSig.y, economizer.uSupFanSpe)
  connect(SupFanSpeSig.y, economizer1.uSupFanSpe)
end Controller_Mod_DamLim;


Collection of validation models

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


Control of actuated exhaust  dampers without fans. Control sequence for exhaust dampers without fans. It is implemented according
to ASHRAE Guidline 35 (G36), PART 5.N.8.(for multi zone VAV AHU), PART 5.P.6
and PART3.2B.3 (for single zone VAV AHU).

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints;
block ExhaustDamper
  "Control of actuated exhaust  dampers without fans"
  parameter Real minExhDamPos(
    min=0,
    max=1,
    final unit="1") = 0.2
    "Exhaust damper position maintaining building static pressure at setpoint when the system is at minPosMin"
  parameter Real maxExhDamPos(
    min=0,
    max=1,
    final unit="1") = 0.9
    "Exhaust damper position maintaining building static pressure at setpoint when outdoor air damper is fully open and fan speed is at cooling maximum"
  parameter Real minOutPosMin(
    min=0,
    max=1,
    final unit="1") = 0.4
    "Outdoor air damper position when fan operating at minimum speed to supply minimum outdoor air flow"
  parameter Real outDamPhyPosMax(
    min=0,
    max=1,
    final unit="1")=1
    "Physical or at the comissioning fixed maximum position of the outdoor air damper"

  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uSupFan "Supply fan status"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uOutDamPos(
    min=0,
    max=1,
    final unit="1")
    "Outdoor air damper position"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yExhDamPos(
    min=0,
    max=1,
    final unit="1") "Exhaust damper position"

  Buildings.Controls.OBC.CDL.Reals.Line exhDamPos
    "Linearly map exhaust damper position to the outdoor air damper position"
  Buildings.Controls.OBC.CDL.Reals.Switch swi1
    "Check if exhaust damper should be open"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis greThr(
    final uLow=0.02,
    final uHigh=0.05)
    "Check if outdoor air damper is open"
  Buildings.Controls.OBC.CDL.Logical.And and2
    "Check if exhaust damper should be activated"

protected
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zerDam(
    final k=0)
    "Close damper when disabled"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant minExhDam(
    final k=minExhDamPos)
    "Exhaust damper position maintaining building static pressure at setpoint while the system is at minPosMin"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant maxExhDam(
    final k=maxExhDamPos)
    "Exhaust damper position maintaining building static pressure at setpoint when outdoor air damper is fully open and fan speed is at cooling maximum"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant minPosAtMinSpd(
    final k=minOutPosMin)
    "Outdoor air damper position when fan operating at minimum speed to supply minimum outdoor air flow"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant outDamPhyPosMaxSig(
    final k=outDamPhyPosMax)
    "Physical or at the comissioning fixed maximum position of the outdoor air damper"

equation
  connect(outDamPhyPosMaxSig.y, exhDamPos.x2)
  connect(maxExhDam.y, exhDamPos.f2)
  connect(uOutDamPos, exhDamPos.u)
  connect(zerDam.y, swi1.u3)
  connect(and2.y, swi1.u2)
  connect(minPosAtMinSpd.y, exhDamPos.x1)
  connect(minExhDam.y, exhDamPos.f1)
  connect(uOutDamPos, greThr.u)
  connect(uSupFan, and2.u2)
  connect(greThr.y, and2.u1)
  connect(exhDamPos.y, swi1.u1)
  connect(swi1.y, yExhDamPos)
end ExhaustDamper;


Output zone setpoint with operation mode selection. Block that outputs the zone setpoint temperature (TZonCooSet,
TZonHeaSet) and system operation mode (yOpeMod).

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints;
block ModeAndSetPoints "Output zone setpoint with operation mode selection"

  parameter Boolean have_winSen "Check if the zone has window status sensor";
  parameter Boolean have_occSen "Check if the zone has occupancy sensor";
  parameter Real THeaSetOcc(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=293.15
    "Occupied heating setpoint"
  parameter Real THeaSetUno(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=285.15
    "Unoccupied heating setpoint"
  parameter Real TCooSetOcc(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=297.15
    "Occupied cooling setpoint"
  parameter Real TCooSetUno(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=303.15
    "Unoccupied cooling setpoint"
  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 bouLim=1
    "Threshold of temperature difference for indicating the end of setback or setup mode"
  parameter Real uLow=-0.1
    "Low limit of the hysteresis for checking temperature difference"
  parameter Real uHigh=0.1
    "High limit of the hysteresis for checking temperature difference"
  parameter Real preWarCooTim(
    final unit="s",
    final quantity="Time")=10800 "Maximum cool-down or warm-up time"
  parameter Real TZonFreProOn(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=277.15
    "Threshold temperature to activate the freeze protection mode"
  parameter Real TZonFreProOff(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")=280.15
    "Threshold temperature to end the freeze protection mode"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput cooDowTim(
    final unit="s",
    final quantity="Time")
    "Cool-down time retrieved from optimal cool-down block"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput warUpTim(
    final unit="s",
    final quantity="Time") "Warm-up time retrieved from optimal warm-up block"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uWin if have_winSen
    "Window status: true=open, false=close"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TZon(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Zone temperature"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uOcc
    "Zone occupancy status according to the schedule: true=occupied, false=unoccupied"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput tNexOcc(
    final unit="s",
    final quantity="Time") "Time to next occupied period"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput setAdj if cooAdj or sinAdj
    "Setpoint adjustment value"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput heaSetAdj if heaAdj
    "Heating setpoint adjustment value"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uOccSen if have_occSen
    "Occupancy sensor (occupied=true, unoccupied=false)"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uCooDemLimLev
    "Cooling demand limit level"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerInput uHeaDemLimLev
    "Heating demand limit level"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yOpeMod "Operation mode"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonCooSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Cooling setpoint temperature"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonHeaSet(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Heating setpoint temperature"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Generic.SetPoints.OperationMode
    opeModSel(
    final numZon=1,
    final preWarCooTim=preWarCooTim,
    final TZonFreProOn=TZonFreProOn,
    final TZonFreProOff=TZonFreProOff) "Operation mode"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.TerminalUnits.SetPoints.ZoneTemperatures
    TZonSet(
    final have_occSen=have_occSen,
    final have_winSen=have_winSen,
    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) "Adjust setpoint temperature"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Generic.SetPoints.ZoneStatus zonSta(
    final THeaSetOcc=THeaSetOcc,
    final THeaSetUno=THeaSetUno,
    final TCooSetOcc=TCooSetOcc,
    final TCooSetUno=TCooSetUno,
    final bouLim=bouLim,
    final have_winSen=have_winSen,
    final uLow=uLow,
    final uHigh=uHigh) "Zone temperature status"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger colZon
    "Check if the zone is cold"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger hotZon
    "Check if the zone is hot"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant winSta(
    final k=false) if not have_winSen
    "Assume window is closed when there is no windows status sensor"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant occSta(
    final k=true) if not have_occSen
    "Assume the zone is occupied when there is no occupancy sensor"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToInt
    "Boolean to integer"

equation
  connect(zonSta.cooDowTim, cooDowTim)
  connect(zonSta.warUpTim, warUpTim)
  connect(zonSta.uWin, uWin)
  connect(zonSta.TZon, TZon)
  connect(zonSta.yCooTim, opeModSel.maxCooDowTim)
  connect(zonSta.yWarTim, opeModSel.maxWarUpTim)
  connect(zonSta.yHigOccCoo, opeModSel.uHigOccCoo)
  connect(zonSta.yOccHeaHig, opeModSel.uOccHeaHig)
  connect(zonSta.yUnoHeaHig, colZon.u)
  connect(colZon.y, opeModSel.totColZon)
  connect(zonSta.yHigUnoCoo, hotZon.u)
  connect(hotZon.y, opeModSel.totHotZon)
  connect(zonSta.yUnoHeaHig, opeModSel.uSetBac)
  connect(zonSta.yEndSetBac, opeModSel.uEndSetBac)
  connect(TZon, opeModSel.TZonMin)
  connect(zonSta.yHigUnoCoo, opeModSel.uSetUp)
  connect(zonSta.yEndSetUp, opeModSel.uEndSetUp)
  connect(opeModSel.uOcc, uOcc)
  connect(opeModSel.tNexOcc, tNexOcc)
  connect(zonSta.TCooSetOn, TZonSet.TZonCooSetOcc)
  connect(zonSta.TCooSetOff, TZonSet.TZonCooSetUno)
  connect(zonSta.THeaSetOn, TZonSet.TZonHeaSetOcc)
  connect(zonSta.THeaSetOff, TZonSet.TZonHeaSetUno)
  connect(opeModSel.yOpeMod, TZonSet.uOpeMod)
  connect(TZonSet.uCooDemLimLev, uCooDemLimLev)
  connect(TZonSet.uHeaDemLimLev, uHeaDemLimLev)
  connect(uWin, TZonSet.uWinSta)
  connect(winSta.y, TZonSet.uWinSta)
  connect(TZonSet.uOccSen, uOccSen)
  connect(occSta.y, TZonSet.uOccSen)
  connect(opeModSel.yOpeMod, yOpeMod)
  connect(TZonSet.TZonCooSet, TZonCooSet)
  connect(TZonSet.TZonHeaSet, TZonHeaSet)
  connect(winSta.y, booToInt.u)
  connect(uWin, booToInt.u)
  connect(booToInt.y, opeModSel.uOpeWin)
  connect(TZonSet.setAdj, setAdj)
  connect(TZonSet.heaSetAdj, heaSetAdj)
end ModeAndSetPoints;


Output the minimum outdoor airflow rate setpoint for systems with a single zone. This atomic sequence sets the minimum outdoor airflow setpoint for compliance
with the ventilation rate procedure of ASHRAE 62.1-2013. The implementation
is according to ASHRAE Guidline 36 (G36), PART 5.P.4.b, PART 5.B.2.b, PART3.1-D.2.a.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints;
block OutsideAirFlow
  "Output the minimum outdoor airflow rate setpoint for systems with a single zone"

  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 Boolean have_occSen
    "Set to true if zones have occupancy 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 uLow(
    final unit="K",
    final displayUnit="K",
    final quantity="TemperatureDifference") = -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 uHigh(
    final unit="K",
    final displayUnit="K",
    final quantity="TemperatureDifference") = 0.5
    "If zone space temperature minus supply air temperature is more than uHig,
     then it should use cooling supply air distribution effectiveness"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput nOcc(final unit="1")
    if have_occSen "Number of occupants"
  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.IntegerInput uOpeMod
    "AHU operation mode status signal"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uSupFan
    "Supply fan status, true if on, false if off"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uWin
    "Window status, true if open, false if closed"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput VOutMinSet_flow(
    min=0,
    final unit="m3/s",
    final quantity="VolumeFlowRate") "Effective minimum outdoor airflow setpoint"

protected
  Buildings.Controls.OBC.CDL.Reals.Add breZon "Breathing zone airflow"
  Buildings.Controls.OBC.CDL.Reals.Subtract sub2
    "Zone space temperature minus supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gai(
    final k=VOutPerPer_flow) if have_occSen "Outdoor airflow rate per person"
  Buildings.Controls.OBC.CDL.Reals.Switch swi
    "Switch for enabling occupancy sensor input"
  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.Switch swi2
    "If window is open or it is not in occupied mode, the required outdoor
    airflow rate should be zero"
  Buildings.Controls.OBC.CDL.Reals.Switch swi3
    "If supply fan is off, then outdoor airflow rate should be zero."
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hys(
    final uLow=uLow,
    final uHigh=uHigh,
    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 zerOutAir(
    final k=0)
    "Zero required outdoor airflow rate when window open or zone is not in occupied mode"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant disEffHea(
    final k=zonDisEffHea)
    "Zone distribution effectiveness during heating"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant disEffCoo(
    final k=zonDisEffCoo)
    "Zone distribution effectiveness for cooling"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant breZonAre(
    final k=VOutPerAre_flow*AFlo)
    "Area component of the breathing zone outdoor airflow"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant breZonPop(
    final k=VOutPerPer_flow*AFlo*occDen)
    "Population component of the breathing zone outdoor airflow"
  Buildings.Controls.OBC.CDL.Integers.Equal intEqu1 "Check if operation mode is occupied"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant occMod(
    final k=Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Types.OperationModes.occupied)
    "Occupied mode index"
  Buildings.Controls.OBC.CDL.Logical.And and1 "Logical and"
  Buildings.Controls.OBC.CDL.Logical.Not not1 "Logical not"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant zerOcc(final k=0)
    if not have_occSen
    "Zero occupant when there is no occupancy sensor"

equation
  connect(breZonAre.y, breZon.u1)
  connect(gai.y, swi.u1)
  connect(breZonPop.y, swi.u3)
  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(uWin, swi2.u2)
  connect(zerOutAir.y, swi2.u1)
  connect(zonOutAirRate.y, swi2.u3)
  connect(swi.u2, occSen.y)
  connect(nOcc, gai.u)
  connect(swi3.y, VOutMinSet_flow)
  connect(TZon, sub2.u1)
  connect(TDis, sub2.u2)
  connect(sub2.y, hys.u)
  connect(hys.y, swi1.u2)
  connect(swi2.y, swi3.u3)
  connect(zerOutAir.y, swi3.u1)
  connect(and1.y, not1.u)
  connect(not1.y, swi3.u2)
  connect(uSupFan, and1.u1)
  connect(intEqu1.y, and1.u2)
  connect(uOpeMod, intEqu1.u1)
  connect(occMod.y, intEqu1.u2)
  connect(swi.u1, zerOcc.y)
end OutsideAirFlow;


Output setpoints for AHU control

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV;
package SetPoints "Output setpoints for AHU control"
end SetPoints;


Supply air set point for single zone VAV system. Block that outputs the set points for the supply air temperature for
cooling, heating and economizer control,
and the fan speed for a single zone VAV system.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints;
block Supply "Supply air set point for single zone VAV system"

  parameter Real TSupSetMax(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Maximum supply air temperature for heating"

  parameter Real TSupSetMin(
    final unit="K",
    final 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"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput uHea(min=0, max=1, unit="1")
    "Heating control signal"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput uCoo(min=0, max=1, unit="1")
    "Cooling control signal"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TZonSet(unit="K", displayUnit="degC")
    "Average of heating and cooling setpoints for zone temperature"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TZon(unit="K", displayUnit="degC")
    "Zone temperature"

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TOut(unit="K", displayUnit="degC")
    "Outdoor air temperature"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TSupHeaEco(unit="K", displayUnit="degC")
    "Temperature setpoint for heating coil and for economizer"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TSupCoo(unit="K", displayUnit="degC")
    "Cooling supply air temperature setpoint"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput y(min=0, max=1, unit="1") "Fan speed"

  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uFan "Supply fan status"
  Buildings.Controls.OBC.CDL.Reals.Switch switch "Switch to assign control signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant fanOff(k=0) "Fan off status"
  Buildings.Controls.OBC.CDL.Reals.Min yFanHeaCoo "Fan speed due to heating or cooling"
protected
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant one(final k=1) "Maximum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Line TSetCooHig
    "Table to compute the setpoint for cooling for uCoo = 0...1"
  Buildings.Controls.OBC.CDL.Reals.Line offSetTSetHea
    "Table to compute the setpoint offset for heating for uCoo = 0...1"
  Buildings.Controls.OBC.CDL.Reals.Add addTHe
    "Adder for heating setpoint calculation"
  Buildings.Controls.OBC.CDL.Reals.Line offSetTSetCoo
    "Table to compute the setpoint offset for cooling for uHea = 0...1"
  Buildings.Controls.OBC.CDL.Reals.Add addTSupCoo
    "Adder for cooling setpoint calculation"
  Buildings.Controls.OBC.CDL.Reals.Subtract dT
    "Difference zone minus outdoor temperature"
  Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gai1(
    final k=(yMin - yCooMax)/(0.56 - 5.6))
    "Gain factor"
  Buildings.Controls.OBC.CDL.Reals.AddParameter yMed(
    final p=yCooMax - (yMin - yCooMax)/(0.56 - 5.6)*5.6)
    "Fan speed at medium cooling load"
  Buildings.Controls.OBC.CDL.Reals.Limiter yMedLim(
    final uMax=yCooMax,
    final uMin=yMin) "Limiter for yMed"
  Buildings.Controls.OBC.CDL.Reals.Limiter TDea(
    final uMax=24 + 273.15,
    final uMin=21 + 273.15)
    "Limiter that outputs the dead band value for the supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Line TSetHeaHig
    "Block to compute the setpoint for heating for uHea = 0...1"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con0(
    final k=0) "Contant that outputs zero"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con25(
    final k=0.25) "Contant that outputs 0.25"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con05(
    final k=0.5) "Contant that outputs 0.5"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con75(
    final k=0.75) "Contant that outputs 0.75"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant conTSupSetMax(
    final k=TSupSetMax) "Constant that outputs TSupSetMax"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant conTSupSetMin(
    final k=TSupSetMin) "Constant that outputs TSupSetMin"
  Buildings.Controls.OBC.CDL.Reals.Subtract TDeaTSupSetMin
    "Outputs TDea-TSupSetMin"
  Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gai(
    final k=-1)
    "Gain factor"
  Buildings.Controls.OBC.CDL.Reals.AddParameter addTDea(
    final p=-1.1)
    "Adds constant offset"
  Buildings.Controls.OBC.CDL.Reals.Subtract TSupSetMaxTDea
    "Outputs TSupSetMax-TDea"
  Buildings.Controls.OBC.CDL.Reals.Line yHea "Fan speed for heating"
  Buildings.Controls.OBC.CDL.Reals.Line lin050(
    final limitBelow=true,
    final limitAbove=true)
    "Linear increase in control signal for 0 < yCoo < 0.75"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con025(
    final k=0.25) "Constant signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con1(
    final k=0.5) "Constant signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con2(
    final k=1) "Constant signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con3(
    final k=0) "Constant signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con4(
    final k=yCooMax - yMin) "Constant signal"
  Buildings.Controls.OBC.CDL.Reals.Subtract dY075
    "Change in control signal above yMedLim for y > 0.75"
  Buildings.Controls.OBC.CDL.Reals.Line lin075(
    final limitBelow=true,
    final limitAbove=true)
    "Linear increase in control signal for 0.75 < yCoo"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con5(
    final k=0.75) "Constant signal"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con6(
    final k=0) "Constant signal"
  Buildings.Controls.OBC.CDL.Reals.AddParameter yOffSet(
    final p=-yMin)
    "Subtract yMin so that all control signals can be added"
  Buildings.Controls.OBC.CDL.Reals.Add addHeaCoo
    "Add heating control signal and offset due to cooling"
  Buildings.Controls.OBC.CDL.Reals.Add offCoo
    "Offset of control signal (relative to heating signal) for cooling"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant con7(final k=0.5)
    "Contant that outputs 0.5"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant minSpe(final k=yMin)
    "Contant that outputs minimum fan speed"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant conOne(final k=1)
    "Contant that outputs 1"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant maxHeaSpe(final k=yHeaMax)
    "Contant that outputs maximum fan speed for heating"

equation
  connect(offSetTSetHea.u, uCoo)
  connect(offSetTSetHea.y, addTHe.u2)
  connect(addTHe.y, TSupHeaEco)
  connect(TSetCooHig.y, addTSupCoo.u1)
  connect(offSetTSetCoo.y, addTSupCoo.u2)
  connect(TSetCooHig.u, uCoo)
  connect(offSetTSetCoo.u, uHea)
  connect(addTSupCoo.y, TSupCoo)
  connect(dT.u1, TZon)
  connect(dT.u2, TOut)
  connect(yMedLim.u, yMed.y)
  connect(TDea.u, TZonSet)
  connect(TDea.y, TSetHeaHig.f1)
  connect(con05.y, TSetHeaHig.x2)
  connect(conTSupSetMax.y, TSetHeaHig.f2)
  connect(uHea, TSetHeaHig.u)
  connect(TSetHeaHig.y, addTHe.u1)
  connect(con0.y, offSetTSetHea.x1)
  connect(con25.y, offSetTSetHea.x2)
  connect(con0.y, offSetTSetHea.f1)
  connect(TDea.y, TDeaTSupSetMin.u1)
  connect(conTSupSetMin.y, TDeaTSupSetMin.u2)
  connect(addTDea.y, offSetTSetHea.f2)
  connect(TSetCooHig.x1, con05.y)
  connect(TSetCooHig.f1, TDea.y)
  connect(TSetCooHig.x2, con75.y)
  connect(TSetCooHig.f2, conTSupSetMin.y)
  connect(offSetTSetCoo.f1, con0.y)
  connect(offSetTSetCoo.x1, con0.y)
  connect(offSetTSetCoo.x2, con05.y)
  connect(TSupSetMaxTDea.u1, conTSupSetMax.y)
  connect(TDea.y, TSupSetMaxTDea.u2)
  connect(TSupSetMaxTDea.y, offSetTSetCoo.f2)
  connect(uCoo, lin050.u)
  connect(dY075.u1, con4.y)
  connect(lin075.x2, con2.y)
  connect(lin075.x1, con5.y)
  connect(uCoo, lin075.u)
  connect(yMedLim.y, yOffSet.u)
  connect(dY075.u2, yOffSet.y)
  connect(offCoo.u1, lin050.y)
  connect(offCoo.u2, lin075.y)
  connect(offCoo.y, addHeaCoo.u2)
  connect(lin050.x2, con1.y)
  connect(con025.y, lin050.x1)
  connect(lin050.f2, yOffSet.y)
  connect(con3.y, lin050.f1)
  connect(dY075.y, lin075.f2)
  connect(con6.y, lin075.f1)
  connect(TSetHeaHig.x1, con0.y)
  connect(con7.y, yHea.x1)
  connect(minSpe.y, yHea.f1)
  connect(uHea, yHea.u)
  connect(conOne.y, yHea.x2)
  connect(maxHeaSpe.y, yHea.f2)
  connect(yHea.y, addHeaCoo.u1)
  connect(uFan, switch.u2)
  connect(fanOff.y, switch.u3)
  connect(switch.y, y)
  connect(one.y, yFanHeaCoo.u1)
  connect(addHeaCoo.y, yFanHeaCoo.u2)
  connect(yFanHeaCoo.y, switch.u1)
  connect(TDeaTSupSetMin.y, gai.u)
  connect(gai.y, addTDea.u)
  connect(dT.y, gai1.u)
  connect(gai1.y, yMed.u)
end Supply;


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

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

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

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.ExhaustDamper
    exhDamPos "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 outDamPos(
    duration=1200,
    startTime=0,
    height=0.6,
    offset=0.4)
    "Outdoor air damper position"

equation
  connect(supFan.y, exhDamPos.uSupFan)
  connect(outDamPos.y, exhDamPos.uOutDamPos)
end ExhaustDamper;


Validation models of reseting the zone setpoint temperature. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.ModeAndSetPoints.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Validation;
model ModeAndSetPoints
  "Validation models of reseting the zone setpoint temperature"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.ModeAndSetPoints
    setPoi(
    final have_winSen=false,
    final have_occSen=false,
    final cooAdj=true,
    final heaAdj=true) "Output resetted zone setpoint remperature"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.ModeAndSetPoints
    setPoi1(final have_occSen=true, final have_winSen=true)
    "Output resetted zone setpoint remperature"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.ModeAndSetPoints
    setPoi2(
    final have_winSen=false,
    final have_occSen=false,
    final cooAdj=true,
    final heaAdj=true) "Output resetted zone setpoint remperature"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.ModeAndSetPoints
    setPoi3(final have_occSen=true, final have_winSen=true)
    "Output resetted zone setpoint remperature"

  Buildings.Controls.SetPoints.OccupancySchedule occSch "Occupancy schedule"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin heaSetAdj(
    final freqHz=1/28800,
    final amplitude=0.5) "Heating setpoint adjustment"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin cooSetAdj(
    final freqHz=1/28800) "Cooling setpoint adjustment"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin TZon1(
    final amplitude=5,
    final offset=18 + 273.15,
    final freqHz=1/86400) "Zone 1 temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Sin TZon2(
    final offset=18 + 273.15,
    final freqHz=1/86400,
    final amplitude=7.5) "Zone 2 temperature"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant winSta1(
    final k=false)
    "Window status"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant winSta2(
    final k=true)
    "Window status"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant occSen1(
    final k=false)
    "Occupancy sensor"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant occSen2(
    final k=true)
    "Occupancy sensor"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant demLimLev(
    final k=0) "Demand limit level"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant warCooTim(
    final k=1800)
    "Warm-up or cooldown time"

equation
  connect(cooSetAdj.y, setPoi.setAdj)
  connect(heaSetAdj.y, setPoi.heaSetAdj)
  connect(occSen2.y, setPoi3.uOccSen)
  connect(setPoi3.TZon, TZon2.y)
  connect(setPoi2.TZon, TZon2.y)
  connect(cooSetAdj.y, setPoi2.setAdj)
  connect(heaSetAdj.y, setPoi2.heaSetAdj)
  connect(TZon1.y, setPoi.TZon)
  connect(setPoi1.TZon, setPoi.TZon)
  connect(occSch.tNexOcc, setPoi.tNexOcc)
  connect(occSch.tNexOcc, setPoi1.tNexOcc)
  connect(occSch.occupied, setPoi.uOcc)
  connect(occSch.occupied, setPoi1.uOcc)
  connect(occSch.occupied, setPoi2.uOcc)
  connect(occSch.occupied, setPoi3.uOcc)
  connect(occSen1.y, setPoi1.uOccSen)
  connect(winSta1.y, setPoi1.uWin)
  connect(winSta2.y, setPoi3.uWin)
  connect(occSch.tNexOcc, setPoi2.tNexOcc)
  connect(occSch.tNexOcc, setPoi3.tNexOcc)
  connect(demLimLev.y, setPoi.uCooDemLimLev)
  connect(demLimLev.y, setPoi.uHeaDemLimLev)
  connect(demLimLev.y, setPoi1.uCooDemLimLev)
  connect(demLimLev.y, setPoi1.uHeaDemLimLev)
  connect(demLimLev.y, setPoi2.uCooDemLimLev)
  connect(demLimLev.y, setPoi2.uHeaDemLimLev)
  connect(demLimLev.y, setPoi3.uCooDemLimLev)
  connect(demLimLev.y, setPoi3.uHeaDemLimLev)
  connect(warCooTim.y, setPoi.cooDowTim)
  connect(warCooTim.y, setPoi.warUpTim)
  connect(warCooTim.y, setPoi1.warUpTim)
  connect(warCooTim.y, setPoi2.warUpTim)
  connect(warCooTim.y, setPoi3.warUpTim)
  connect(warCooTim.y, setPoi1.cooDowTim)
  connect(warCooTim.y, setPoi2.cooDowTim)
  connect(warCooTim.y, setPoi3.cooDowTim)
end ModeAndSetPoints;


Validate the model of calculating minimum outdoor airflow setpoint. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.OutsideAirFlow.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Validation;
model OutsideAirFlow
  "Validate the model of calculating minimum outdoor airflow setpoint"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.OutsideAirFlow
    outAirSet_SinZon(AFlo=40, have_occSen=true)
    "Block to output minimum outdoor airflow rate for system with single zone "
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp numOfOcc(
    height=4,
    duration=3600)
    "Number of occupant detected in zone"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.OutsideAirFlow
    outAirSet_SinZon_noOccSen(AFlo=40, have_occSen=false)
    "Block to output minimum outdoor airflow rate for system with single zone without an occupancy sensor"
protected
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant winSta(
    k=false) "Window status"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant supFan(
    k=true) "Supply fan status"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TZon(
    height=6,
    offset=273.15 + 17,
    duration=3600) "Measured zone temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TDis(
    height=4,
    duration=3600,
    offset=273.15 + 18) "Terminal unit discharge air temperature"
  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"

equation
  connect(numOfOcc.y, outAirSet_SinZon.nOcc)
  connect(winSta.y, outAirSet_SinZon.uWin)
  connect(TZon.y, outAirSet_SinZon.TZon)
  connect(outAirSet_SinZon.uOpeMod, opeMod.y)
  connect(supFan.y, outAirSet_SinZon.uSupFan)
  connect(TDis.y, outAirSet_SinZon.TDis)
  connect(winSta.y, outAirSet_SinZon_noOccSen.uWin)
  connect(TZon.y, outAirSet_SinZon_noOccSen.TZon)
  connect(outAirSet_SinZon_noOccSen.uOpeMod, opeMod.y)
  connect(supFan.y, outAirSet_SinZon_noOccSen.uSupFan)
  connect(TDis.y, outAirSet_SinZon_noOccSen.TDis)
end OutsideAirFlow;


Collection of validation models

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


Validation model for outdoor minus room air temperature. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Supply
for a change in temperature difference between zone air and outdoor air.
Hence, this model validates whether the adjustment of the fan speed for medium
cooling load is correctly implemented.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Validation;
model Supply_T
  "Validation model for outdoor minus room air temperature"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Supply
    setPoiVAV(
    yHeaMax=0.7,
    yMin=0.3,
    TSupSetMax=303.15,
    TSupSetMin=289.15,
    yCooMax=0.9)
    "Block that computes the setpoints for temperature and fan speed"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant uHea(k=0)
    "Heating control signal"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant uCoo(k=0.6)
    "Cooling control signal"

  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TOut(
    duration=1,
    height=18,
    offset=273.15 + 10) "Outdoor air temperature"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TZon(
    k=273.15 + 22) "Zone temperature"
  Buildings.Controls.OBC.CDL.Reals.Subtract dT
    "Difference zone minus outdoor temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TZonSet(
    k=273.15 + 22) "Average zone set point"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanSta(k=true) "Fan is on"
equation
  connect(uCoo.y, setPoiVAV.uCoo)
  connect(TZon.y, setPoiVAV.TZon)
  connect(TOut.y, setPoiVAV.TOut)
  connect(uHea.y, setPoiVAV.uHea)
  connect(dT.u1, TZon.y)
  connect(dT.u2, TOut.y)
  connect(TZonSet.y,setPoiVAV.TZonSet)
  connect(fanSta.y, setPoiVAV.uFan)
end Supply_T;


Validation model for temperature and fan speed. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Supply
for different control signals.
Each controller is configured identical, but the input signal for TZon differs
in order to validate that the fan speed is increased correctly.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Validation;
model Supply_u "Validation model for temperature and fan speed"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Supply
    setPoiVAV(
    yHeaMax=0.7,
    yMin=0.3,
    TSupSetMax=303.15,
    TSupSetMin=289.15)
    "Block that computes the setpoints for temperature and fan speed"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Supply
    setPoiVAV1(
    yHeaMax=0.7,
    yMin=0.3,
    TSupSetMax=303.15,
    TSupSetMin=289.15)
    "Block that computes the setpoints for temperature and fan speed"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.SetPoints.Supply
    setPoiVAV2(
    yHeaMax=0.7,
    yMin=0.3,
    TSupSetMax=303.15,
    TSupSetMin=289.15)
    "Block that computes the setpoints for temperature and fan speed"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TZon(k=273.15 + 28)
    "Zone air temperature"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOut(k=273.15 + 22)
    "Outdoor temperature"

  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp uHea(
    duration=0.25,
    height=-1,
    offset=1) "Heating control signal"

  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp uCoo(
    duration=0.25,
    startTime=0.75)
    "Cooling control signal"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TZonSet(k=273.15 + 23)
    "Average zone set point"

  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TZon1(k=273.15 + 23)
    "Zone air temperature"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanSta(k=true)
    "Fan is on"
equation
  connect(TZon.y, setPoiVAV.TZon)
  connect(TOut.y, setPoiVAV.TOut)
  connect(uHea.y, setPoiVAV.uHea)
  connect(uCoo.y, setPoiVAV.uCoo)
  connect(TZonSet.y,setPoiVAV.TZonSet)
  connect(TOut.y, setPoiVAV1.TOut)
  connect(uHea.y, setPoiVAV1.uHea)
  connect(uCoo.y, setPoiVAV1.uCoo)
  connect(TZonSet.y,setPoiVAV1.TZonSet)
  connect(TOut.y, setPoiVAV2.TOut)
  connect(uHea.y, setPoiVAV2.uHea)
  connect(uCoo.y, setPoiVAV2.uCoo)
  connect(TZonSet.y,setPoiVAV2.TZonSet)
  connect(TOut.y, setPoiVAV1.TZon)
  connect(TZon1.y, setPoiVAV2.TZon)
  connect(fanSta.y, setPoiVAV.uFan)
  connect(setPoiVAV1.uFan, setPoiVAV.uFan)
  connect(setPoiVAV2.uFan, setPoiVAV.uFan)
end Supply_u;


Validation of the top-level controller. This example validates

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

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation;
model Controller "Validation of the top-level controller"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Controller
    conVAV(
    final have_winSen=false,
    final kHea=1,
    final yHeaMax=1,
    final yMin=0.1,
    final AFlo=50,
    final controllerTypeCoo=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final controllerTypeHea=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final have_occSen=true,
    final TSupSetMax=297.15,
    final TSupSetMin=285.15,
    final use_TMix=false,
    final controllerTypeMod=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final kMod=1,
    final VOutMin_flow=6e-3,
    final VOutDes_flow=0.25) "Validate the heating case"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Controller
    conVAV1(
    final have_winSen=true,
    final kCoo=1,
    final kHea=1,
    final yHeaMax=1,
    final yMin=0.1,
    final AFlo=50,
    final controllerTypeCoo=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final controllerTypeHea=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final have_occSen=false,
    final TSupSetMax=297.15,
    final TSupSetMin=285.15,
    final use_TMix=false,
    final controllerTypeMod=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final kMod=1,
    final VOutMin_flow=6e-3,
    final VOutDes_flow=0.25) "Validate the cooling case"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Controller
    conVAV2(
    final have_winSen=false,
    final kCoo=1,
    final kHea=1,
    final yHeaMax=1,
    final yMin=0.1,
    final AFlo=50,
    final controllerTypeCoo=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final controllerTypeHea=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final have_occSen=true,
    final TSupSetMax=297.15,
    final TSupSetMin=285.15,
    final use_TMix=false,
    final controllerTypeMod=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final kMod=1,
    final VOutMin_flow=6e-3,
    final VOutDes_flow=0.25) "Validate the cooling case"

  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Controller
    conVAV3(
    final have_winSen=true,
    final kCoo=1,
    final kHea=1,
    final yHeaMax=1,
    final yMin=0.1,
    final AFlo=50,
    final controllerTypeCoo=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final controllerTypeHea=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final have_occSen=false,
    final TSupSetMax=297.15,
    final TSupSetMin=285.15,
    final use_TMix=false,
    final controllerTypeMod=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
    final kMod=1,
    final VOutMin_flow=6e-3,
    final VOutDes_flow=0.25) "Validate the cooling case"

  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TZon(
    final duration=86400,
    final height=6,
    final offset=273.15 + 16,
    y(unit="K"))  "Measured zone temperature"
  Buildings.Controls.SetPoints.OccupancySchedule occSch(
    final occupancy=3600*{4,20})
    "Occupancy schedule"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TCut(
    final k=289.15,
    y(unit="K"))
    "Fixed dry bulb temperature high limit cutoff for economizer"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant nOcc(final k=2)
    "Number of occupants"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant win(final k=false)
    "Window status"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOut(
    final k=290.15,
    y(unit="K"))
    "Outdoor air dry bulb temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOut1(
    final k=301.15,
    y(unit="K"))
    "Outdoor air dry bulb temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TZon1(
    final duration=86400,
    final height=-3,
    final offset=273.15 + 26,
    y(unit="K"))  "Measured zone temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOut2(
    final k=295.15,
    y(unit="K"))
    "Outdoor air dry bulb temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TOut3(
    final k=289.15,
    y(unit="K"))
    "Outdoor air dry bulb temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup(
    final height=2,
    final duration=86400,
    final offset=273.15 + 22.5,
    y(unit="K")) "Terminal unit discharge air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup1(
    final height=-3,
    final duration=86400,
    final offset=273.15 + 24,
    y(unit="K")) "Terminal unit discharge air temperature"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant demLim(
    final k=0)
    "Cooling and heating demand imit level"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant cooWarTim(
    final k=0)
    "Cooldown and warm-up time"

equation
  connect(TZon.y, conVAV.TZon)
  connect(occSch.occupied, conVAV.uOcc)
  connect(occSch.tNexOcc, conVAV.tNexOcc)
  connect(TCut.y, conVAV.TCut)
  connect(nOcc.y, conVAV.nOcc)
  connect(TOut.y, conVAV.TOut)
  connect(TSup.y, conVAV.TSup)
  connect(win.y, conVAV1.uWin)
  connect(occSch.tNexOcc, conVAV1.tNexOcc)
  connect(occSch.occupied, conVAV1.uOcc)
  connect(TOut1.y, conVAV1.TOut)
  connect(TZon1.y, conVAV1.TZon)
  connect(TSup1.y, conVAV1.TSup)
  connect(TCut.y, conVAV1.TCut)
  connect(TSup1.y,conVAV2. TSup)
  connect(occSch.occupied,conVAV2. uOcc)
  connect(occSch.tNexOcc,conVAV2. tNexOcc)
  connect(TCut.y,conVAV2. TCut)
  connect(TZon1.y, conVAV2.TZon)
  connect(TOut2.y, conVAV2.TOut)
  connect(win.y, conVAV3.uWin)
  connect(occSch.occupied, conVAV3.uOcc)
  connect(TCut.y, conVAV3.TCut)
  connect(TSup1.y, conVAV3.TSup)
  connect(TZon1.y, conVAV3.TZon)
  connect(occSch.tNexOcc, conVAV3.tNexOcc)
  connect(TOut3.y, conVAV3.TOut)
  connect(nOcc.y, conVAV2.nOcc)
  connect(cooWarTim.y, conVAV.warUpTim)
  connect(cooWarTim.y, conVAV.cooDowTim)
  connect(cooWarTim.y, conVAV1.warUpTim)
  connect(cooWarTim.y, conVAV1.cooDowTim)
  connect(cooWarTim.y, conVAV2.warUpTim)
  connect(cooWarTim.y, conVAV2.cooDowTim)
  connect(cooWarTim.y, conVAV3.warUpTim)
  connect(cooWarTim.y, conVAV3.cooDowTim)
  connect(demLim.y, conVAV3.uHeaDemLimLev)
  connect(demLim.y, conVAV3.uCooDemLimLev)
  connect(demLim.y, conVAV2.uHeaDemLimLev)
  connect(demLim.y, conVAV2.uCooDemLimLev)
  connect(demLim.y, conVAV1.uHeaDemLimLev)
  connect(demLim.y, conVAV1.uCooDemLimLev)
  connect(demLim.y, conVAV.uCooDemLimLev)
  connect(demLim.y, conVAV.uHeaDemLimLev)
end Controller;


Validation of cooling coil model. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.CoolingCoil.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation;
model CoolingCoil "Validation of cooling coil model"
  final parameter Real TSupSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")=291.15
    "Supply air temperature setpoint";
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.CoolingCoil
    cooCoi(controllerTypeCooCoi=Buildings.Controls.OBC.CDL.Types.SimpleController.P,
      kCooCoi=1) "Cooling coil controller"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp TSup(
    final height=4,
    final offset=TSupSet - 2,
    final duration=3600*8) "Measured supply air temperature"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant TSupSetSig(final k=
        TSupSet) "Supply air temperature setpoint"
  Buildings.Controls.OBC.CDL.Logical.Sources.Constant fanStatus(k=true)
    "Fan is on"
  Buildings.Controls.OBC.CDL.Reals.Sources.Pulse zonSta(offset=2, period=
        3600*2) "Zone state"
  Buildings.Controls.OBC.CDL.Conversions.RealToInteger reaToInt
    "Real to integer conversion"
equation
  connect(TSup.y, cooCoi.TSup)
  connect(TSupSetSig.y, cooCoi.TSupCoo)
  connect(fanStatus.y, cooCoi.uSupFan)
  connect(zonSta.y, reaToInt.u)
  connect(reaToInt.y, cooCoi.uZonSta)
end CoolingCoil;


Collection of validation models

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


Validation models of determining zone state. This example validates

Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.ZoneState.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.Validation;
model ZoneState "Validation models of determining zone state"
  Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.AHUs.SingleZone.VAV.ZoneState zonSta
    "Zone state"
  Buildings.Controls.OBC.CDL.Reals.Sources.TimeTable uHeaCoo(
    table=[0,0,0; 1,0,1; 2,1,0],
    smoothness=Buildings.Controls.OBC.CDL.Types.Smoothness.ConstantSegments,
    extrapolation=Buildings.Controls.OBC.CDL.Types.Extrapolation.HoldLastPoint)
    "Control signal for heating and cooling"
equation
  connect(zonSta.uHea, uHeaCoo.y[1])
  connect(zonSta.uCoo, uHeaCoo.y[2])
end ZoneState;


Freeze protection based on mixed air temperature. Block that tracks the mixed air temperature TMix
using a PI controller and outputs
a freeze protection control signal yFrePro and
its inverse yFreProInv.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Generic;
block FreezeProtectionMixedAir "Freeze protection based on mixed air temperature"

  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")=0.1 "Gain";

  parameter Real Ti(
    final unit="s",
    final quantity="Time")= 120 "Time constant of integrator block";

  parameter Real Td(
    final unit="s",
    final quantity="Time")= 0.1
    "Time constant of derivative block"

  parameter Real TFreSet(
    final unit="K",
    final displayUnit="degC",
    final quantity="ThermodynamicTemperature")= 279.15
    "Lower limit for mixed air temperature for freeze protection";

  Buildings.Controls.OBC.CDL.Interfaces.RealInput TMix(
    final unit="K",
    final displayUnit="degC",
    final quantity = "ThermodynamicTemperature")
    "Mixed air temperature measurement"

  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yFrePro(
    final unit="1",
    final min=0,
    final max=1) "Freeze protection control signal, 0 if no frost, 1 if TMix below TFreSet"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yFreProInv(
    final unit="1",
    final min=0,
    final max=1) "Inverse freeze protection control signal, 1 if no frost, 0 if TMix below TFreSet"

  Buildings.Controls.OBC.CDL.Reals.PID con(
    final controllerType=controllerType,
    final k=k,
    final Ti=Ti,
    final Td=Td,
    final yMax=1,
    final yMin=0)
    "Controller for mixed air to track freeze protection set point"

protected
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant setPoi(final k=TFreSet)
    "Set point for freeze protection"
  Buildings.Controls.OBC.CDL.Reals.Subtract yOut
    "Freeze protection control signal inverter"
  Buildings.Controls.OBC.CDL.Reals.Sources.Constant one(
    final k=1) "Constant 1"

equation
  connect(con.u_s, setPoi.y)
  connect(yOut.y, yFreProInv)
  connect(TMix, con.u_m)
  connect(con.y, yFrePro)
  connect(con.y, yOut.u2)
  connect(one.y, yOut.u1)
end FreezeProtectionMixedAir;


Generic control sequences

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1;
package Generic "Generic control sequences"
end Generic;


Block that outputs the zone group status. This sequence sums up the zone level status calculation to find the outputs that are
needed to define the zone group operation mode.

within Buildings.Obsolete.Controls.OBC.ASHRAE.G36_PR1.Generic.SetPoints;
block GroupStatus "Block that outputs the zone group status"

  parameter Integer numZon(
    final min=1)=5 "Number of zones in building";
  parameter Integer numZonGro(
    final min=1)=numZon "Number of zones in group";
  parameter Boolean zonGroMsk[numZon]=fill(true, numZon)
    "Boolean array mask of zones included in group";

  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.BooleanInput zonOcc[numZon]
    "True when the zone is set to be occupied due to the override"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uOcc[numZon]
    "True when the zone is occupied according to the occupancy schedule"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput tNexOcc[numZon](
    final unit=fill("s", numZon),
    final quantity=fill("Time", numZon)) "Time to next occupied period"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uCooTim[numZon](
    final unit=fill("s", numZon),
    final quantity=fill("Time", numZon)) "Cool down time"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput uWarTim[numZon](
    final unit=fill("s", numZon),
    final quantity=fill("Time", numZon)) "Warm-up time"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uOccHeaHig[numZon]
    "True when the zone temperature is lower than the occupied heating setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uHigOccCoo[numZon]
    "True when the zone temperature is higher than the occupied cooling setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uUnoHeaHig[numZon]
    "True when the zone temperature is lower than the unoccupied heating setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput THeaSetOff[numZon](
    final unit=fill("K", numZon),
    displayUnit=fill("degC", numZon),
    final quantity=fill("ThermodynamicTemperature", numZon))
    "Zone unoccupied heating setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uEndSetBac[numZon]
    "True when the zone could end the setback mode"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uHigUnoCoo[numZon]
    "True when the zone temperature is higher than its unoccupied cooling setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TCooSetOff[numZon](
    final unit=fill("K", numZon),
    displayUnit=fill("degC", numZon),
    final quantity=fill("ThermodynamicTemperature", numZon))
    "Zone unoccupied cooling setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uEndSetUp[numZon]
    "True when the zone could end the setup mode"
  Buildings.Controls.OBC.CDL.Interfaces.RealInput TZon[numZon](
    final unit=fill("K", numZon),
    displayUnit=fill("degC", numZon),
    final quantity=fill("ThermodynamicTemperature", numZon)) "Zone temperature"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanInput uWin[numZon]
    "True when the window is open, false when the window is close or the zone does not have window status sensor"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput uGroOcc
    "True when the zone group is in occupied mode"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput nexOcc(
    final quantity="Time",
    final unit="s") "Time to next occupied period"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yCooTim(
    final unit="s",
    final quantity="Time") "Cool down time"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput yWarTim(
    final unit="s",
    final quantity="Time") "Warm-up time"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput yOccHeaHig
    "True when there is zone with temperature being lower than the occupied heating setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput yHigOccCoo
    "True when there is zone with temperature being higher than the occupied cooling setpoint"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yColZon
    "Total number of cold zones"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput ySetBac
    "Run setback mode"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput yEndSetBac
    "True when the group should end setback mode"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yHotZon
    "Total number of hot zones"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput ySetUp
    "Run setup mode"
  Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput yEndSetUp
    "True when the group should end setup mode"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonMax(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Maximum zone temperature in the zone group"
  Buildings.Controls.OBC.CDL.Interfaces.RealOutput TZonMin(
    final unit="K",
    displayUnit="degC",
    final quantity="ThermodynamicTemperature")
    "Minimum zone temperature in the zone group"
  Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput yOpeWin
    "Total number of open windows"

  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysSetBac(final uLow=uLow,
      final uHigh=uHigh)
    "Hysteresis that outputs if the group should run in setback mode"
  Buildings.Controls.OBC.CDL.Reals.Hysteresis hysSetUp(final uLow=uLow,
      final uHigh=uHigh)
    "Hysteresis that outputs if the group should run in setup mode"

protected
    Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter zonOccFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uOccFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.RealVectorFilter tNexOccFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.RealVectorFilter uCooTimFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.RealVectorFilter uWarTimFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uOccHeaHigFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uHigOccCooFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uUnoHeaHigFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.RealVectorFilter THeaSetOffFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uEndSetBacFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uHigUnoCooFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.RealVectorFilter TCooSetOffFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uEndSetUpFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.RealVectorFilter TZonFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"
  Buildings.Controls.OBC.CDL.Routing.BooleanVectorFilter uWinFil(
    final nin=numZon,
    final nout=numZonGro,
    final msk=zonGroMsk) "Zone group filter"

  Buildings.Controls.OBC.CDL.Reals.MultiMax cooDowTim(
    final nin=numZonGro)
    "Longest cooldown time"
  Buildings.Controls.OBC.CDL.Reals.MultiMax warUpTim(
    final nin=numZonGro)
    "Longest warm up time"
  Buildings.Controls.OBC.CDL.Logical.MultiOr mulOr(
    final nin=numZonGro)
    "Check if there is any zone that the zone temperature is lower than its occupied heating setpoint"
  Buildings.Controls.OBC.CDL.Logical.MultiOr mulOr1(
    final nin=numZonGro)
    "Check if there is any zone that the zone temperature is higher than its occupied cooling setpoint"
  Buildings.Controls.OBC.CDL.Reals.MultiMax maxTem(
    final nin=numZonGro)
    "Maximum zone temperature in the zone group"
  Buildings.Controls.OBC.CDL.Reals.MultiMin minTem(
    final nin=numZonGro)
    "Minimum zone temperature in the zone group"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToInt[numZonGro]
    "Convert boolean to integer"
  Buildings.Controls.OBC.CDL.Integers.MultiSum totColZon(
    final nin=numZonGro) "Total number of cold zone"
  Buildings.Controls.OBC.CDL.Logical.MultiAnd endSetBac(
    final nin=numZonGro)
    "Check if all zones have ended the setback mode"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToInt1[numZonGro]
    "Convert boolean to integer"
  Buildings.Controls.OBC.CDL.Integers.MultiSum totHotZon(
    final nin=numZonGro) "Total number of hot zones"
  Buildings.Controls.OBC.CDL.Logical.MultiAnd endSetUp(
    final nin=numZonGro)
    "Check if all zones have ended the setup mode"
  Buildings.Controls.OBC.CDL.Reals.MultiSum sumUnoHea(
    final nin=numZonGro)
    "Sum of all zones unoccupied heating setpoint"
  Buildings.Controls.OBC.CDL.Reals.Subtract difUnoHea
    "Difference between unoccupied heating setpoint and zone temperature"
  Buildings.Controls.OBC.CDL.Reals.Divide div1 "Average difference"
  Buildings.Controls.OBC.CDL.Integers.Sources.Constant totZon(
    final k=numZonGro) "Total number of zones"
  Buildings.Controls.OBC.CDL.Conversions.IntegerToReal intToRea "Convert integer to real"
  Buildings.Controls.OBC.CDL.Reals.MultiSum sumUnoCoo(
    final nin=numZonGro)
    "Sum of all zones unoccupied cooling setpoint"
  Buildings.Controls.OBC.CDL.Reals.MultiSum sumTem(
    final nin=numZonGro)
    "Sum of all zones temperature"
  Buildings.Controls.OBC.CDL.Reals.Subtract difUnoCoo
    "Difference between unoccupied cooling setpoint and zone temperature"
  Buildings.Controls.OBC.CDL.Reals.Divide div2 "Average difference"
  Buildings.Controls.OBC.CDL.Reals.MultiMin minToNexOcc(
    final nin=numZonGro)
    "Minimum time to next occupied period"
  Buildings.Controls.OBC.CDL.Logical.MultiOr schOcc(
    final nin=numZonGro)
    "Check if the group should be in occupied mode according to the schedule"
  Buildings.Controls.OBC.CDL.Logical.MultiOr oveRidOcc(
    final nin=numZonGro)
    "Check if the group should be in occupied mode according to the zone override"
  Buildings.Controls.OBC.CDL.Logical.Or groOcc
    "Check if the group should be in occupied mode according to the schedule or the zone override"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger booToInt2[numZonGro]
    "Convert boolean to integer"
  Buildings.Controls.OBC.CDL.Integers.MultiSum totOpeWin(
    final nin=numZonGro)
    "Total number of opening windows"
  Buildings.Controls.OBC.CDL.Conversions.BooleanToReal booToRea(
    final realTrue=0,
    final realFalse=1)
    "When any zone becomes occpuied, output zero"
  Buildings.Controls.OBC.CDL.Reals.Multiply proOcc
    "When it is occupied, output zero"

equation
  connect(maxTem.y, TZonMax)
  connect(minTem.y, TZonMin)
  connect(cooDowTim.y, yCooTim)
  connect(warUpTim.y, yWarTim)
  connect(mulOr.y, yOccHeaHig)
  connect(mulOr1.y, yHigOccCoo)
  connect(totColZon.y, yColZon)
  connect(endSetBac.y, yEndSetBac)
  connect(totHotZon.y, yHotZon)
  connect(endSetUp.y, yEndSetUp)
  connect(booToInt.y, totColZon.u)
  connect(booToInt1.y, totHotZon.u)
  connect(totZon.y, intToRea.u)
  connect(sumTem.y, difUnoCoo.u1)
  connect(sumUnoHea.y, difUnoHea.u1)
  connect(intToRea.y, div1.u2)
  connect(intToRea.y, div2.u2)
  connect(difUnoHea.y, div1.u1)
  connect(difUnoCoo.y, div2.u1)
  connect(div1.y, hysSetBac.u)
  connect(hysSetBac.y, ySetBac)
  connect(div2.y, hysSetUp.u)
  connect(hysSetUp.y, ySetUp)
  connect(groOcc.y, uGroOcc)
  connect(oveRidOcc.y, groOcc.u1)
  connect(schOcc.y, groOcc.u2)
  connect(totOpeWin.y, yOpeWin)
  connect(booToInt2.y, totOpeWin.u)
  connect(schOcc.y, booToRea.u)
  connect(minToNexOcc.y, proOcc.u2)
  connect(booToRea.y, proOcc.u1)
  connect(proOcc.y, nexOcc)
  connect(zonOcc, zonOccFil.u)
  connect(uOcc, uOccFil.u)
  connect(zonOccFil.y, oveRidOcc.u)
  connect(uOccFil.y, schOcc.u)
  connect(tNexOcc, tNexOccFil.u)
  connect(tNexOccFil.y, minToNexOcc.u)
  connect(uCooTim, uCooTimFil.u)
  connect(uCooTimFil.y, cooDowTim.u)
  connect(uWarTim, uWarTimFil.u)
  connect(uWarTimFil.y, warUpTim.u)
  connect(uOccHeaHig, uOccHeaHigFil.u)
  connect(uOccHeaHigFil.y, mulOr.u)
  connect(uHigOccCoo, uHigOccCooFil.u)
  connect(uHigOccCooFil.y, mulOr1.u)
  connect(uUnoHeaHig, uUnoHeaHigFil.u)
  connect(uUnoHeaHigFil.y, booToInt.u)
  connect(THeaSetOff, THeaSetOffFil.u)
  connect(THeaSetOffFil.y, sumUnoHea.u)
  connect(uEndSetBac, uEndSetBacFil.u)
  connect(uEndSetBacFil.y, endSetBac.u)
  connect(uHigUnoCoo, uHigUnoCooFil.u)
  connect(uHigUnoCooFil.y, booToInt1.u)
  connect(TCooSetOff, TCooSetOffFil.u)
  connect(TCooSetOffFil.y, sumUnoCoo.u)
  connect(uEndSetUp, uEndSetUpFil.u)
  connect(uEndSetUpFil.y, endSetUp.u)
  connect(TZon, TZonFil.u)
  connect(TZonFil.y, sumTem.u)
  connect(TZonFil.y, maxTem.u)
  connect(TZonFil.y, minTem.u)
  connect(uWin, uWinFil.u)
  connect(uWinFil.y, booToInt2.u)

  connect(sumTem.y, difUnoHea.u2)
  connect(sumUnoCoo.y, difUnoCoo.u2)
end GroupStatus;