Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in) | :: | FirstHVACIteration | |||
integer, | intent(in) | :: | VRFCond | |||
integer, | intent(in) | :: | TUListNum | |||
real(kind=r64), | intent(inout) | :: | OnOffAirFlowRatio |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
SUBROUTINE InitializeOperatingMode(FirstHVACIteration,VRFCond,TUListNum,OnOffAirFlowRatio)
! SUBROUTINE INFORMATION:
! AUTHOR Richard Raustad
! DATE WRITTEN July 2012 (Moved from InitVRF)
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Scans each zone coil and determines the load based on control
! Moved from Init to clean up and localize code segments
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
USE DataHeatBalFanSys, ONLY: TempControlType, ZT, ZoneThermostatSetPointHi, ZoneThermostatSetPointLo
USE ScheduleManager, ONLY: GetCurrentScheduleValue
USE MixedAir, ONLY: SimOAMixer, SimOAController
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
LOGICAL, INTENT (IN) :: FirstHVACIteration ! flag for first time through HVAC systems
INTEGER, INTENT (IN) :: VRFCond ! Condenser Unit index
INTEGER, INTENT (IN) :: TUListNum ! Condenser Unit terminal unit list
REAL(r64), INTENT (INOUT) :: OnOffAirFlowRatio ! ratio of on to off flow rate
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: ZoneDeltaT ! zone temperature difference from setpoint
REAL(r64) :: SPTempHi ! thermostat setpoint high
REAL(r64) :: SPTempLo ! thermostat setpoint low
INTEGER :: NumTU ! loop counter, number of TU's in list
INTEGER :: TUIndex ! index to TU
INTEGER :: ThisZoneNum ! index to zone number where TU is located
REAL(r64) :: ZoneLoad ! current zone load (W)
REAL(r64) :: LoadToCoolingSP ! thermostat load to cooling setpoint (W)
REAL(r64) :: LoadToHeatingSP ! thermostat load to heating setpoint (W)
REAL(r64) :: TempOutput ! terminal unit output [W]
INTEGER :: FanOpMode ! TU fan operating mode
MaxDeltaT = 0.d0
MinDeltaT = 0.d0
NumCoolingLoads = 0
SumCoolingLoads = 0.d0
NumHeatingLoads = 0
SumHeatingLoads = 0.d0
NumCoolingLoads(VRFCond) = 0
NumHeatingLoads(VRFCond) = 0
SumCoolingLoads(VRFCond) = 0.0d0
SumHeatingLoads(VRFCond) = 0.0d0
MaxDeltaT(VRFCond) = 0.0d0
MinDeltaT(VRFCond) = 0.0d0
ZoneDeltaT = 0.0d0
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .FALSE.
TerminalUnitList(TUListNum)%CoolingCoilAvailable = .FALSE.
TerminalUnitList(TUListNum)%HeatingCoilAvailable = .FALSE.
! loop through all TU's to find operating mode. Be carefull not to mix loop counters with current TU/Cond index
DO NumTU = 1, TerminalUnitList(TUListNum)%NumTUInList
! make sure TU's have been sized before looping through each one of them to determine operating mode
! (which would size all coils based on the zone that called this specific VRF terminal unit)
IF(ANY(TerminalUnitList(TUListNum)%TerminalUnitNotSizedYet))EXIT
TUIndex = TerminalUnitList(TUListNum)%ZoneTUPtr(NumTU)
ThisZoneNum = VRFTU(TUIndex)%ZoneNum
! check to see if coil is present
IF(TerminalUnitList(VRFCond)%CoolingCoilPresent(NumTU))THEN
! now check to see if coil is scheduled off
IF(GetCurrentScheduleValue(TerminalUnitList(TUListNum)%CoolingCoilAvailSchPtr(NumTU)) .GT. 0.d0)THEN
TerminalUnitList(TUListNum)%CoolingCoilAvailable(NumTU) = .TRUE.
END IF
END IF
! check to see if coil is present
IF(TerminalUnitList(VRFCond)%HeatingCoilPresent(NumTU))THEN
! now check to see if coil is scheduled off
IF(GetCurrentScheduleValue(TerminalUnitList(TUListNum)%HeatingCoilAvailSchPtr(NumTU)) .GT. 0.d0)THEN
TerminalUnitList(TUListNum)%HeatingCoilAvailable(NumTU) = .TRUE.
END IF
END IF
! Constant fan systems are tested for ventilation load to determine if load to be met changes.
! more logic may be needed here, what is the OA flow rate, was last mode heating or cooling, what control is used, etc...
ZoneLoad = ZoneSysEnergyDemand(ThisZoneNum)%RemainingOutputRequired
IF(VRF(VRFCond)%ThermostatPriority == ThermostatOffsetPriority)THEN
! for TSTATPriority, just check difference between zone temp and thermostat setpoint
IF(ThisZoneNum .GT. 0)THEN
SPTempHi = ZoneThermostatSetPointHi(ThisZoneNum)
SPTempLo = ZoneThermostatSetPointLo(ThisZoneNum)
SELECT CASE (TempControlType(ThisZoneNum))
CASE (0) ! Uncontrolled
CASE (SingleHeatingSetPoint)
ZoneDeltaT = MAX(0.0d0,SPTempLo - ZT(ThisZoneNum))
MaxDeltaT(VRFCond) = MAX(MaxDeltaT(VRFCond),ZoneDeltaT)
CASE (SingleCoolingSetPoint)
ZoneDeltaT = MIN(0.0d0,SPTempHi - ZT(ThisZoneNum))
MinDeltaT(VRFCond) = MIN(MinDeltaT(VRFCond),ZoneDeltaT)
CASE (SingleHeatCoolSetPoint)
ZoneDeltaT = ZT(ThisZoneNum) - SPTempHi !- SPTempHi and SPTempLo are same value
IF(ZoneDeltaT .GT. 0.0d0)THEN
MaxDeltaT(VRFCond) = MAX(MaxDeltaT(VRFCond),ZoneDeltaT)
ELSE
MinDeltaT(VRFCond) = MIN(MinDeltaT(VRFCond),ZoneDeltaT)
END IF
CASE (DualSetPointWithDeadBand)
IF(ZT(ThisZoneNum) - SPTempHi .GT. 0.0d0)THEN
ZoneDeltaT = MAX(0.0d0,ZT(ThisZoneNum) - SPTempHi)
MaxDeltaT(VRFCond) = MAX(MaxDeltaT(VRFCond),ZoneDeltaT)
ELSE IF(SPTempLo - ZT(ThisZoneNum) .GT. 0.0d0)THEN
ZoneDeltaT = MIN(0.0d0,ZT(ThisZoneNum) - SPTempLo)
MinDeltaT(VRFCond) = MIN(MinDeltaT(VRFCond),ZoneDeltaT)
END IF
CASE DEFAULT
END SELECT
END IF
ELSE IF(VRF(VRFCond)%ThermostatPriority == LoadPriority .OR. VRF(VRFCond)%ThermostatPriority == ZonePriority)THEN
IF(VRFTU(TUIndex)%OpMode == ContFanCycCoil)THEN
CALL SetCompFlowRate(TUIndex, VRFCond)
CALL CalcVRF(TUIndex,FirstHVACIteration,0.0d0,TempOutput,OnOffAirFlowRatio)
LoadToCoolingSP = ZoneSysEnergyDemand(ThisZoneNum)%OutputRequiredToCoolingSP
LoadToHeatingSP = ZoneSysEnergyDemand(ThisZoneNum)%OutputRequiredToHeatingSP
! If the Terminal Unit has a net cooling capacity (NoCompOutput < 0) and
! the zone temp is above the Tstat heating setpoint (QToHeatSetPt < 0)
IF(TempOutput < 0.0d0 .AND. LoadToHeatingSP .LT. 0.0d0)THEN
! If the net cooling capacity overshoots the heating setpoint count as heating load
IF(TempOutput < LoadToHeatingSP)THEN
! Don't count as heating load unless mode is allowed. Also check for floating zone.
IF(TempControlType(ThisZoneNum) .NE. SingleCoolingSetPoint .AND. &
TempControlType(ThisZoneNum) .NE. 0)THEN
IF(.NOT. LastModeHeating(VRFCond))THEN
! if last mode was cooling, make sure heating flow rate is used
IF(VRFTU(TUIndex)%OAMixerUsed)THEN
Node(VRFTU(TUIndex)%VRFTUOAMixerRetNodeNum)%MassFlowRate = VRFTU(TUIndex)%MaxHeatAirMassFlow
Node(VRFTU(TUIndex)%VRFTUOAMixerOANodeNum)%MassFlowRate = VRFTU(TUIndex)%HeatOutAirMassFlow
CALL SimOAMixer(VRFTU(TUIndex)%OAMixerName,FirstHVACIteration,VRFTU(TUIndex)%OAMixerIndex)
ELSE
Node(VRFTU(TUIndex)%VRFTUInletNodeNum)%MassFlowRate = VRFTU(TUIndex)%MaxHeatAirMassFlow
END IF
! recalculate using correct flow rate
CALL CalcVRF(TUIndex,FirstHVACIteration,0.0d0,TempOutput,OnOffAirFlowRatio)
IF(TempOutput < LoadToHeatingSP)THEN
NumHeatingLoads(VRFCond) = NumHeatingLoads(VRFCond) + 1
! sum heating load on condenser, not total zone heating load
SumHeatingLoads(VRFCond) = SumHeatingLoads(VRFCond) + (LoadToHeatingSP-TempOutput)
END IF
ELSE
NumHeatingLoads(VRFCond) = NumHeatingLoads(VRFCond) + 1
! sum heating load on condenser, not total zone heating load
SumHeatingLoads(VRFCond) = SumHeatingLoads(VRFCond) + (LoadToHeatingSP-TempOutput)
END IF
END IF
ELSE IF(TempOutput .LT. ZoneLoad)THEN
! If the net cooling capacity meets the zone cooling load but does not overshoot heating setpoint, turn off coil
! do nothing, the zone will float
ELSE IF(ZoneLoad .LT. 0.0d0)THEN
! still a cooling load
NumCoolingLoads(VRFCond) = NumCoolingLoads(VRFCond) + 1
! sum cooling load on condenser, not total zone cooling load
SumCoolingLoads(VRFCond) = SumCoolingLoads(VRFCond) + (LoadToCoolingSP-TempOutput)
END IF
! If the terminal unit has a net heating capacity and the zone temp is below the Tstat cooling setpoint
ELSE IF(TempOutput .GT. 0.0d0 .AND. LoadToCoolingSP .GT. 0.0d0)THEN
! If the net heating capacity overshoots the cooling setpoint count as cooling load
IF(TempOutput > LoadToCoolingSP)THEN
! Don't count as cooling load unless mode is allowed. Also check for floating zone.
IF(TempControlType(ThisZoneNum) .NE. SingleHeatingSetPoint .AND. &
TempControlType(ThisZoneNum) .NE. 0)THEN
IF(.NOT. LastModeCooling(VRFCond))THEN
IF(VRFTU(TUIndex)%OAMixerUsed)THEN
Node(VRFTU(TUIndex)%VRFTUOAMixerRetNodeNum)%MassFlowRate = VRFTU(TUIndex)%MaxCoolAirMassFlow
Node(VRFTU(TUIndex)%VRFTUOAMixerOANodeNum)%MassFlowRate = VRFTU(TUIndex)%CoolOutAirMassFlow
CALL SimOAMixer(VRFTU(TUIndex)%OAMixerName,FirstHVACIteration,VRFTU(TUIndex)%OAMixerIndex)
ELSE
Node(VRFTU(TUIndex)%VRFTUInletNodeNum)%MassFlowRate = VRFTU(TUIndex)%MaxCoolAirMassFlow
END IF
CALL CalcVRF(TUIndex,FirstHVACIteration,0.0d0,TempOutput,OnOffAirFlowRatio)
IF(TempOutput > LoadToCoolingSP)THEN
NumCoolingLoads(VRFCond) = NumCoolingLoads(VRFCond) + 1
SumCoolingLoads(VRFCond) = SumCoolingLoads(VRFCond) + (LoadToCoolingSP-TempOutput)
END IF
ELSE
NumCoolingLoads(VRFCond) = NumCoolingLoads(VRFCond) + 1
SumCoolingLoads(VRFCond) = SumCoolingLoads(VRFCond) + (LoadToCoolingSP-TempOutput)
END IF
END IF
ELSE IF(TempOutput > ZoneLoad)THEN
! do nothing, zone will float
ELSE IF(ZoneLoad > 0.0d0)THEN
NumHeatingLoads(VRFCond) = NumHeatingLoads(VRFCond) + 1
SumHeatingLoads(VRFCond) = SumHeatingLoads(VRFCond) + ZoneLoad
END IF
! ELSE there is no overshoot and the zone has a valid cooling load
ELSE IF(ZoneLoad .LT. 0.0d0)THEN
NumCoolingLoads(VRFCond) = NumCoolingLoads(VRFCond) + 1
SumCoolingLoads(VRFCond) = SumCoolingLoads(VRFCond) + ZoneLoad
! ELSE there is no overshoot and the zone has a valid heating load
ELSE IF(ZoneLoad .GT. 0.0d0)THEN
NumHeatingLoads(VRFCond) = NumHeatingLoads(VRFCond) + 1
SumHeatingLoads(VRFCond) = SumHeatingLoads(VRFCond) + ZoneLoad
END IF
ELSE ! is cycling fan
IF(ZoneLoad .GT. 0.0D0)THEN
NumHeatingLoads(VRFCond) = NumHeatingLoads(VRFCond) + 1
SumHeatingLoads(VRFCond) = SumHeatingLoads(VRFCond) + ZoneLoad
ELSE IF(ZoneLoad .LT. 0.0D0)THEN
NumCoolingLoads(VRFCond) = NumCoolingLoads(VRFCond) + 1
SumCoolingLoads(VRFCond) = SumCoolingLoads(VRFCond) + ZoneLoad
END IF
END IF ! IF(VRFTU(TUIndex)%OpMode == ContFanCycCoil)THEN
END IF
END DO
! Determine operating mode based on VRF type and thermostat control selection
SELECT CASE(VRF(VRFCond)%ThermostatPriority)
CASE(ThermostatOffsetPriority)
TUIndex = VRF(VRFCond)%MasterZoneTUIndex
IF (VRFTU(TUIndex)%FanOpModeSchedPtr .GT. 0) THEN
IF (GetCurrentScheduleValue(VRFTU(TUIndex)%FanOpModeSchedPtr) .EQ. 0.0d0) THEN
FanOpMode = CycFanCycCoil
ELSE
FanOpMode = ContFanCycCoil
END IF
END IF
IF(MaxDeltaT(VRFCond) .GT. ABS(MinDeltaT(VRFCond)) .AND. MaxDeltaT(VRFCond) .GT. 0.0d0)THEN
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .TRUE.
ELSE IF(MaxDeltaT(VRFCond) .LT. ABS(MinDeltaT(VRFCond)) .AND. MinDeltaT(VRFCond) .LT. 0.0d0)THEN
HeatingLoad(VRFCond) = .TRUE.
CoolingLoad(VRFCond) = .FALSE.
! assuming if constant fan mode then previous operating mode will be needed
! could actually run the master zone TU to see if overshoot occurs, but seems overkill
ELSE IF(FanOpMode == ContFanCycCoil .AND. LastModeCooling(VRFCond))THEN
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .TRUE.
ELSE IF(FanOpMode == ContFanCycCoil .AND. LastModeHeating(VRFCond))THEN
HeatingLoad(VRFCond) = .TRUE.
CoolingLoad(VRFCond) = .FALSE.
ELSE
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .FALSE.
END IF
CASE(LoadPriority)
IF(SumHeatingLoads(VRFCond) .GT. ABS(SumCoolingLoads(VRFCond)) .AND. SumHeatingLoads(VRFCond) .GT. 0.0D0)THEN
HeatingLoad(VRFCond) = .TRUE.
CoolingLoad(VRFCond) = .FALSE.
ELSE IF(SumHeatingLoads(VRFCond) .LE. ABS(SumCoolingLoads(VRFCond)) .AND. SumCoolingLoads(VRFCond) .LT. 0.0D0)THEN
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .TRUE.
ELSE
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .FALSE.
END IF
CASE(ZonePriority)
IF(NumHeatingLoads(VRFCond) .GT. NumCoolingLoads(VRFCond) .AND. NumHeatingLoads(VRFCond) .GT. 0)THEN
HeatingLoad(VRFCond) = .TRUE.
CoolingLoad(VRFCond) = .FALSE.
ELSE IF(NumHeatingLoads(VRFCond) .LE. NumCoolingLoads(VRFCond) .AND. NumCoolingLoads(VRFCond) .GT. 0)THEN
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .TRUE.
ELSE
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .FALSE.
END IF
CASE(ScheduledPriority)
IF(GetCurrentScheduleValue(VRF(VRFCond)%SchedPriorityPtr) == 0)THEN
HeatingLoad(VRFCond) = .TRUE.
CoolingLoad(VRFCond) = .FALSE.
ELSEIF(GetCurrentScheduleValue(VRF(VRFCond)%SchedPriorityPtr) == 1)THEN
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .TRUE.
ELSE
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .FALSE.
END If
CASE(MasterThermostatPriority)
ZoneLoad = ZoneSysEnergyDemand(VRF(VRFCond)%MasterZonePtr)%RemainingOutputRequired
IF(VRFTU(VRF(VRFCond)%MasterZoneTUIndex)%OpMode == ContFanCycCoil)THEN
CALL SetCompFlowRate(VRF(VRFCond)%MasterZoneTUIndex, VRFCond)
CALL CalcVRF(VRF(VRFCond)%MasterZoneTUIndex,FirstHVACIteration,0.0d0,TempOutput,OnOffAirFlowRatio)
LoadToCoolingSP = ZoneSysEnergyDemand(VRF(VRFCond)%MasterZonePtr)%OutputRequiredToCoolingSP
LoadToHeatingSP = ZoneSysEnergyDemand(VRF(VRFCond)%MasterZonePtr)%OutputRequiredToHeatingSP
IF(TempOutput .LT. LoadToHeatingSP)THEN
CoolingLoad(VRFCond) = .FALSE.
HeatingLoad(VRFCond) = .TRUE.
ELSE IF(TempOutput .GT. LoadToCoolingSP)THEN
CoolingLoad(VRFCond) = .TRUE.
HeatingLoad(VRFCond) = .FALSE.
ELSE
CoolingLoad(VRFCond) = .FALSE.
HeatingLoad(VRFCond) = .FALSE.
END IF
ELSE IF(ZoneLoad .GT. 0.0D0)THEN
HeatingLoad(VRFCond) = .TRUE.
CoolingLoad(VRFCond) = .FALSE.
ELSE IF(ZoneLoad .LT. 0.0D0)THEN
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .TRUE.
ELSE
HeatingLoad(VRFCond) = .FALSE.
CoolingLoad(VRFCond) = .FALSE.
END IF
CASE(FirstOnPriority)
! na
CASE DEFAULT
END SELECT
! limit to one possible mode
IF(CoolingLoad(VRFCond) .AND. HeatingLoad(VRFCond))HeatingLoad(VRFCond)=.FALSE.
RETURN
END SUBROUTINE InitializeOperatingMode