SUBROUTINE InitUnitarySystems(UnitarySysNum,AirLoopNum,OAUnitNum,OAUCoilOutTemp,FirstHVACIteration)
! SUBROUTINE INFORMATION:
! AUTHOR Richard Raustad, FSEC
! DATE WRITTEN February 2013
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine is for initializations of the unitary systems.
! METHODOLOGY EMPLOYED:
! Uses the status flags to trigger initializations.
! REFERENCES:
! na
! USE STATEMENTS:
USE DataAirLoop, ONLY: AirLoopControlInfo
USE DataAirflowNetwork, ONLY: AirflowNetworkUnitarySystem
USE DataPlant, ONLY: ScanPlantLoopsForObject, TypeOf_UnitarySystemRecovery, &
PlantLoop, TypeOf_CoilSteamAirHeating, TypeOf_CoilWaterSimpleHeating, &
TypeOf_CoilWaterCooling, TypeOf_CoilWaterDetailedFlatCooling
USE FluidProperties, ONLY: GetDensityGlycol, GetSatDensityRefrig
USE HeatingCoils, ONLY: SimulateHeatingCoilComponents, GetHeatingCoilCapacity=>GetCoilCapacity
USE WaterCoils, ONLY: GetCoilMaxWaterFlowRate, SimulateWaterCoilComponents, SetCoilDesFlow
USE HVACHXAssistedCoolingCoil, ONLY: GetHXDXCoilName,GetHXDXCoilIndex, GetCoilObjectTypeNum
USE SteamCoils, ONLY: GetCoilMaxSteamFlowRate, SimulateSteamCoilComponents, &
GetSteamCoilCapacity=>GetCoilCapacity
USE PlantUtilities, ONLY: SetComponentFlowRate, InitComponentNodes
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT (IN) :: UnitarySysNum ! number of the current DX Sys being simulated
INTEGER, INTENT (IN) :: AirLoopNum ! number of the current air loop being simulated
INTEGER, INTENT (IN), OPTIONAL :: OAUnitNum ! number of the current Outdoor air unit being simulated
REAL(r64), INTENT(IN), OPTIONAL :: OAUCoilOutTemp ! the coil inlet temperature of OutdoorAirUnit
LOGICAL, INTENT(IN) :: FirstHVACIteration ! True when first HVAC iteration
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyEnvrnFlag ! environment flag
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyPlantScanFlag ! used for finding on heat recovery plant loop
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MySuppCoilPlantScanFlag ! used for finding on heat recovery plant loop
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MySetPointCheckFlag ! tests for set point
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MySizingCheckFlag ! tests for sizing
LOGICAL,SAVE :: MyOneTimeFlag = .TRUE. ! one time flag
CHARACTER(len=MaxNameLength) :: CoolingCoilType =' ' ! Coil:Cooling:Water or Coil:Cooling:Water:DetailedGeometry
CHARACTER(len=MaxNameLength) :: CoolingCoilName =' ' ! Coil:Cooling:Water or Coil:Cooling:Water:DetailedGeometry
CHARACTER(len=MaxNameLength) :: HeatingCoilType =' ' ! Coil:Heating:Water or Coil:Heating:Steam
LOGICAL :: errFlag = .FALSE. ! error flag for mining functions
LOGICAL :: ErrorsFound = .FALSE. ! error flag for mining functions
INTEGER :: ControlNode ! control node number
INTEGER :: OutdoorAirUnitNum ! "ONLY" for ZoneHVAC:OutdoorAirUnit
INTEGER :: SteamIndex = 0 ! index of steam quality for steam heating coil
INTEGER :: TypeOfCoilWaterCooling = 0 ! Used for simple water cool coil or detailed geometry
INTEGER :: TypeOfCoilWaterHeating = 0 ! Used for simple water heat coil or steam coil
REAL(r64) :: OAUCoilOutletTemp = 0.0d0 ! "ONLY" for zoneHVAC:OutdoorAirUnit [C]
REAL(r64) :: mdot = 0.0d0 ! local temporary for mass flow rate (kg/s)
REAL(r64) :: SteamDensity = 0.0d0 ! density of steam at 100C, used for steam heating coils [kg/m3]
REAL(r64) :: CoilMaxVolFlowRate = 0.0d0 ! coil fluid maximum volume flow rate [m3/s]
REAL(r64) :: QACTUAL = 0.0d0 ! coil actual capacity [W]
REAL(r64) :: rho = 0.0d0 ! local fluid density [kg/m3]
REAL(r64) :: mdotHR = 0.0d0 ! heat recovery mass flow rate [kg/s]
! REAL(r64) :: SaveMassFlow = 0.0d0 ! saves node flow rate when checking heat coil capacity [m3/s]
IF (MyOneTimeFlag) THEN
ALLOCATE(MyEnvrnFlag(NumUnitarySystem))
ALLOCATE(MyPlantScanFlag(NumUnitarySystem))
ALLOCATE(MySuppCoilPlantScanFlag(NumUnitarySystem))
ALLOCATE(MySetPointCheckFlag(NumUnitarySystem))
ALLOCATE(MySizingCheckFlag(NumUnitarySystem))
MyEnvrnFlag = .TRUE.
MyPlantScanFlag = .TRUE.
MySuppCoilPlantScanFlag = .TRUE.
MySetPointCheckFlag = .TRUE.
MySizingCheckFlag = .TRUE.
MyOneTimeFlag = .FALSE.
AirflowNetworkUnitarySystem = .TRUE.
END IF
IF ( .NOT. SysSizingCalc .AND. MySizingCheckFlag(UnitarySysNum)) THEN
IF(UnitarySystem(UnitarySysNum)%FanExists .AND. &
(UnitarySystem(UnitarySysNum)%CoolCoilExists .AND. &
(UnitarySystem(UnitarySysNum)%HeatCoilExists .OR. UnitarySystem(UnitarySysNum)%SuppCoilExists))) &
AirLoopControlInfo(AirLoopNum)%UnitarySys = .TRUE.
AirLoopControlInfo(AirLoopNum)%UnitarySysSimulating = .TRUE.
CALL SizeUnitarySystem(UnitarySysNum, FirstHVACIteration, AirLoopNum)
MySizingCheckFlag(UnitarySysNum) = .FALSE.
IF (AirLoopNum > 0) THEN
AirLoopControlInfo(AirLoopNum)%FanOpMode = UnitarySystem(UnitarySysNum)%FanOpMode
AirLoopControlInfo(AirLoopNum)%CycFanSchedPtr = UnitarySystem(UnitarySysNum)%FanOpModeSchedPtr
END IF
END IF
IF (AirLoopNum .EQ.-1) THEN ! This DX system is component of ZoneHVAC:OutdoorAirUnit
OutdoorAirUnitNum=OAUnitNum
OAUCoilOutletTemp=OAUCoilOutTemp
END IF
! Scan hot water and steam heating coil plant components for one time initializations
IF (MyPlantScanFlag(UnitarySysNum) .AND. ALLOCATED(PlantLoop)) THEN
IF (UnitarySystem(UnitarySysNum)%HeatRecActive) THEN
errFlag=.FALSE.
CALL ScanPlantLoopsForObject(UnitarySystem(UnitarySysNum)%Name, &
TypeOf_UnitarySystemRecovery, &
UnitarySystem(UnitarySysNum)%HRLoopNum, &
UnitarySystem(UnitarySysNum)%HRLoopSideNum, &
UnitarySystem(UnitarySysNum)%HRBranchNum, &
UnitarySystem(UnitarySysNum)%HRCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitUnitarySystems: Program terminated for previous conditions.')
END IF
END IF
IF (UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWater .OR. &
UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWaterDetailed .OR. &
UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == CoilWater_CoolingHXAssisted) THEN
IF (UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWater) THEN
TypeOfCoilWaterCooling = TypeOf_CoilWaterCooling
CoolingCoilType = 'Coil:Cooling:Water'
CoolingCoilName = UnitarySystem(UnitarySysNum)%CoolingCoilName
ELSE IF(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWaterDetailed)THEN
TypeOfCoilWaterCooling = TypeOf_CoilWaterDetailedFlatCooling
CoolingCoilType = 'Coil:Cooling:Water:DetailedGeometry'
CoolingCoilName = UnitarySystem(UnitarySysNum)%CoolingCoilName
ELSE
TypeOfCoilWaterCooling = GetCoilObjectTypeNum(cAllCoilTypes(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num), &
UnitarySystem(UnitarySysNum)%CoolingCoilName,ErrFlag,.TRUE.)
IF(TypeOfCoilWaterCooling == Coil_CoolingWater)THEN
TypeOfCoilWaterCooling = TypeOf_CoilWaterCooling
CoolingCoilType = 'Coil:Cooling:Water'
ELSE IF(TypeOfCoilWaterCooling == Coil_CoolingWaterDetailed)THEN
TypeOfCoilWaterCooling = TypeOf_CoilWaterDetailedFlatCooling
CoolingCoilType = 'Coil:Cooling:Water:DetailedGeometry'
END IF
CoolingCoilName = GetHXDXCoilName(cAllCoilTypes(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num), &
UnitarySystem(UnitarySysNum)%CoolingCoilName,ErrFlag)
END IF
errFlag=.false.
CALL ScanPlantLoopsForObject( TRIM(CoolingCoilName), &
TypeOfCoilWaterCooling , &
UnitarySystem(UnitarySysNum)%CoolCoilLoopNum, &
UnitarySystem(UnitarySysNum)%CoolCoilLoopSide, &
UnitarySystem(UnitarySysNum)%CoolCoilBranchNum, &
UnitarySystem(UnitarySysNum)%CoolCoilCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitUnitarySystem: Program terminated for previous conditions.')
END IF
UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow = GetCoilMaxWaterFlowRate(CoolingCoilType, &
CoolingCoilName,ErrorsFound)
IF(UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow .GT. 0.0d0)THEN
rho = GetDensityGlycol(PlantLoop(UnitarySystem(UnitarySysNum)%CoolCoilLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(UnitarySystem(UnitarySysNum)%CoolCoilLoopNum)%FluidIndex, &
'InitUnitarySystem')
UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow = UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow * rho
END IF
! fill outlet node for coil
UnitarySystem(UnitarySysNum)%CoolCoilFluidOutletNodeNum = &
PlantLoop(UnitarySystem(UnitarySysNum)%CoolCoilLoopNum)%LoopSide(UnitarySystem(UnitarySysNum)%CoolCoilLoopSide) &
%Branch(UnitarySystem(UnitarySysNum)%CoolCoilBranchNum)%Comp(UnitarySystem(UnitarySysNum)%CoolCoilCompNum)%NodeNumOut
END IF
IF (UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWater .OR. &
UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingSteam) THEN
IF (UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWater) THEN
TypeOfCoilWaterHeating = TypeOf_CoilWaterSimpleHeating
HeatingCoilType = 'Coil:Heating:Water'
CALL SetCoilDesFlow(CALLCoilTypes(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num), &
UnitarySystem(UnitarySysNum)%HeatingCoilName, &
UnitarySystem(UnitarySysNum)%MaxHeatAirVolFlow,&
ErrorsFound)
ELSE
TypeOfCoilWaterHeating = TypeOf_CoilSteamAirHeating
HeatingCoilType = 'Coil:Heating:Steam'
END IF
errFlag=.false.
CALL ScanPlantLoopsForObject( UnitarySystem(UnitarySysNum)%HeatingCoilName, &
TypeOfCoilWaterHeating , &
UnitarySystem(UnitarySysNum)%HeatCoilLoopNum, &
UnitarySystem(UnitarySysNum)%HeatCoilLoopSide, &
UnitarySystem(UnitarySysNum)%HeatCoilBranchNum, &
UnitarySystem(UnitarySysNum)%HeatCoilCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitUnitarySystem: Program terminated for previous conditions.')
END IF
IF (UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWater) THEN
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow = GetCoilMaxWaterFlowRate(HeatingCoilType, &
UnitarySystem(UnitarySysNum)%HeatingCoilName,ErrorsFound)
IF(UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow .GT. 0.0d0)THEN
rho = GetDensityGlycol(PlantLoop(UnitarySystem(UnitarySysNum)%HeatCoilLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(UnitarySystem(UnitarySysNum)%HeatCoilLoopNum)%FluidIndex, &
'InitUnitarySystem')
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow = GetCoilMaxWaterFlowRate(HeatingCoilType, &
UnitarySystem(UnitarySysNum)%HeatingCoilName,ErrorsFound) * rho
END IF
ELSE
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow = &
GetCoilMaxSteamFlowRate(UnitarySystem(UnitarySysNum)%HeatingCoilIndex,ErrorsFound)
IF(UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow .GT. 0.0d0)THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitUnitarySystem')
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow = UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow * SteamDensity
END IF
END IF
! fill outlet node for coil
UnitarySystem(UnitarySysNum)%HeatCoilFluidOutletNodeNum = &
PlantLoop(UnitarySystem(UnitarySysNum)%HeatCoilLoopNum)%LoopSide(UnitarySystem(UnitarySysNum)%HeatCoilLoopSide) &
%Branch(UnitarySystem(UnitarySysNum)%HeatCoilBranchNum)%Comp(UnitarySystem(UnitarySysNum)%HeatCoilCompNum)%NodeNumOut
END IF
MyPlantScanFlag(UnitarySysNum) = .FALSE.
ELSEIF (MyPlantScanFlag(UnitarySysNum) .AND. .NOT. AnyPlantInModel) THEN
MyPlantScanFlag(UnitarySysNum) = .FALSE.
END IF
! Scan Supplemental hot water and steam heating coil plant components for one time initializations
IF (MySuppCoilPlantScanFlag(UnitarySysNum) .AND. ALLOCATED(PlantLoop)) THEN
IF (UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingWater) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject( UnitarySystem(UnitarySysNum)%SuppHeatCoilName, &
TypeOf_CoilWaterSimpleHeating , &
UnitarySystem(UnitarySysNum)%SuppCoilLoopNum, &
UnitarySystem(UnitarySysNum)%SuppCoilLoopSide, &
UnitarySystem(UnitarySysNum)%SuppCoilBranchNum, &
UnitarySystem(UnitarySysNum)%SuppCoilCompNum, &
errFlag=errFlag)
CALL SetCoilDesFlow(CALLCoilTypes(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num), &
UnitarySystem(UnitarySysNum)%SuppHeatCoilName, &
UnitarySystem(UnitarySysNum)%MaxHeatAirVolFlow,&
ErrorsFound)
IF (errFlag) THEN
CALL ShowFatalError('InitUnitarySystems: Program terminated for previous conditions.')
END IF
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
UnitarySystem(UnitarySysNum)%SuppHeatCoilName,ErrorsFound)
IF(UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow .GT. 0.0d0)THEN
rho = GetDensityGlycol(PlantLoop(UnitarySystem(UnitarySysNum)%SuppCoilLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(UnitarySystem(UnitarySysNum)%SuppCoilLoopNum)%FluidIndex, &
'InitUnitarySystems')
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
UnitarySystem(UnitarySysNum)%SuppHeatCoilName,ErrorsFound) * rho
END IF
! fill outlet node for coil
UnitarySystem(UnitarySysNum)%SuppCoilFluidOutletNodeNum = &
PlantLoop(UnitarySystem(UnitarySysNum)%SuppCoilLoopNum)%LoopSide(UnitarySystem(UnitarySysNum)%SuppCoilLoopSide) &
%Branch(UnitarySystem(UnitarySysNum)%SuppCoilBranchNum)%Comp(UnitarySystem(UnitarySysNum)%SuppCoilCompNum)%NodeNumOut
ELSEIF (UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingSteam) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject(UnitarySystem(UnitarySysNum)%SuppHeatCoilName, &
TypeOf_CoilSteamAirHeating , &
UnitarySystem(UnitarySysNum)%SuppCoilLoopNum, &
UnitarySystem(UnitarySysNum)%SuppCoilLoopSide, &
UnitarySystem(UnitarySysNum)%SuppCoilBranchNum, &
UnitarySystem(UnitarySysNum)%SuppCoilCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitUnitarySystems: Program terminated for previous conditions.')
END IF
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow = &
GetCoilMaxSteamFlowRate(UnitarySystem(UnitarySysNum)%SuppHeatCoilIndex,ErrorsFound)
IF(UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow .GT. 0.0d0)THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitUnitarySystems')
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow = UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow * SteamDensity
END IF
! fill outlet node for coil
UnitarySystem(UnitarySysNum)%SuppCoilFluidOutletNodeNum = &
PlantLoop(UnitarySystem(UnitarySysNum)%SuppCoilLoopNum)%LoopSide(UnitarySystem(UnitarySysNum)%SuppCoilLoopSide) &
%Branch(UnitarySystem(UnitarySysNum)%SuppCoilBranchNum)%Comp(UnitarySystem(UnitarySysNum)%SuppCoilCompNum)%NodeNumOut
END IF
MySuppCoilPlantScanFlag(UnitarySysNum) = .FALSE.
ELSEIF (MySuppCoilPlantScanFlag(UnitarySysNum) .AND. .NOT. AnyPlantInModel) THEN
MySuppCoilPlantScanFlag(UnitarySysNum) = .FALSE.
END IF
! do the Begin Environment initializations
IF (BeginEnvrnFlag .and. MyEnvrnFlag(UnitarySysNum)) THEN
UnitarySystem(UnitarySysNum)%DesignMassFlowRate = UnitarySystem(UnitarySysNum)%DesignFanVolFlowRate * StdRhoAir
UnitarySystem(UnitarySysNum)%MaxCoolAirMassFlow = UnitarySystem(UnitarySysNum)%MaxCoolAirVolFlow * StdRhoAir
UnitarySystem(UnitarySysNum)%MaxHeatAirMassFlow = UnitarySystem(UnitarySysNum)%MaxHeatAirVolFlow * StdRhoAir
UnitarySystem(UnitarySysNum)%MaxNoCoolHeatAirMassFlow = UnitarySystem(UnitarySysNum)%MaxNoCoolHeatAirVolFlow * StdRhoAir
UnitarySystem(UnitarySysNum)%SenLoadLoss = 0.0d0
IF (UnitarySystem(UnitarySysNum)%Humidistat) THEN
UnitarySystem(UnitarySysNum)%LatLoadLoss = 0.0d0
END IF
IF ((UnitarySystem(UnitarySysNum)%HeatRecActive) .AND. (.NOT. MyPlantScanFlag(UnitarySysNum)) ) THEN
rho = GetDensityGlycol(PlantLoop(UnitarySystem(UnitarySysNum)%HRLoopNum)%FluidName, &
60.0d0, &
PlantLoop(UnitarySystem(UnitarySysNum)%HRLoopNum)%FluidIndex, &
'InitUnitarySystems')
UnitarySystem(UnitarySysNum)%DesignHeatRecMassFlowRate = UnitarySystem(UnitarySysNum)%DesignHRWaterVolumeFlow * rho
CALL InitComponentNodes(0.0d0, UnitarySystem(UnitarySysNum)%DesignHeatRecMassFlowRate, &
UnitarySystem(UnitarySysNum)%HeatRecoveryInletNodeNum, &
UnitarySystem(UnitarySysNum)%HeatRecoveryOutletNodeNum, &
UnitarySystem(UnitarySysNum)%HRLoopNum, &
UnitarySystem(UnitarySysNum)%HRLoopSideNum, &
UnitarySystem(UnitarySysNum)%HRBranchNum, &
UnitarySystem(UnitarySysNum)%HRCompNum )
END IF
! set fluid-side hardware limits
IF(UnitarySystem(UnitarySysNum)%CoolCoilFluidInletNode .GT. 0)THEN
IF(UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow .EQ. Autosize)THEN
! If water coil max water flow rate is autosized, simulate once in order to mine max flow rate
IF(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWater) THEN
CoolingCoilType = 'Coil:Cooling:Water'
ELSE
CoolingCoilType = 'Coil:Cooling:Water:DetailedGeometry'
END IF
CALL SimulateWaterCoilComponents(UnitarySystem(UnitarySysNum)%CoolingCoilName,FirstHVACIteration, &
UnitarySystem(UnitarySysNum)%CoolingCoilIndex)
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate(CoolingCoilType, UnitarySystem(UnitarySysNum)%CoolingCoilName, &
ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
rho = GetDensityGlycol(PlantLoop(UnitarySystem(UnitarySysNum)%CoolCoilLoopNum)%fluidName, &
InitConvTemp, &
PlantLoop(UnitarySystem(UnitarySysNum)%CoolCoilLoopNum)%fluidIndex, &
'InitUnitarySystem')
UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow = CoilMaxVolFlowRate * rho
END IF
END IF
CALL InitComponentNodes(0.0d0, UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow, &
UnitarySystem(UnitarySysNum)%CoolCoilFluidInletNode, &
UnitarySystem(UnitarySysNum)%CoolCoilFluidOutletNodeNum, &
UnitarySystem(UnitarySysNum)%CoolCoilLoopNum, &
UnitarySystem(UnitarySysNum)%CoolCoilLoopSide, &
UnitarySystem(UnitarySysNum)%CoolCoilBranchNum, &
UnitarySystem(UnitarySysNum)%CoolCoilCompNum )
END IF
IF(UnitarySystem(UnitarySysNum)%HeatCoilFluidInletNode .GT. 0)THEN
IF(UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow .EQ. Autosize)THEN
! IF water coil max water flow rate is autosized, simulate once in order to mine max flow rate
IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWater) THEN
CALL SimulateWaterCoilComponents(UnitarySystem(UnitarySysNum)%HeatingCoilName,FirstHVACIteration, &
UnitarySystem(UnitarySysNum)%HeatingCoilIndex)
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
UnitarySystem(UnitarySysNum)%HeatingCoilName,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
rho = GetDensityGlycol(PlantLoop(UnitarySystem(UnitarySysNum)%HeatCoilLoopNum)%fluidName, &
InitConvTemp, &
PlantLoop(UnitarySystem(UnitarySysNum)%HeatCoilLoopNum)%fluidIndex, &
'InitUnitarySystems')
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow = CoilMaxVolFlowRate * rho
END IF
END IF
! If steam coil max steam flow rate is autosized, simulate once in order to mine max flow rate
IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingSteam) THEN
CALL SimulateSteamCoilComponents(UnitarySystem(UnitarySysNum)%HeatingCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity
UnitarySystem(UnitarySysNum)%HeatingCoilIndex, QActual)
CoilMaxVolFlowRate = GetCoilMaxSteamFlowRate(UnitarySystem(UnitarySysNum)%HeatingCoilIndex,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitUnitarySystems')
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity
END IF
END IF
END IF
CALL InitComponentNodes(0.0d0, UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow, &
UnitarySystem(UnitarySysNum)%HeatCoilFluidInletNode, &
UnitarySystem(UnitarySysNum)%HeatCoilFluidOutletNodeNum, &
UnitarySystem(UnitarySysNum)%HeatCoilLoopNum, &
UnitarySystem(UnitarySysNum)%HeatCoilLoopSide, &
UnitarySystem(UnitarySysNum)%HeatCoilBranchNum, &
UnitarySystem(UnitarySysNum)%HeatCoilCompNum )
END IF
IF(UnitarySystem(UnitarySysNum)%SuppCoilFluidInletNode .GT. 0)THEN
IF(UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow .EQ. Autosize)THEN
IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingWater) THEN
! If water coil max water flow rate is autosized, simulate once in order to mine max flow rate
CALL SimulateWaterCoilComponents(UnitarySystem(UnitarySysNum)%SuppHeatCoilName,FirstHVACIteration, &
UnitarySystem(UnitarySysNum)%SuppHeatCoilIndex)
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
UnitarySystem(UnitarySysNum)%SuppHeatCoilName,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
rho = GetDensityGlycol(PlantLoop(UnitarySystem(UnitarySysNum)%SuppCoilLoopNum)%fluidName, &
InitConvTemp, &
PlantLoop(UnitarySystem(UnitarySysNum)%SuppCoilLoopNum)%fluidIndex, &
'InitUnitarySystems')
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow = CoilMaxVolFlowRate * rho
END IF
END IF
IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingSteam) THEN
CALL SimulateSteamCoilComponents(UnitarySystem(UnitarySysNum)%SuppHeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity
UnitarySystem(UnitarySysNum)%SuppHeatCoilIndex, QActual)
CoilMaxVolFlowRate = GetCoilMaxSteamFlowRate(UnitarySystem(UnitarySysNum)%SuppHeatCoilIndex,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitUnitarySystems')
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity
END IF
END IF
CALL InitComponentNodes(0.0d0, UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow, &
UnitarySystem(UnitarySysNum)%SuppCoilFluidInletNode, &
UnitarySystem(UnitarySysNum)%SuppCoilFluidOutletNodeNum, &
UnitarySystem(UnitarySysNum)%SuppCoilLoopNum, &
UnitarySystem(UnitarySysNum)%SuppCoilLoopSide, &
UnitarySystem(UnitarySysNum)%SuppCoilBranchNum, &
UnitarySystem(UnitarySysNum)%SuppCoilCompNum )
END IF
END IF
IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingGas .OR. &
UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingElectric)THEN
CALL SimulateHeatingCoilComponents(UnitarySystem(UnitarySysNum)%HeatingCoilName,FirstHVACIteration, &
CompIndex=UnitarySystem(UnitarySysNum)%HeatingCoilIndex, &
QCoilReq=1.0d0, &
FanOpMode=UnitarySystem(UnitarySysNum)%FanOpMode, &
PartLoadRatio=1.0d0)
UnitarySystem(UnitarySysNum)%DesignHeatingCapacity = &
GetHeatingCoilCapacity(CALLCoilTypes(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num), &
UnitarySystem(UnitarySysNum)%HeatingCoilName,ErrFlag)
END IF
MyEnvrnFlag(UnitarySysNum) = .FALSE.
END IF
IF (.not. BeginEnvrnFlag) THEN
MyEnvrnFlag(UnitarySysNum) = .TRUE.
END IF
!Init maximum available Heat Recovery flow rate
IF ((UnitarySystem(UnitarySysNum)%HeatRecActive) .AND. (.NOT. MyPlantScanFlag(UnitarySysNum)) ) THEN
IF (GetCurrentScheduleValue(UnitarySystem(UnitarySysNum)%SysAvailSchedPtr) .GT. 0.0d0) THEN
IF (FirstHVACIteration) THEN
mdotHR = UnitarySystem(UnitarySysNum)%DesignHeatRecMassFlowRate
ELSE
IF (UnitarySystem(UnitarySysNum)%HeatRecoveryMassFlowRate > 0.0d0) THEN
mdotHR = UnitarySystem(UnitarySysNum)%HeatRecoveryMassFlowRate
ELSE
mdotHR = UnitarySystem(UnitarySysNum)%DesignHeatRecMassFlowRate
END IF
END IF
ELSE
mdotHR = 0.0d0
END IF
mdotHR = MIN(Node(UnitarySystem(UnitarySysNum)%HeatRecoveryOutletNodeNum)%MassFlowRateMaxAvail,mdotHR)
Node(UnitarySystem(UnitarySysNum)%HeatRecoveryInletNodeNum)%MassFlowRate = mdotHR
END IF
! get operating capacity of water and steam coil
IF(FirstHVACIteration .OR. UnitarySystem(UnitarySysNum)%DehumidControlType_Num == DehumidControl_CoolReheat) THEN
IF(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWater .OR. &
UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWaterDetailed) THEN
! set air-side and steam-side mass flow rates
mdot = MIN(Node(UnitarySystem(UnitarySysNum)%CoolCoilFluidOutletNodeNum)%MassFlowRateMaxAvail, &
UnitarySystem(UnitarySysNum)%MaxCoolCoilFluidFlow)
Node(UnitarySystem(UnitarySysNum)%CoolCoilFluidInletNode)%MassFlowRate = mdot
! simulate water coil to find operating capacity
CALL SimulateWaterCoilComponents(UnitarySystem(UnitarySysNum)%CoolingCoilName,FirstHVACIteration, &
UnitarySystem(UnitarySysNum)%CoolingCoilIndex, QActual)
UnitarySystem(UnitarySysNum)%DesignCoolingCapacity = QActual
END IF ! from IF(UnitarySystem(UnitarySysNum)%CoolingCoilType_Num == Coil_CoolingWater .OR. Coil_CoolingWaterDetailed
IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWater) THEN
! set air-side and steam-side mass flow rates
mdot = MIN(Node(UnitarySystem(UnitarySysNum)%HeatCoilFluidOutletNodeNum)%MassFlowRateMaxAvail, &
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow)
Node(UnitarySystem(UnitarySysNum)%HeatCoilFluidInletNode)%MassFlowRate = mdot
! simulate water coil to find operating capacity
! SaveMassFlow = Node(UnitarySystem(UnitarySysNum)%HeatCoilInletNodeNum)%MassFlowRate
! Node(UnitarySystem(UnitarySysNum)%HeatCoilInletNodeNum)%MassFlowRate = UnitarySystem(UnitarySysNum)%MaxHeatAirMassFlow
CALL SimulateWaterCoilComponents(UnitarySystem(UnitarySysNum)%HeatingCoilName,FirstHVACIteration, &
UnitarySystem(UnitarySysNum)%HeatingCoilIndex, QActual)
UnitarySystem(UnitarySysNum)%DesignHeatingCapacity = QActual
! Node(UnitarySystem(UnitarySysNum)%HeatCoilInletNodeNum)%MassFlowRate = SaveMassFlow
END IF ! from IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingWater) THEN
IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingSteam) THEN
! set air-side and steam-side mass flow rates
mdot = MIN(Node(UnitarySystem(UnitarySysNum)%HeatCoilFluidOutletNodeNum)%MassFlowRateMaxAvail, &
UnitarySystem(UnitarySysNum)%MaxHeatCoilFluidFlow)
Node(UnitarySystem(UnitarySysNum)%HeatCoilFluidInletNode)%MassFlowRate = mdot
! simulate steam coil to find operating capacity
CALL SimulateSteamCoilComponents(UnitarySystem(UnitarySysNum)%HeatingCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
UnitarySystem(UnitarySysNum)%HeatingCoilIndex, QActual)
UnitarySystem(UnitarySysNum)%DesignHeatingCapacity = &
GetSteamCoilCapacity(CALLCoilTypes(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num), &
UnitarySystem(UnitarySysNum)%HeatingCoilName,ErrorsFound)
END IF ! from IF(UnitarySystem(UnitarySysNum)%HeatingCoilType_Num == Coil_HeatingSteam) THEN
IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingWater) THEN
! set air-side and steam-side mass flow rates
mdot = MIN(Node(UnitarySystem(UnitarySysNum)%SuppCoilFluidOutletNodeNum)%MassFlowRateMaxAvail, &
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow)
Node(UnitarySystem(UnitarySysNum)%SuppCoilFluidInletNode)%MassFlowRate = mdot
! SaveMassFlow = Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate
! Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate = UnitarySystem(UnitarySysNum)%MaxHeatAirMassFlow
! simulate water coil to find operating capacity
IF(mdot > 0.0d0)THEN
! Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate = &
! UnitarySystem(UnitarySysNum)%MaxHeatAirMassFlow
CALL SimulateWaterCoilComponents(UnitarySystem(UnitarySysNum)%SuppHeatCoilName,FirstHVACIteration, &
UnitarySystem(UnitarySysNum)%SuppHeatCoilIndex, QActual)
UnitarySystem(UnitarySysNum)%DesignSuppHeatingCapacity = QActual
ELSE
UnitarySystem(UnitarySysNum)%DesignSuppHeatingCapacity = 0.0d0
END IF
! Node(UnitarySystem(UnitarySysNum)%SuppCoilAirInletNode)%MassFlowRate = SaveMassFlow
END IF ! from IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingWater) THEN
IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingSteam) THEN
! set air-side and steam-side mass flow rates
mdot = MIN(Node(UnitarySystem(UnitarySysNum)%SuppCoilFluidOutletNodeNum)%MassFlowRateMaxAvail, &
UnitarySystem(UnitarySysNum)%MaxSuppCoilFluidFlow)
Node(UnitarySystem(UnitarySysNum)%SuppCoilFluidInletNode)%MassFlowRate = mdot
! simulate steam coil to find operating capacity
CALL SimulateSteamCoilComponents(UnitarySystem(UnitarySysNum)%SuppHeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
UnitarySystem(UnitarySysNum)%SuppHeatCoilIndex, QActual)
UnitarySystem(UnitarySysNum)%DesignSuppHeatingCapacity = GetSteamCoilCapacity('Coil:Heating:Steam', &
UnitarySystem(UnitarySysNum)%SuppHeatCoilName,ErrorsFound)
END IF ! from IF(UnitarySystem(UnitarySysNum)%SuppHeatCoilType_Num == Coil_HeatingSteam) THEN
END IF ! from IF( FirstHVACIteration ) THEN
IF(MySetPointCheckFlag(UnitarySysNum))THEN
IF ( .NOT. SysSizingCalc .AND. DOSetPointTest) THEN
IF(UnitarySystem(UnitarySysNum)%CoolCoilExists)THEN
ControlNode = UnitarySystem(UnitarySysNum)%SystemCoolControlNodeNum
IF (ControlNode > 0) THEN
CALL CheckNodeSetPoint(UnitarySysNum,AirLoopNum, ControlNode, CoolingCoil,OAUCoilOutTemp)
END IF
END IF
IF(UnitarySystem(UnitarySysNum)%HeatCoilExists)THEN
ControlNode = UnitarySystem(UnitarySysNum)%SystemHeatControlNodeNum
IF (ControlNode > 0) THEN
CALL CheckNodeSetPoint(UnitarySysNum,AirLoopNum, ControlNode,HeatingCoil,OAUCoilOutTemp)
END IF
END IF
IF(UnitarySystem(UnitarySysNum)%SuppCoilExists)THEN
ControlNode = UnitarySystem(UnitarySysNum)%SuppHeatControlNodeNum
IF (ControlNode > 0) THEN
CALL CheckNodeSetPoint(UnitarySysNum,AirLoopNum, ControlNode,SuppHeatCoil,OAUCoilOutTemp)
END IF
END IF
MySetPointCheckFlag(UnitarySysNum) = .FALSE.
END IF
END IF
UnitarySystem(UnitarySysNum)%CoolingPartLoadFrac = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingPartLoadFrac = 0.0d0
UnitarySystem(UnitarySysNum)%SuppHeatPartLoadFrac = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingCycRatio = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedRatio = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingSpeedNum = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingCycRatio = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedRatio = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingSpeedNum = 0.0d0
UnitarySystem(UnitarySysNum)%HeatingCoilSensDemand = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingCoilSensDemand = 0.0d0
UnitarySystem(UnitarySysNum)%CoolingCoilLatentDemand = 0.0d0
UnitarySystem(UnitarySysNum)%DehumidInducedHeatingDemandRate = 0.0d0
UnitarySystem(UnitarySysNum)%InitHeatPump = .TRUE.
RETURN
END SUBROUTINE InitUnitarySystems