SUBROUTINE ControlUnitarySystemOutput(UnitarySysNum, FirstHVACIteration, OnOffAirFlowRatio, HXUnitOn, &
ZoneLoad, FullSensibleOutput, CompOn)
! SUBROUTINE INFORMATION:
! AUTHOR Richard Raustad, FSEC
! DATE WRITTEN February 2013
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine determines operating PLR and calculates the load based system output.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
USE General, ONLY: SolveRegulaFalsi, TrimSigDigits
USE DataHeatBalFanSys, ONLY: TempControlType
USE Psychrometrics, ONLY: PsyCpAirFnWTdb
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: UnitarySysNum ! Index of AirloopHVAC:UnitarySystem object
LOGICAL, INTENT(IN) :: FirstHVACIteration ! True when first HVAC iteration
REAL(R64), INTENT(INOUT) :: OnOffAirFlowRatio ! ratio of heating PLR to cooling PLR (is this correct?)
LOGICAL, INTENT(INOUT), OPTIONAL :: HXUnitOn ! Flag to control HX for HXAssisted Cooling Coil
REAL(R64), INTENT(IN) :: ZoneLoad
REAL(R64), INTENT(INOUT) :: FullSensibleOutput
INTEGER, OPTIONAL, INTENT(INOUT) :: CompOn
! SUBROUTINE PARAMETER DEFINITIONS:
INTEGER, PARAMETER :: MaxIter = 100 ! maximum number of iterations
REAL(r64), PARAMETER :: MinPLR = 0.0d0 ! minimum part load ratio allowed
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
CHARACTER(len=MaxNameLength) :: CompName ! Name of Unitary System object
INTEGER :: InletNode ! DX System inlet node number
INTEGER :: OutletNode ! DX System outlet node number
INTEGER :: OpMode ! fan operating mode (cycling or constant)
REAL(R64) :: PartLoadRatio ! operating part-load ratio
REAL(R64) :: SensOutputOff ! sensible output at PLR = 0 [W]
REAL(R64) :: LatOutputOff ! latent output at PLR = 0 [W]
REAL(R64) :: SensOutputOn ! sensible output at PLR = 1 [W]
REAL(R64) :: LatOutputOn ! latent output at PLR = 1 [W]
REAL(R64) :: CoolPLR ! cooing part load ratio
REAL(R64) :: HeatPLR ! heating part load ratio
REAL(r64), DIMENSION(10) :: Par ! parameters passed to RegulaFalsi function
INTEGER :: SolFlag ! return flag from RegulaFalsi for sensible load
INTEGER :: SolFlagLat ! return flag from RegulaFalsi for latent load
REAL(r64) :: TempLoad ! represents either a sensible or latent load [W]
REAL(r64) :: TempSysOutput ! represents either a sensible or latent capacity [W]
REAL(R64) :: TempSensOutput ! iterative sensible capacity [W]
REAL(R64) :: TempLatOutput ! iterative latent capacity [W]
REAL(R64) :: TempMinPLR ! iterative minimum PLR
REAL(R64) :: TempMaxPLR ! iterative maximum PLR
INTEGER :: SpeedNum ! multi-speed coil speed number
INTEGER :: CompressorONFlag ! 0= compressor off, 1= compressor off
REAL(r64) :: CoolingOnlySensibleOutput ! use to calculate dehumidification induced heating [W]
REAL(r64) :: CpAir ! specific heat of air [J/kg_C]
CompName = UnitarySystem(UnitarySysNum)%Name
InletNode = UnitarySystem(UnitarySysNum)%UnitarySystemInletNodeNum
OutletNode = UnitarySystem(UnitarySysNum)%UnitarySystemOutletNodeNum
OpMode = UnitarySystem(UnitarySysNum)%FanOpMode
! Pass full mass flow rate on FirstHVACIteration to set MassFlowRateMax
IF(FirstHVACIteration .AND. UnitarySystem(UnitarySysNum)%AirLoopEquipment)THEN
IF (UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == CoilDX_CoolingSingleSpeed .OR. &
UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == CoilDX_CoolingHXAssisted .OR. &
UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == CoilDX_HeatingEmpirical .OR. &
UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingAirToAirVariableSpeed .OR. &
UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingAirToAirVariableSpeed .OR. &
UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWaterToAirHPSimple .OR. &
UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWaterToAirHPSimple) THEN
PartLoadRatio = 1.0d0
IF(HeatingLoad)THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = UnitarySystem(UnitarySysNum)%NumOfSpeedHeating
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 1.0d0
ELSE
! CoolingLoad = .TRUE.
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = UnitarySystem(UnitarySysNum)%NumOfSpeedCooling
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 1.0d0
END IF
ELSE
IF(HeatingLoad)THEN
PartLoadRatio = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = UnitarySystem(UnitarySysNum)%NumOfSpeedHeating
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 1.0d0
IF (UnitarySystem(UnitarySysNum)%Staged .AND. ABS(UnitarySystem(UnitarySysNum)%StageNum) .LT. &
UnitarySystem(UnitarySysNum)%NumOfSpeedHeating) THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = ABS(UnitarySystem(UnitarySysNum)%StageNum)
IF (UnitarySystem(UnitarySysNum)%HeatingSpeedNum == 1) UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
END IF
ELSE
! CoolingLoad = .TRUE.
PartLoadRatio = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = UnitarySystem(UnitarySysNum)%NumOfSpeedCooling
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 1.0d0
IF (UnitarySystem(UnitarySysNum)%Staged .AND. ABS(UnitarySystem(UnitarySysNum)%StageNum) .LT. &
UnitarySystem(UnitarySysNum)%NumOfSpeedCooling) THEN
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = ABS(UnitarySystem(UnitarySysNum)%StageNum)
IF (UnitarySystem(UnitarySysNum)%CoolingSpeedNum == 1) UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
END IF
END IF
END IF
CALL SetOnOffMassFlowRate(UnitarySysNum, OnOffAirFlowRatio, PartLoadRatio)
IF(HeatingLoad)THEN
UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac=1.0d0
ELSE
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac=1.0d0
END IF
CompOn=0
RETURN
END IF
IF(GetCurrentScheduleValue(UnitarySystem(UnitarySysNum)%SysAvailSchedPtr) .LE. 0.0d0)THEN
RETURN
END IF
PartLoadRatio = 0.0d0 ! Get no load result
SolFlag = 0 ! # of iterations IF positive, -1 means failed to converge, -2 means bounds are incorrect
SolFlagLat = 0 ! # of iterations IF positive, -1 means failed to converge, -2 means bounds are incorrect
SensOutputOff = 0.0d0
LatOutputOff = 0.0d0
CoolPLR = 0.0d0
HeatPLR = 0.0d0
CompressorONFlag = 0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = 0.0d0
CALL SetOnOffMassFlowRate(UnitarySysNum, OnOffAirFlowRatio, PartLoadRatio)
IF (HeatingLoad) THEN
UnitarySystem(UnitarySysNum)%HeatingCoilSensDemand = ZoneLoad
UnitarySystem(UnitarySysNum)%CoolingCoilSensDemand = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingCoilLatentDemand = 0.0d0
ELSE IF(CoolingLoad .OR. MoistureLoad < 0.0d0)THEN
UnitarySystem(UnitarySysNum)%HeatingCoilSensDemand = 0.0d0
IF(CoolingLoad)THEN
UnitarySystem(UnitarySysNum)%CoolingCoilSensDemand = ABS(ZoneLoad)
ELSE
UnitarySystem(UnitarySysNum)%CoolingCoilSensDemand = 0.0d0
END IF
UnitarySystem(UnitarySysNum)%CoolingCoilLatentDemand = ABS(MoistureLoad)
ELSE
RETURN
END IF
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
FullSensibleOutput = SensOutputOff
IF(.NOT. HeatingLoad .AND. .NOT. CoolingLoad) THEN
! no load
IF(MoistureLoad >= 0.0d0 .OR. MoistureLoad > LatOutputOff) RETURN
! Dehumcontrol_Multimode only controls RH if there is a sensible load
IF(UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_Multimode) RETURN
END IF
! determine if PLR=0 meets the load
SELECT CASE (TempControlType(UnitarySystem(UnitarySysNum)%ControlZoneNum))
CASE(SingleHeatingSetPoint)
IF(HeatingLoad .AND. SensOutputOff .GT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(.NOT. HeatingLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
CASE(SingleCoolingSetPoint)
IF(CoolingLoad .AND. SensOutputOff .LT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(.NOT. CoolingLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
CASE(SingleHeatCoolSetPoint, DualSetPointWithDeadBand)
IF(HeatingLoad .AND. SensOutputOff .GT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(CoolingLoad .AND. SensOutputOff .LT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(.NOT. HeatingLoad .AND. .NOT. CoolingLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
CASE DEFAULT
! should never get here
END SELECT
! if a variable speed unit, the SensOutputOff at SpeedNum=1 must be checked to see if it exceeds the ZoneLoad
! This is still no load but at the first speed above idle
IF(HeatingLoad .AND. UnitarySystem(UnitarySysNum)%NumOfSpeedHeating > 0 .OR. &
CoolingLoad .AND. UnitarySystem(UnitarySysNum)%NumOfSpeedCooling > 0)THEN
IF(UnitarySystem(UnitarySysNum)%Staged)THEN
IF(HeatingLoad)THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = UnitarySystem(UnitarySysNum)%StageNum
ELSE
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = ABS(UnitarySystem(UnitarySysNum)%StageNum)
END IF
ELSE
IF(HeatingLoad)THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = 1
ELSE
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = 1
END IF
END IF
CALL SetOnOffMassFlowRate(UnitarySysNum, OnOffAirFlowRatio, PartLoadRatio)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
FullSensibleOutput = SensOutputOff
SELECT CASE (TempControlType(UnitarySystem(UnitarySysNum)%ControlZoneNum))
CASE(SingleHeatingSetPoint)
IF(HeatingLoad .AND. SensOutputOff .GT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(.NOT. HeatingLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
CASE(SingleCoolingSetPoint)
IF(CoolingLoad .AND. SensOutputOff .LT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(.NOT. CoolingLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
CASE(SingleHeatCoolSetPoint, DualSetPointWithDeadBand)
IF(HeatingLoad .AND. SensOutputOff .GT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(CoolingLoad .AND. SensOutputOff .LT. ZoneLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
IF(.NOT. HeatingLoad .AND. .NOT. CoolingLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad .GT. LatOutputOff))RETURN
CASE DEFAULT
! should never get here
END SELECT
END IF
PartLoadRatio = 1.0d0 ! Get full load result
IF(PRESENT(CompOn))THEN
CompressorONFlag = CompOn
ELSE
CompressorONFlag = 1
END IF
IF(HeatingLoad)THEN
CoolPLR = 0.0d0
HeatPLR = 1.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 1.0d0
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = HeatPLR
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = UnitarySystem(UnitarySysNum)%NumOfSpeedHeating
IF (UnitarySystem(UnitarySysNum)%Staged .AND. UnitarySystem(UnitarySysNum)%StageNum > 0) THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = MIN(UnitarySystem(UnitarySysNum)%StageNum, &
UnitarySystem(UnitarySysNum)%NumOfSpeedHeating)
CALL SetOnOffMassFlowRate(UnitarySysNum, OnOffAirFlowRatio, PartLoadRatio)
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
IF(SensOutputOff .GT. ZoneLoad)RETURN
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 1.0d0
END IF
ELSEIF(CoolingLoad .OR. MoistureLoad < LatOutputOff)THEN
CoolPLR = 1.0d0
HeatPLR = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = CoolPLR
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = UnitarySystem(UnitarySysNum)%NumOfSpeedCooling
IF (UnitarySystem(UnitarySysNum)%Staged .AND. UnitarySystem(UnitarySysNum)%StageNum < 0) THEN
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = MIN(ABS(UnitarySystem(UnitarySysNum)%StageNum), &
UnitarySystem(UnitarySysNum)%NumOfSpeedCooling)
CALL SetOnOffMassFlowRate(UnitarySysNum, OnOffAirFlowRatio, PartLoadRatio)
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
IF(SensOutputOff .LT. ZoneLoad)RETURN
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 1.0d0
END IF
ELSE
! will return here when no cooling or heating load and MoistureLoad > LatOutputOff (i.e., PLR=0)
RETURN
END IF
CALL SetOnOffMassFlowRate(UnitarySysNum, OnOffAirFlowRatio, PartLoadRatio)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOn,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
FullSensibleOutput = SensOutputOn
! turn on HX if DehumidControl_Multimode
IF(UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_Multimode .AND. &
MoistureLoad < 0.0d0 .AND. MoistureLoad < LatOutputOn .AND. CoolingLoad)THEN
HXUnitOn = .TRUE.
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOn,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
FullSensibleOutput = SensOutputOn
END IF
! test to see if full capacity is less than load, if so set to PLR=1 and RETURN if no moisture load
IF(HeatingLoad .AND. UnitarySystem(UnitarySysNum)%NumOfSpeedHeating .LE. 1 .OR. &
CoolingLoad .AND. UnitarySystem(UnitarySysNum)%NumOfSpeedCooling .LE. 1)THEN
SELECT CASE (TempControlType(UnitarySystem(UnitarySysNum)%ControlZoneNum))
CASE(SingleHeatingSetPoint)
IF(HeatingLoad .AND. SensOutputOn .LT. ZoneLoad)THEN
UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac = 1.0d0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = 1.0d0
IF(MoistureLoad >= 0.0d0 .OR. (MoistureLoad < 0.0d0 .AND. MoistureLoad < LatOutputOn))RETURN
END IF
IF(.NOT. HeatingLoad .AND. &
(MoistureLoad >= 0.0d0 .OR. (MoistureLoad < 0.0d0 .AND. MoistureLoad < LatOutputOn)))RETURN
CASE(SingleCoolingSetPoint)
IF(CoolingLoad .AND. SensOutputOn .GT. ZoneLoad)THEN
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac = 1.0d0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = 1.0d0
IF(MoistureLoad >= 0.0d0 .OR. (MoistureLoad < 0.0d0 .AND. MoistureLoad < LatOutputOn))RETURN
END IF
IF(.NOT. CoolingLoad .AND. &
(MoistureLoad >= 0.0d0 .OR. (MoistureLoad < 0.0d0 .AND. MoistureLoad < LatOutputOn)))RETURN
CASE(SingleHeatCoolSetPoint, DualSetPointWithDeadBand)
IF(HeatingLoad .AND. SensOutputOn .LT. ZoneLoad)THEN
UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac = 1.0d0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = 1.0d0
IF(MoistureLoad >= 0.0d0 .OR. (MoistureLoad < 0.0d0 .AND. MoistureLoad > LatOutputOn))THEN
RETURN
END IF
END IF
IF(CoolingLoad .AND. SensOutputOn .GT. ZoneLoad)THEN
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac = 1.0d0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = 1.0d0
RETURN
END IF
IF(.NOT. HeatingLoad .AND. .NOT. CoolingLoad .AND. &
(MoistureLoad >= 0.0d0 .OR. (MoistureLoad < 0.0d0 .AND. MoistureLoad < LatOutputOn)))THEN
RETURN
END IF
CASE DEFAULT
! no other choices for thermostat control
END SELECT
END IF
! will find speed for multispeed coils here and then RegulaFalsi on PLR at a fixed speed
! Do the non-variable or non-multispeed coils have a NumOfSpeed = 0 ? We don't need to do this for single speed coils.
! Check to see which speed to meet the load
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = 0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = 0
IF (.NOT. UnitarySystem(UnitarySysNum)%Staged) THEN
IF(HeatingLoad)THEN
DO SpeedNum=1,UnitarySystem(UnitarySysNum)%NumOfSpeedHeating
CoolPLR = 0.0d0
HeatPLR = 1.0d0
IF(SpeedNum == 1)THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 1.0d0
END IF
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = SpeedNum
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOn,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num /= Coil_HeatingWaterToAirHPVSEquationFit) THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = SpeedNum-1
IF(UnitarySystem(UnitarySysNum)%HeatingSpeedNum .EQ. 0)THEN
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 0.0d0
HeatPLR = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 1.0d0
HeatPLR = 1.0d0
END IF
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = SpeedNum
END IF
IF (ZoneLoad <= SensOutputOn) THEN
EXIT
END IF
END DO
ELSE ! Cooling or moisture load
DO SpeedNum=1,UnitarySystem(UnitarySysNum)%NumOfSpeedCooling
CoolPLR = 1.0d0
HeatPLR = 0.0d0
IF(SpeedNum == 1)THEN
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 1.0d0
END IF
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = SpeedNum
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR,OnOffAirFlowRatio, &
SensOutputOn,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
IF(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num /= Coil_CoolingWaterToAirHPVSEquationFit) THEN
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = SpeedNum-1
IF(UnitarySystem(UnitarySysNum)%CoolingSpeedNum .EQ. 0)THEN
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 0.0d0
CoolPLR = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 1.0d0
CoolPLR = 1.0d0
END IF
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR,OnOffAirFlowRatio, &
SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = SpeedNum
END IF
IF (ZoneLoad >= SensOutputOn) THEN
EXIT
END IF
END DO
END IF
ELSE ! IF (.NOT. UnitarySystem(UnitarySysNum)%Staged) THEN
! Staged control
IF(HeatingLoad)THEN
CoolPLR = 0.0d0
HeatPLR = 1.0d0
SpeedNum = UnitarySystem(UnitarySysNum)%StageNum
IF(SpeedNum == 1)THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 1.0d0
SpeedNum = MIN(UnitarySystem(UnitarySysNum)%StageNum,UnitarySystem(UnitarySysNum)%NumOfSpeedHeating)
END IF
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = SpeedNum
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOn,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num /= Coil_HeatingWaterToAirHPVSEquationFit) THEN
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = SpeedNum-1
IF(UnitarySystem(UnitarySysNum)%HeatingSpeedNum .EQ. 0)THEN
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 0.0d0
HeatPLR = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 1.0d0
HeatPLR = 1.0d0
END IF
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = SpeedNum
END IF
IF (ZoneLoad <= SensOutputOn) THEN
! EXIT ????????????
END IF
ELSE ! Cooling or moisture load
CoolPLR = 1.0d0
HeatPLR = 0.0d0
SpeedNum = ABS(UnitarySystem(UnitarySysNum)%StageNum)
IF(SpeedNum == 1)THEN
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 1.0d0
SpeedNum = MIN(ABS(UnitarySystem(UnitarySysNum)%StageNum),UnitarySystem(UnitarySysNum)%NumOfSpeedCooling)
END IF
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = SpeedNum
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR,OnOffAirFlowRatio, &
SensOutputOn,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
IF(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num /= Coil_CoolingWaterToAirHPVSEquationFit) THEN
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = SpeedNum-1
IF(UnitarySystem(UnitarySysNum)%CoolingSpeedNum .EQ. 0)THEN
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 0.0d0
CoolPLR = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 1.0d0
CoolPLR = 1.0d0
END IF
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR,OnOffAirFlowRatio, &
SensOutputOff,LatOutputOff,HXUnitOn,CompOn=CompressorONFlag)
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = SpeedNum
END IF
IF (ZoneLoad >= SensOutputOn) THEN
! EXIT ???????????
END IF
END IF
END IF ! IF (.NOT. UnitarySystem(UnitarySysNum)%Staged) THEN
FullSensibleOutput = SensOutputOn
IF(.NOT. HeatingLoad .AND. .NOT. CoolingLoad .AND. (MoistureLoad >= 0.0d0 .OR. MoistureLoad < LatOutputOn))THEN
! if no load, or only a moisture load which can't be met at PLR=1, RETURN
RETURN
END IF
! must test to see if load is bounded by capacity before calling RegulaFalsi
IF((HeatingLoad .AND. ZoneLoad < SensOutputOn) .OR. (CoolingLoad .AND. ZoneLoad > SensOutputOn))THEN
IF((HeatingLoad .AND. ZoneLoad > SensOutputOff) .OR. (CoolingLoad .AND. ZoneLoad < SensOutputOff))THEN
Par(1) = REAL(UnitarySysNum,r64)
Par(2) = 0.0d0 ! FLAG, IF 1.0 then FirstHVACIteration equals TRUE, if 0.0 then FirstHVACIteration equals false
IF(FirstHVACIteration)Par(2)=1.0d0
Par(3) = REAL(UnitarySystem(UnitarySysNum)%FanOpMode,r64)
Par(4) = CompressorONFlag ! CompOp
Par(5) = ZoneLoad
Par(6) = 0.0d0 ! FLAG, 0.0 if heating load, 1.0 IF cooling or moisture load
IF(CoolingLoad)Par(6) = 1.0d0
Par(7) = 1.0d0 ! FLAG, 0.0 if latent load, 1.0 if sensible load to be met
Par(8) = OnOffAirFlowRatio ! Ratio of compressor ON mass flow rate to AVERAGE mass flow rate over time step
Par(9) = 0.0d0 ! HXUnitOn is always false for HX
Par(10) = UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac
! Tolerance is in fraction of load, MaxIter = 30, SolFalg = # of iterations or error as appropriate
CALL SolveRegulaFalsi(0.001d0, MaxIter, SolFlag, PartLoadRatio, CalcUnitarySystemLoadResidual, 0.0d0, 1.0d0, Par)
IF (SolFlag == -1) THEN
IF(HeatingLoad)THEN
! IF iteration limit is exceeded, find tighter boundary of solution and repeat RegulaFalsi
! This does cause a problem when coil cannot turn on when OAT < min allowed or scheduled off
! If max iteration limit is exceeded, how do we know if the heating coil is operating?
TempMaxPLR = -0.1d0
TempSensOutput = SensOutputOff
DO WHILE((TempSensOutput - ZoneLoad) .LT. 0.0d0 .AND. TempMaxPLR .LT. 1.0d0)
! find upper limit of HeatingPLR
TempMaxPLR = TempMaxPLR + 0.1d0
! SUBROUTINE SetSpeedVariables(UnitarySysNum, SensibleLoad, PartLoadRatio)
CALL SetSpeedVariables(UnitarySysNum, .TRUE., TempMaxPLR)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,TempMaxPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
END DO
TempMinPLR = TempMaxPLR
DO WHILE((TempSensOutput - ZoneLoad) .GT. 0.0d0 .AND. TempMinPLR .GT. 0.0d0)
! pull upper limit of HeatingPLR down to last valid limit (i.e. heat output still exceeds SystemSensibleLoad)
TempMaxPLR = TempMinPLR
! find minimum limit of HeatingPLR
TempMinPLR = TempMinPLR - 0.01d0
CALL SetSpeedVariables(UnitarySysNum, .TRUE., TempMinPLR)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,TempMinPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
END DO
! Now solve again with tighter PLR limits
CALL SolveRegulaFalsi(0.001d0, MaxIter, SolFlag, HeatPLR, CalcUnitarySystemLoadResidual, TempMinPLR, TempMaxPLR, Par)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
ELSEIF(CoolingLoad)THEN
! RegulaFalsi may not find cooling PLR when the latent degradation model is used.
! IF iteration limit is exceeded, find tighter boundary of solution and repeat RegulaFalsi
TempMaxPLR = -0.1d0
TempSysOutput = SensOutputOff
TempLoad = ZoneLoad
DO WHILE((TempSysOutput - TempLoad) .GT. 0.0d0 .AND. TempMaxPLR .LT. 1.0d0)
! find upper limit of HeatingPLR
TempMaxPLR = TempMaxPLR + 0.1d0
CALL SetSpeedVariables(UnitarySysNum, .TRUE., TempMaxPLR)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,TempMaxPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
TempSysOutput = TempSensOutput
END DO
TempMinPLR = TempMaxPLR
DO WHILE((TempSysOutput - TempLoad) .LT. 0.0d0 .AND. TempMinPLR .GT. 0.0d0)
! pull upper limit of HeatingPLR DOwn to last valid limit (i.e. heat output still exceeds SystemSensibleLoad)
TempMaxPLR = TempMinPLR
! find minimum limit of HeatingPLR
TempMinPLR = TempMinPLR - 0.01d0
CALL SetSpeedVariables(UnitarySysNum, .TRUE., TempMinPLR)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,TempMinPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
TempSysOutput = TempSensOutput
END DO
! Now solve again with tighter PLR limits
CALL SolveRegulaFalsi(0.001d0, MaxIter, SolFlag, CoolPLR, CalcUnitarySystemLoadResidual, TempMinPLR, TempMaxPLR, Par)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
END IF ! IF(HeatingLoad)THEN
IF (SolFlag == -1) THEN
IF(ABS(ZoneLoad - TempSensOutput) .GT. SmallLoad)THEN
IF(UnitarySystem(UnitarySysNum)%MaxIterIndex == 0)THEN
CALL ShowWarningMessage('Coil control failed to converge for ' &
//TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//':'//TRIM(UnitarySystem(UnitarySysNum)%Name))
CALL ShowContinueError(' Iteration limit exceeded in calculating system sensible part-load ratio.')
CALL ShowContinueErrorTimeStamp('Sensible load to be met = ' &
//TRIM(TrimSigDigits(ZoneLoad,2))//' (watts), sensible output = ' &
//TRIM(TrimSigDigits(TempSensOutput,2))//' (watts), and the simulation continues.')
END IF
CALL ShowRecurringWarningErrorAtEnd(TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//' "'&
//TRIM(UnitarySystem(UnitarySysNum)%Name)//'" - Iteration limit exceeded in calculating'// &
' sensible part-load ratio error continues. Sensible load statistics:' &
,UnitarySystem(UnitarySysNum)%MaxIterIndex,ZoneLoad,ZoneLoad)
END IF
ELSEIF (SolFlag == -2) THEN
IF(UnitarySystem(UnitarySysNum)%RegulaFalsIFailedIndex == 0)THEN
CALL ShowWarningMessage('Coil control failed for ' &
//TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//':'//TRIM(UnitarySystem(UnitarySysNum)%Name))
CALL ShowContinueError(' sensible part-load ratio determined to be outside the range of 0-1.')
CALL ShowContinueErrorTimeStamp('Sensible load to be met = ' &
//TRIM(TrimSigDigits(ZoneLoad,2))//' (watts), and the simulation continues.')
END IF
CALL ShowRecurringWarningErrorAtEnd(TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//' "'&
//TRIM(UnitarySystem(UnitarySysNum)%Name)//'" - '// &
' sensible part-load ratio out of range error continues. Sensible load statistics:' &
,UnitarySystem(UnitarySysNum)%RegulaFalsIFailedIndex,ZoneLoad,ZoneLoad)
END IF
ELSEIF (SolFlag == -2) THEN
IF(UnitarySystem(UnitarySysNum)%RegulaFalsIFailedIndex == 0)THEN
CALL ShowWarningMessage('Coil control failed for ' &
//TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//':'//TRIM(UnitarySystem(UnitarySysNum)%Name))
CALL ShowContinueError(' sensible part-load ratio determined to be outside the range of 0-1.')
CALL ShowContinueErrorTimeStamp('Sensible load to be met = ' &
//TRIM(TrimSigDigits(ZoneLoad,2))//' (watts), and the simulation continues.')
END IF
CALL ShowRecurringWarningErrorAtEnd(TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//' "'&
//TRIM(UnitarySystem(UnitarySysNum)%Name)//'" - '// &
' sensible part-load ratio out of range error continues. Sensible load statistics:' &
,UnitarySystem(UnitarySysNum)%RegulaFalsIFailedIndex,ZoneLoad,ZoneLoad)
END IF ! IF (SolFlag == -1) THEN
ELSE ! load is not bounded by capacity. Leave PLR=1 or turn off unit?
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac = 0.0d0
CoolPLR = 0.0d0
HeatPLR = 0.0d0
PartLoadRatio = 0.0d0
END IF ! IF((HeatingLoad .AND. ZoneLoad > SensOutputOff) .OR. (CoolingLoad .AND. ZoneLoad < SensOutputOff))THEN
END IF ! IF((HeatingLoad .AND. ZoneLoad < SensOutputOn) .OR. (CoolingLoad .AND. ZoneLoad > SensOutputOn))THEN
IF(HeatingLoad .AND. (UnitarySystem(UnitarySysNum)%MultiSpeedHeatingCoil .OR. &
UnitarySystem(UnitarySysNum)%VarSpeedHeatingCoil)) THEN
IF(UnitarySystem(UnitarySysNum)%HeatingSpeedNum == 1)THEN
UnitarySystem(UnitarySysNum)%HeatingCycRatio = PartLoadRatio
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = PartLoadRatio
END IF
HeatPLR = PartLoadRatio
CoolPLR = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
ELSEIF(CoolingLoad .AND. (UnitarySystem(UnitarySysNum)%MultiSpeedCoolingCoil .OR. &
UnitarySystem(UnitarySysNum)%VarSpeedCoolingCoil))THEN
IF(UnitarySystem(UnitarySysNum)%CoolingSpeedNum == 1)THEN
UnitarySystem(UnitarySysNum)%CoolingCycRatio = PartLoadRatio
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
ELSE
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = PartLoadRatio
END IF
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
HeatPLR = 0.0d0
CoolPLR = PartLoadRatio
ELSE
HeatPLR = UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac
CoolPLR = UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac
END IF
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
! FullSensibleOutput is used to set supplemental heater PLR in calling routine
! OnOffAirFlowRatio is used to average air flow between ON and OFF state
FullSensibleOutput = TempSensOutput
! RETURN of the moisture load is met
IF(MoistureLoad >= 0.0d0 .OR. (MoistureLoad < 0.0d0 .AND. MoistureLoad >= TempLatOutput))RETURN
! Multimode does not meet the latent load, only the sensible load with or without HX active
IF(.NOT. CoolingLoad .AND. UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_Multimode)RETURN
! IF(HeatingLoad .AND. UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_CoolReheat)RETURN
IF (( UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_CoolReheat .OR. &
UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_Multimode))THEN
! find maximum latent output IF not already calculated
IF(HeatingLoad)THEN
CoolPLR = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = UnitarySystem(UnitarySysNum)%NumOfSpeedCooling
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 1.0d0
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 1.0d0
UnitarySystem(UnitarySysNum)%WSHPRuntimeFrac = CoolPLR
IF(UnitarySystem(UnitarySysNum)%CoolingSpeedNum .GT. 0)THEN
UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = 0
HeatPLR = 0.0d0
CoolingLoad = .TRUE.
HeatingLoad = .FALSE.
UnitarySystem(UnitarySysNum)%HeatingCoilSensDemand = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingCoilLatentDemand = MoistureLoad
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,0.0d0,0.0d0, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
ELSE
UnitarySystem(UnitarySysNum)%HeatingCoilSensDemand = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingCoilLatentDemand = 0.0d0
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,0.0d0,0.0d0, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
UnitarySystem(UnitarySysNum)%CoolingCoilLatentDemand = MoistureLoad
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
END IF
END IF
IF(UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_Multimode .AND. &
MoistureLoad < LatOutputOn)THEN
HXUnitOn = .TRUE.
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,LatOutputOn,HXUnitOn,CompOn=CompressorONFlag)
FullSensibleOutput = TempSensOutput
END IF
! IF ((HeatingLoad .AND. MoistureLoad < TempLatOutput) .OR. &
! (CoolingLoad .AND. MoistureLoad < TempLatOutput .AND. MoistureLoad > LatOutputOn) .OR. &
! ((.NOT. HeatingLoad) .AND. (.NOT. CoolingLoad) .AND. MoistureLoad > LatOutputOn)) THEN
IF ((MoistureLoad < TempLatOutput) .AND. (MoistureLoad > LatOutputOn)) THEN ! bounds check for RegulaFalsi
! save heating PLR
HeatPLR = UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac
Par(1) = REAL(UnitarySysNum,r64)
Par(2) = 0.0d0 ! FLAG, if 1.0 then FirstHVACIteration equals TRUE, if 0.0 then FirstHVACIteration equals false
IF(FirstHVACIteration)Par(2)=1.0d0
Par(3) = REAL(UnitarySystem(UnitarySysNum)%FanOpMode,r64)
Par(4) = CompressorONFlag ! CompOp
IF(UnitarySystem(UnitarySysNum)%DehumidControlType_Num .EQ. DehumidControl_Multimode)THEN
Par(5) = ZoneLoad
Par(7) = 1.0d0 ! FLAG, 0.0 if latent load, 1.0 if sensible load to be met
ELSE
Par(5) = MoistureLoad
Par(7) = 0.0d0 ! FLAG, 0.0 if latent load, 1.0 if sensible load to be met
END IF
Par(6) = 1.0d0 ! FLAG, 0.0 if heating load, 1.0 if cooling or moisture load
! IF(HeatingLoad)Par(6) = 0.0d0
Par(8) = OnOffAirFlowRatio ! Ratio of compressor ON mass flow rate to AVERAGE mass flow rate over time step
IF (HXUnitOn) THEN
Par(9) = 1.0d0
ELSE
Par(9) = 0.0d0
END IF
Par(10) = UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac
! Tolerance is fraction of load, MaxIter = 30, SolFalg = # of iterations or error as appropriate
CALL SolveRegulaFalsi(0.001d0, MaxIter, SolFlagLat, PartLoadRatio, CalcUnitarySystemLoadResidual, 0.0d0, 1.0d0, Par)
! IF (HeatingLoad) THEN
! UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac = PartLoadRatio
! ELSE
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac = PartLoadRatio
! END IF
UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac = HeatPLR
ELSEIF(MoistureLoad < LatOutputOn .AND. CoolingLoad)THEN
! Logic below needs further look...what to do if the bounds check for RegulaFalsi fail?
! I'm not even sure if this should be done.
! It's wrong anyway, since there won't be a cooling load if multimode (see RETURN about 80 lines up).
IF(UnitarySystem(UnitarySysNum)%DehumidControlType_Num .NE. DehumidControl_Multimode) THEN
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac = 1.0d0
END IF
END IF
END IF
CoolPLR = UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac
HeatPLR = UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
IF (SolFlagLat == -1) THEN
! RegulaFalsi may not find cooling PLR when the latent degradation model is used.
! IF iteration limit is exceeded, find tighter boundary of solution and repeat RegulaFalsi
TempMaxPLR = -0.1d0
TempLatOutput = LatOutputOff
DO WHILE((TempLatOutput - MoistureLoad) .GT. 0.0d0 .AND. TempMaxPLR .LT. 1.0d0)
! find upper limit of HeatingPLR
TempMaxPLR = TempMaxPLR + 0.1d0
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,TempMaxPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
END DO
TempMinPLR = TempMaxPLR
DO WHILE((TempLatOutput - MoistureLoad) .LT. 0.0 .AND. TempMinPLR .GT. 0.0d0)
! pull upper limit of HeatingPLR DOwn to last valid limit (i.e. heat output still exceeds SystemSensibleLoad)
TempMaxPLR = TempMinPLR
! find minimum limit of HeatingPLR
TempMinPLR = TempMinPLR - 0.01d0
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,TempMinPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
END DO
! Now solve again with tighter PLR limits
CALL SolveRegulaFalsi(0.001d0, MaxIter, SolFlagLat, CoolPLR, CalcUnitarySystemLoadResidual, TempMinPLR, TempMaxPLR, Par)
CALL CalcUnitarySystemToLoad(UnitarySysNum,FirstHVACIteration,CoolPLR,HeatPLR, &
OnOffAirFlowRatio,TempSensOutput,TempLatOutput,HXUnitOn,CompOn=CompressorONFlag)
IF (SolFlagLat == -1) THEN
IF(ABS(MoistureLoad - TempLatOutput) .GT. SmallLoad)THEN
IF(UnitarySystem(UnitarySysNum)%LatMaxIterIndex == 0)THEN
CALL ShowWarningMessage('Coil control failed to converge for ' &
//TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//':'//TRIM(UnitarySystem(UnitarySysNum)%Name))
CALL ShowContinueError(' Iteration limit exceeded in calculating system Latent part-load ratio.')
CALL ShowContinueErrorTimeStamp('Latent load to be met = ' &
//TRIM(TrimSigDigits(MoistureLoad,2))//' (watts), Latent output = ' &
//TRIM(TrimSigDigits(TempLatOutput,2))//' (watts), and the simulation continues.')
END IF
CALL ShowRecurringWarningErrorAtEnd(TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//' "'&
//TRIM(UnitarySystem(UnitarySysNum)%Name)//'" - Iteration limit exceeded in calculating'// &
' Latent part-load ratio error continues. Latent load statistics:' &
,UnitarySystem(UnitarySysNum)%LatMaxIterIndex,MoistureLoad,MoistureLoad)
END IF
ELSEIF (SolFlagLat == -2) THEN
IF(UnitarySystem(UnitarySysNum)%LatRegulaFalsIFailedIndex == 0)THEN
CALL ShowWarningMessage('Coil control failed for ' &
//TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//':'//TRIM(UnitarySystem(UnitarySysNum)%Name))
CALL ShowContinueError(' Latent part-load ratio determined to be outside the range of 0-1.')
CALL ShowContinueErrorTimeStamp('Latent load to be met = ' &
//TRIM(TrimSigDigits(MoistureLoad,2))//' (watts), and the simulation continues.')
END IF
CALL ShowRecurringWarningErrorAtEnd(TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//' "'&
//TRIM(UnitarySystem(UnitarySysNum)%Name)//'" - '// &
' Latent part-load ratio out of range error continues. Latent load statistics:' &
,UnitarySystem(UnitarySysNum)%LatRegulaFalsIFailedIndex,MoistureLoad,MoistureLoad)
END IF
ELSEIF (SolFlagLat == -2) THEN
IF(UnitarySystem(UnitarySysNum)%LatRegulaFalsIFailedIndex == 0)THEN
CALL ShowWarningMessage('Coil control failed for ' &
//TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//':'//TRIM(UnitarySystem(UnitarySysNum)%Name))
CALL ShowContinueError(' Latent part-load ratio determined to be outside the range of 0-1.')
CALL ShowContinueErrorTimeStamp('Latent load to be met = ' &
//TRIM(TrimSigDigits(MoistureLoad,2))//' (watts), and the simulation continues.')
END IF
CALL ShowRecurringWarningErrorAtEnd(TRIM(UnitarySystem(UnitarySysNum)%UnitarySystemType)//' "'&
//TRIM(UnitarySystem(UnitarySysNum)%Name)//'" - '// &
' Latent part-load ratio out of range error continues. Latent load statistics:' &
,UnitarySystem(UnitarySysNum)%LatRegulaFalsIFailedIndex,MoistureLoad,MoistureLoad)
END IF
FullSensibleOutput = TempSensOutput
CpAir = PsyCpAirFnWTdb(Node(UnitarySystem(UnitarySysNum)%CoolCoilInletNodeNum)%HumRat, &
Node(UnitarySystem(UnitarySysNum)%CoolCoilInletNodeNum)%Temp)
CoolingOnlySensibleOutput = Node(UnitarySystem(UnitarySysNum)%CoolCoilInletNodeNum)%MassFlowRate * CpAir * &
((Node(UnitarySystem(UnitarySysNum)%NodeNumOfControlledZone)%Temp-&
Node(UnitarySystem(UnitarySysNum)%CoolCoilOutletNodeNum)%Temp)- &
(Node(UnitarySystem(UnitarySysNum)%HeatCoilOutletNodeNum)%Temp-&
Node(UnitarySystem(UnitarySysNum)%HeatCoilInletNodeNum)%Temp))
IF(QToHeatSetPt .LT. 0.0d0)THEN
! Calculate the reheat coil load wrt the heating setpoint temperature. Reheat coil picks up
! the entire excess sensible cooling (DX cooling coil and impact of outdoor air).
UnitarySystem(UnitarySysNum)%DehumidInducedHeatingDemandRate = MAX(0.0d0,(CoolingOnlySensibleOutput+QToHeatSetPt))
! Heating mode and dehumidification is required
ELSEIF(QToHeatSetPt .GE. 0.0d0)THEN
! Calculate the reheat coil load as the sensible capacity of the DX cooling coil only. Let
! the heating coil pick up the load due to outdoor air.
UnitarySystem(UnitarySysNum)%DehumidInducedHeatingDemandRate = MAX(0.0d0,CoolingOnlySensibleOutput)
END IF
RETURN
END SUBROUTINE ControlUnitarySystemOutput