SUBROUTINE InitWaterThermalTank(WaterThermalTankNum, FirstHVACIteration, LoopNum, LoopSideNum )
! SUBROUTINE INFORMATION:
! AUTHOR Peter Graham Ellis
! DATE WRITTEN February 2004
! MODIFIED FSEC, July 2005
! Brent Griffith, October 2007 indirect fired water heater
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Initialize the water heater, heat pump water heater, or desuperheater heating coil objects during the simulation.
! determine flow rates thru use side and source side plant connections (if any)
! METHODOLOGY EMPLOYED:
! Inlet and outlet nodes are initialized. Scheduled values are retrieved for the current timestep.
! USE STATEMENTS:
USE DataGlobals, ONLY: BeginEnvrnFlag, WarmupFlag, AnyPlantInModel
USE DataInterfaces, ONLY: ShowSevereError, ShowWarningError, ShowContinueError, ShowContinueErrorTimeStamp
USE DataLoopNode, ONLY: Node
USE DataEnvironment, ONLY: WaterMainsTemp, OutDryBulbTemp, OutBaroPress
USE DataHeatBalFanSys, ONLY: MAT
USE ScheduleManager, ONLY: GetCurrentScheduleValue
USE Psychrometrics, ONLY: RhoH2O, PsyRhoAirFnPbTdbW, PsyWFnTdbRhPb, PsyHFnTdbW, PsyTwbFnTdbWPb, PsyWFnTdbTwbPb
USE DataHVACGlobals, ONLY: HPWHInletDBTemp, HPWHInletWBTemp, HPWHCrankcaseDBTemp, NumPlantLoops
USE DataSizing, ONLY: AutoSize
USE InputProcessor, ONLY: SameString
USE General, ONLY: TrimSigDigits, RoundSigDigits
USE DataZoneEquipment, ONLY: ZoneEquipInputsFilled,CheckZoneEquipmentList
USE DataPlant
USE PlantUtilities, ONLY: InitComponentNodes, SetComponentFlowRate, InterConnectTwoPlantLoopSides
USE FluidProperties, ONLY: GetDensityGlycol
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: WaterThermalTankNum
LOGICAL, INTENT(IN) :: FirstHVACIteration
INTEGER, INTENT(IN), OPTIONAL :: LoopNum
INTEGER, INTENT(IN), OPTIONAL :: LoopSideNum
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: UseInletNode ! Water heater use inlet node number
INTEGER :: UseOutletNode ! Water heater use outlet node number
INTEGER :: SourceInletNode ! Water heater source inlet node number
INTEGER :: SourceOutletNode ! Water heater source outlet node number
INTEGER :: SchIndex ! Index to schedule
INTEGER :: HPNum ! Index to heat pump
INTEGER :: HPAirInletNode ! HP air inlet node number
INTEGER :: HPAirOutletNode ! HP air outlet node number
INTEGER :: OutdoorAirNode ! Outdoor air inlet node number
INTEGER :: ExhaustAirNode ! Exhaust air outlet node number
INTEGER :: HPWaterInletNode ! HP condenser water inlet node number
INTEGER :: HPWaterOutletNode ! HP condenser water outlet node number
INTEGER :: InletAirMixerNode ! HP inlet node number after inlet mixing damper
INTEGER :: OutletAirSplitterNode ! HP outlet node number before outlet mixing damper
REAL(r64) :: HPInletDryBulbTemp ! HPWH's air inlet dry-bulb temperature, C
REAL(r64) :: HPInletHumRat ! HPWH's air inlet humidity ratio, kg/kg
REAL(r64) :: HPInletRelHum ! HPWH's air inlet relative humidity
REAL(r64) :: DeadBandTemp ! Minimum tank temperature (SetpointTemp - DeadbandDeltaTemp) (C)
! LOGICAL,SAVE :: ZoneEquipmentListChecked = .false. ! True after the Zone Equipment List has been checked for items
! Integer :: Loop
LOGICAL,SAVE :: InitWaterThermalTanksOnce = .TRUE. ! flag for 1 time initialization
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyEnvrnFlag ! flag for init once at start of environment
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyWarmupFlag ! flag for init after warmup complete
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: SetLoopIndexFlag ! get loop number flag
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MySizingDoneFlag ! true if sizing is finished
REAL(r64) :: sensedTemp
INTEGER :: tmpNodeNum
REAL(r64) :: mdotUse ! local temporary for use side mass flow
REAL(r64) :: mdotSource ! local temporary for source side mass flow
LOGICAL :: errFlag
REAL(r64) :: rho ! local fluid density
INTEGER :: DummyWaterIndex = 1
INTEGER :: found = 0
REAL(r64) :: TankChangeRateScale = 0.d0 ! local temporary for nominal tank change rate
REAL(r64) :: MaxSideVolFlow = 0.d0 ! local temporary for largest connection design flow
! FLOW:
If (InitWaterThermalTanksOnce) then
ALLOCATE (MyEnvrnFlag( NumWaterThermalTank ))
ALLOCATE (MyWarmupFlag( NumWaterThermalTank ))
ALLOCATE (SetLoopIndexFlag( NumWaterThermalTank ))
ALLOCATE (MySizingDoneFlag( NumWaterThermalTank ))
ALLOCATE(AlreadyRated(NumWaterThermalTank))
AlreadyRated = .FALSE.
MyEnvrnFlag = .TRUE.
MyWarmupFlag = .FALSE.
InitWaterThermalTanksOnce = .FALSE.
SetLoopIndexFlag = .TRUE.
MySizingDoneFlag = .FALSE.
END IF
UseInletNode = WaterThermalTank(WaterThermalTankNum)%UseInletNode
UseOutletNode = WaterThermalTank(WaterThermalTankNum)%UseOutletNode
SourceInletNode = WaterThermalTank(WaterThermalTankNum)%SourceInletNode
SourceOutletNode = WaterThermalTank(WaterThermalTankNum)%SourceOutletNode
IF(SetLoopIndexFlag(WaterThermalTankNum) .AND. ALLOCATED(PlantLoop) )THEN
IF ((UseInletNode > 0 ) .AND. (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum == 0)) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject(WaterThermalTank(WaterThermalTankNum)%Name, &
WaterThermalTank(WaterThermalTankNum)%TypeNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantBranchNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantCompNum, &
InletNodeNumber = UseInletNode, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitWaterThermalTank: Program terminated due to previous condition(s).')
ENDIF
rho = GetDensityGlycol(PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%FluidIndex, &
'GetWaterThermalTankInput')
WaterThermalTank(WaterThermalTankNum)%PlantUseMassFlowRateMax = &
WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate * rho
WaterThermalTank(WaterThermalTankNum)%Mass = WaterThermalTank(WaterThermalTankNum)%Volume * rho
WaterThermalTank(WaterThermalTankNum)%UseSidePlantSizNum = &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%PlantSizNum
IF ((WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate == AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%UseSidePlantSizNum == 0) ) THEN
CALL ShowSevereError('InitWaterThermalTank: Did not find Sizing:Plant object for use side of plant thermal tank = ' &
//TRIM(WaterThermalTank(WaterThermalTankNum)%Name) )
CALL ShowFatalError('InitWaterThermalTank: Program terminated due to previous condition(s).')
ENDIF
ENDIF
IF ((UseInletNode > 0 ) .AND. (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum > 0)) THEN
! this is a heat pump water heater, need a separate block because TypeOf_HeatPumpWtrHeater shows up on Branch
! (input should probably have been the associated tank )
errFlag=.false.
CALL ScanPlantLoopsForObject(HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%Name, &
TypeOf_HeatPumpWtrHeater, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantBranchNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantCompNum, &
InletNodeNumber = UseInletNode, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitWaterThermalTank: Program terminated due to previous condition(s).')
ENDIF
rho = GetDensityGlycol(PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%FluidIndex, &
'GetWaterThermalTankInput')
WaterThermalTank(WaterThermalTankNum)%PlantUseMassFlowRateMax = &
WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate * rho
WaterThermalTank(WaterThermalTankNum)%Mass = WaterThermalTank(WaterThermalTankNum)%Volume * rho
WaterThermalTank(WaterThermalTankNum)%UseSidePlantSizNum = &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%PlantSizNum
IF ((WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate == AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%UseSidePlantSizNum == 0) ) THEN
CALL ShowSevereError('InitWaterThermalTank: Did not find Sizing:Plant object for use side of plant thermal tank = ' &
//TRIM(WaterThermalTank(WaterThermalTankNum)%Name) )
CALL ShowFatalError('InitWaterThermalTank: Program terminated due to previous condition(s).')
ENDIF
ENDIF
IF ((SourceInletNode > 0) .AND. (WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum == 0) &
.AND. (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum == 0)) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject(WaterThermalTank(WaterThermalTankNum)%Name, &
WaterThermalTank(WaterThermalTankNum)%TypeNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantBranchNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantCompNum, &
InletNodeNumber = SourceInletNode, &
errFlag=errFlag)
IF (UseInletNode > 0 ) THEN
CALL InterConnectTwoPlantLoopSides( WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%TypeNum , .TRUE. )
ENDIF
IF (errFlag) THEN
CALL ShowFatalError('InitWaterThermalTank: Program terminated due to previous condition(s).')
ENDIF
rho = GetDensityGlycol(PlantLoop(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum)%FluidIndex, &
'GetWaterThermalTankInput')
WaterThermalTank(WaterThermalTankNum)%PlantSourceMassFlowRateMax = &
WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate * rho
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantSizNum = &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum)%PlantSizNum
IF ((WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate == AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantSizNum == 0) ) THEN
CALL ShowSevereError('InitWaterThermalTank: Did not find Sizing:Plant object for source side of plant thermal tank = ' &
//TRIM(WaterThermalTank(WaterThermalTankNum)%Name) )
CALL ShowFatalError('InitWaterThermalTank: Program terminated due to previous condition(s).')
ENDIF
ENDIF
IF ((SourceInletNode > 0) .AND. (WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum > 0) &
.OR. (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum > 0)) THEN
SetLoopIndexFlag(WaterThermalTankNum) = .FALSE.
ENDIF
IF (PlantSizesOkayToFinalize) SetLoopIndexFlag(WaterThermalTankNum) = .FALSE.
IF (WaterThermalTank(WaterThermalTankNum)%StandAlone) THEN
CALL SizeStandAloneWaterHeater(WaterThermalTankNum)
SetLoopIndexFlag(WaterThermalTankNum) = .FALSE.
ENDIF
ELSEIF( SetLoopIndexFlag(WaterThermalTankNum) .AND. .NOT. AnyPlantInModel) THEN
IF (WaterThermalTank(WaterThermalTankNum)%StandAlone) THEN
CALL SizeStandAloneWaterHeater(WaterThermalTankNum)
ENDIF
CALL CalcStandardRatings(WaterThermalTankNum)
SetLoopIndexFlag(WaterThermalTankNum) = .FALSE.
ENDIF
IF (WaterThermalTank(WaterThermalTankNum)%StandAlone .AND. (.NOT. AlreadyRated(WaterThermalTankNum))) THEN
CALL CalcStandardRatings(WaterThermalTankNum)
ENDIF
IF (BeginEnvrnFlag .AND. MyEnvrnFlag(WaterThermalTankNum) .AND. .NOT. SetLoopIndexFlag(WaterThermalTankNum)) THEN
IF (.NOT. MySizingDoneFlag(WaterThermalTankNum)) THEN
! IF (WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum > 0 ) THEN
! WaterThermalTank(WaterThermalTankNum)%UseSidePlantSizNum = &
! PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%PlantSizNum
! ENDIF
! IF (WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum > 0) THEN
! WaterThermalTank(WaterThermalTankNum)%SourceSidePlantSizNum = &
! PlantLoop(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum)%PlantSizNum
! ENDIF
! ! CALL MinePlantStructForInfo(WaterThermalTankNum)
CALL SizeTankForDemandSide(WaterThermalTankNum)
CALL SizeDemandSidePlantConnections(WaterThermalTankNum)
IF (PRESENT(LoopNum)) THEN
CALL SizeSupplySidePlantConnections(WaterThermalTankNum, LoopNum, LoopSideNum)
ELSE
CALL SizeSupplySidePlantConnections(WaterThermalTankNum)
ENDIF
CALL SizeTankForSupplySide(WaterThermalTankNum)
!
IF (PlantSizesOkayToFinalize) THEN
! check to see if any autosize values left, depending on the nature of this tank
IF (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum > 0 ) THEN ! this is heat pump water heater, source side not sized
IF (WaterThermalTank(WaterThermalTankNum)%UseInletNode > 0) THEN
IF ( (WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%Volume /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%MaxCapacity /= Autosize) ) THEN
MySizingDoneFlag(WaterThermalTankNum) = .TRUE.
ENDIF
ELSE
IF ( (WaterThermalTank(WaterThermalTankNum)%Volume /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%MaxCapacity /= Autosize) ) THEN
MySizingDoneFlag(WaterThermalTankNum) = .TRUE.
ENDIF
ENDIF
ELSE ! not a heat pump water heater
IF ((WaterThermalTank(WaterThermalTankNum)%UseInletNode > 0) .AND. &
(WaterThermalTank(WaterThermalTankNum)%SourceInletNode > 0 ) ) THEN
IF ( (WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%Volume /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%Height /= Autosize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%MaxCapacity /= Autosize) ) THEN
MySizingDoneFlag(WaterThermalTankNum) = .TRUE.
ENDIF
ELSEIF ((WaterThermalTank(WaterThermalTankNum)%UseInletNode > 0) .AND. &
(WaterThermalTank(WaterThermalTankNum)%SourceInletNode == 0 ) ) THEN
IF ( (WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%Volume /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%Height /= Autosize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%MaxCapacity /= Autosize) ) THEN
MySizingDoneFlag(WaterThermalTankNum) = .TRUE.
ENDIF
ELSEIF ((WaterThermalTank(WaterThermalTankNum)%UseInletNode == 0) .AND. &
(WaterThermalTank(WaterThermalTankNum)%SourceInletNode == 0 ) ) THEN
IF ( (WaterThermalTank(WaterThermalTankNum)%Volume /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%Height /= Autosize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%MaxCapacity /= Autosize) ) THEN
MySizingDoneFlag(WaterThermalTankNum) = .TRUE.
ENDIF
ENDIF
ENDIF
ENDIF
IF (.NOT. MySizingDoneFlag(WaterThermalTankNum)) THEN
IF ((WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum > 0) &
.OR. (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum > 0)) THEN
IF ( (WaterThermalTank(WaterThermalTankNum)%UseInletNode == 0) .AND. &
(WaterThermalTank(WaterThermalTankNum)%Volume /= AutoSize) .AND. &
(WaterThermalTank(WaterThermalTankNum)%MaxCapacity /= Autosize) ) THEN
MySizingDoneFlag(WaterThermalTankNum) = .TRUE.
ELSE
RETURN
ENDIF
ELSE
RETURN
ENDIF
ENDIF
IF ((WaterThermalTank(WaterThermalTankNum)%ControlType == ControlTypeCycle) .AND. MySizingDoneFlag(WaterThermalTankNum)) THEN
WaterThermalTank(WaterThermalTankNum)%MinCapacity = WaterThermalTank(WaterThermalTankNum)%MaxCapacity
ENDIF
! check for sizing issues that model can not suppport
! if stratified tank model, ensure that nominal change over rate is greater than one minute, avoid numerical problems.
IF ( (WaterThermalTank(WaterThermalTankNum)%TypeNum == StratifiedWaterHeater) &
.OR. (WaterThermalTank(WaterThermalTankNum)%TypeNum == StratifiedChilledWaterStorage)) THEN
MaxSideVolFlow = MAX( WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate, &
WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate)
IF (MaxSideVolFlow > 0.d0) THEN ! protect div by zero
TankChangeRateScale = WaterThermalTank(WaterThermalTankNum)%Volume / MaxSideVolFlow
IF (TankChangeRateScale < 60.d0) THEN ! nominal change over in less than one minute
CALL ShowSevereError('InitWaterThermalTank: Detected problem for stratified tank model. Model cannot be applied.')
CALL ShowContinueError('Occurs for stratified tank name = ' //TRIM(WaterThermalTank(WaterThermalTankNum)%Name) )
CALL ShowContinueError('Tank volume = '//TRIM(RoundSigDigits(WaterThermalTank(WaterThermalTankNum)%Volume, 4))//' [m3]')
CALL ShowContinueError('Tank use side volume flow rate = ' &
//TRIM(RoundSigDigits(WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate, 4))//' [m3/s]' )
CALL ShowContinueError('Tank source side volume flow rate = ' &
//TRIM(RoundSigDigits(WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate, 4))//' [m3/s]' )
CALL ShowContinueError('Nominal tank change over rate = '//TRIM(RoundSigDigits(TankChangeRateScale, 2))//' [s]')
CALL ShowContinueError('Change over rate is too fast, increase tank volume, decrease connection flow rates' &
//' or use mixed tank model')
CALL ShowFatalError('InitWaterThermalTank: Simulation halted because of sizing problem in stratified tank model.')
ENDIF
ENDIF
ENDIF
ENDIF
! Clear node initial conditions
IF (UseInletNode > 0 .AND. UseOutletNode > 0 ) THEN
Node(UseInletNode)%Temp = 0.d0
rho = GetDensityGlycol(PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)%FluidIndex, &
'GetWaterThermalTankInput')
WaterThermalTank(WaterThermalTankNum)%MassFlowRateMin = WaterThermalTank(WaterThermalTankNum)%VolFlowRateMin * rho
WaterThermalTank(WaterThermalTankNum)%PlantUseMassFlowRateMax = &
WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate * rho
CALL InitComponentNodes(WaterThermalTank(WaterThermalTankNum)%MassFlowRateMin, &
WaterThermalTank(WaterThermalTankNum)%PlantUseMassFlowRateMax, &
UseInletNode, UseOutletNode, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantBranchNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantCompNum )
WaterThermalTank(WaterThermalTankNum)%UseOutletTemp = 0.d0
WaterThermalTank(WaterThermalTankNum)%UseMassFlowRate = 0.d0
WaterThermalTank(WaterThermalTankNum)%SavedUseOutletTemp = 0.d0
WaterThermalTank(WaterThermalTankNum)%Mass = WaterThermalTank(WaterThermalTankNum)%Volume * rho
WaterThermalTank(WaterThermalTankNum)%UseBranchControlType = &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum)% &
LoopSide(WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopSide)% &
Branch(WaterThermalTank(WaterThermalTankNum)%UseSidePlantBranchNum)% &
Comp(WaterThermalTank(WaterThermalTankNum)%UseSidePlantCompNum )%FlowCtrl
END IF
IF ((SourceInletNode > 0) .AND. (WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum == 0) &
.AND. (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum == 0)) THEN
rho = GetDensityGlycol(PlantLoop(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum)%FluidIndex, &
'GetWaterThermalTankInput')
WaterThermalTank(WaterThermalTankNum)%PlantSourceMassFlowRateMax = &
WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate * rho
CALL InitComponentNodes(0.d0, WaterThermalTank(WaterThermalTankNum)%PlantSourceMassFlowRateMax, &
SourceInletNode, SourceOutletNode, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantBranchNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantCompNum )
WaterThermalTank(WaterThermalTankNum)%SourceOutletTemp = 0.d0
WaterThermalTank(WaterThermalTankNum)%SourceMassFlowRate = 0.d0
WaterThermalTank(WaterThermalTankNum)%SavedSourceOutletTemp = 0.d0
WaterThermalTank(WaterThermalTankNum)%SourceBranchControlType = &
PlantLoop(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum)% &
LoopSide(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopSide)% &
Branch(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantBranchNum)% &
Comp(WaterThermalTank(WaterThermalTankNum)%SourceSidePlantCompNum )%FlowCtrl
END IF
IF ((SourceInletNode > 0) .AND. ((WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum > 0) &
.OR. (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum > 0))) THEN
Node(SourceInletNode)%Temp = 0.d0
WaterThermalTank(WaterThermalTankNum)%SourceOutletTemp = 0.d0
WaterThermalTank(WaterThermalTankNum)%SourceMassFlowRate = 0.d0
WaterThermalTank(WaterThermalTankNum)%SavedSourceOutletTemp = 0.d0
rho = GetDensityGlycol('WATER', InitConvTemp, DummyWaterIndex, 'SizeTankForDemandSide')
WaterThermalTank(WaterThermalTankNum)%PlantSourceMassFlowRateMax = &
WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate * rho
ENDIF
! Initialize tank temperature to setpoint of first hour of warm up period
! (use HPWH or Desuperheater heating coil set point if applicable)
IF(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum .GT. 0)THEN
HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%Mode = FloatMode
HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SaveMode = FloatMode
HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SaveWHMode = FloatMode
SchIndex = HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SetpointTempSchedule
ELSE IF(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum .GT. 0)THEN
WaterHeaterDesuperheater(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum)%Mode = FloatMode
SchIndex= WaterHeaterDesuperheater(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum)%SetpointTempSchedule
ELSE
SchIndex = WaterThermalTank(WaterThermalTankNum)%SetpointTempSchedule
END IF
IF (SchIndex > 0) THEN
WaterThermalTank(WaterThermalTankNum)%TankTemp = GetCurrentScheduleValue(SchIndex)
WaterThermalTank(WaterThermalTankNum)%SavedTankTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
IF (WaterThermalTank(WaterThermalTankNum)%Nodes > 0) THEN
WaterThermalTank(WaterThermalTankNum)%Node%Temp = WaterThermalTank(WaterThermalTankNum)%TankTemp
WaterThermalTank(WaterThermalTankNum)%Node%SavedTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
END IF
ELSE
WaterThermalTank(WaterThermalTankNum)%TankTemp = 20.0d0
WaterThermalTank(WaterThermalTankNum)%SavedTankTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
IF (WaterThermalTank(WaterThermalTankNum)%Nodes > 0) THEN
WaterThermalTank(WaterThermalTankNum)%Node%Temp = WaterThermalTank(WaterThermalTankNum)%TankTemp
WaterThermalTank(WaterThermalTankNum)%Node%SavedTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
END IF
END IF
WaterThermalTank(WaterThermalTankNum)%SourceOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%SavedSourceOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%UseOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%SavedUseOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%TankTempAvg = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%SavedHeaterOn1 = .FALSE.
WaterThermalTank(WaterThermalTankNum)%SavedHeaterOn2 = .FALSE.
WaterThermalTank(WaterThermalTankNum)%Mode = 0
WaterThermalTank(WaterThermalTankNum)%SavedMode = 0
WaterThermalTank(WaterThermalTankNum)%FirstRecoveryDone = .FALSE.
WaterThermalTank(WaterThermalTankNum)%FirstRecoveryFuel = 0.d0
WaterThermalTank(WaterThermalTankNum)%UnmetEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%LossEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%FlueLossEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%UseEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%TotalDemandEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%SourceEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%HeaterEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%HeaterEnergy1 = 0.d0
WaterThermalTank(WaterThermalTankNum)%HeaterEnergy2 = 0.d0
WaterThermalTank(WaterThermalTankNum)%FuelEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%FuelEnergy1 = 0.d0
WaterThermalTank(WaterThermalTankNum)%FuelEnergy2 = 0.d0
WaterThermalTank(WaterThermalTankNum)%VentEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%OffCycParaFuelEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%OffCycParaEnergyToTank = 0.d0
WaterThermalTank(WaterThermalTankNum)%OnCycParaFuelEnergy = 0.d0
WaterThermalTank(WaterThermalTankNum)%OnCycParaEnergyToTank = 0.d0
WaterThermalTank(WaterThermalTankNum)%NetHeatTransferEnergy = 0.d0
IF ((WaterThermalTank(WaterThermalTankNum)%SourceDesignVolFlowRate == Autosize) .or. &
(WaterThermalTank(WaterThermalTankNum)%UseDesignVolFlowRate == Autosize) ) THEN
MyEnvrnFlag(WaterThermalTankNum) = .TRUE.
MyWarmupFlag(WaterThermalTankNum) = .FALSE.
ELSE
MyEnvrnFlag(WaterThermalTankNum) = .FALSE.
MyWarmupFlag(WaterThermalTankNum) = .TRUE.
ENDIF
END IF
IF (.NOT. BeginEnvrnFlag) MyEnvrnFlag(WaterThermalTankNum) = .TRUE.
IF ( MyWarmupFlag(WaterThermalTankNum) .and. (.not. WarmUpFlag)) then
! reInitialize tank temperature to setpoint of first hour (use HPWH or Desuperheater heating coil set point if applicable)
! BG's interpetation here is that its better to reset initial condition to setpoint once warm up is over.
! (otherwise with a dynamic storage model it is difficult for the user to see the initial performance if it isn't periodic.)
IF(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum .GT. 0)THEN
HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%Mode = FloatMode
SchIndex = HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SetpointTempSchedule
ELSE IF(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum .GT. 0)THEN
WaterHeaterDesuperheater(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum)%Mode = FloatMode
SchIndex = WaterHeaterDesuperheater(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum)%SetpointTempSchedule
ELSE
SchIndex = WaterThermalTank(WaterThermalTankNum)%SetpointTempSchedule
END IF
IF (SchIndex > 0) THEN
WaterThermalTank(WaterThermalTankNum)%TankTemp = GetCurrentScheduleValue(SchIndex)
WaterThermalTank(WaterThermalTankNum)%SavedTankTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
IF (WaterThermalTank(WaterThermalTankNum)%Nodes > 0) THEN
WaterThermalTank(WaterThermalTankNum)%Node%Temp = WaterThermalTank(WaterThermalTankNum)%TankTemp
WaterThermalTank(WaterThermalTankNum)%Node%SavedTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
END IF
ELSE
WaterThermalTank(WaterThermalTankNum)%TankTemp = 20.0d0
WaterThermalTank(WaterThermalTankNum)%SavedTankTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
IF (WaterThermalTank(WaterThermalTankNum)%Nodes > 0) THEN
WaterThermalTank(WaterThermalTankNum)%Node%Temp = WaterThermalTank(WaterThermalTankNum)%TankTemp
WaterThermalTank(WaterThermalTankNum)%Node%SavedTemp = WaterThermalTank(WaterThermalTankNum)%TankTemp
END IF
END IF
WaterThermalTank(WaterThermalTankNum)%SourceOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%SavedSourceOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%UseOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%SavedUseOutletTemp = WaterThermalTank(WaterThermalTankNum)%SavedTankTemp
WaterThermalTank(WaterThermalTankNum)%SavedHeaterOn1 = .FALSE.
WaterThermalTank(WaterThermalTankNum)%SavedHeaterOn2 = .FALSE.
WaterThermalTank(WaterThermalTankNum)%Mode = 0
WaterThermalTank(WaterThermalTankNum)%SavedMode = 0
MyWarmupFlag(WaterThermalTankNum) = .false.
END IF
IF (WarmUpFlag) MyWarmupFlag(WaterThermalTankNum) = .TRUE.
IF (FirstHVACIteration) THEN
! Get all scheduled values
SchIndex = WaterThermalTank(WaterThermalTankNum)%SetpointTempSchedule
WaterThermalTank(WaterThermalTankNum)%SetpointTemp = GetCurrentScheduleValue(SchIndex)
IF (.NOT. WaterThermalTank(WaterThermalTankNum)%IsChilledWaterTank) Then
IF (WaterThermalTank(WaterThermalTankNum)%SetpointTemp > WaterThermalTank(WaterThermalTankNum)%TankTempLimit) THEN
! Setpoint temperature scheduled higher than maximum tank temperature limit
WaterThermalTank(WaterThermalTankNum)%SetpointTemp = WaterThermalTank(WaterThermalTankNum)%TankTempLimit - 1.0d0
IF(WaterThermalTank(WaterThermalTankNum)%ShowSetpointWarning)THEN
CALL ShowSevereError('Water heater = '//TRIM(WaterThermalTank(WaterThermalTankNum)%Name)// &
': Water heater tank set point temperature is greater than the maximum tank temperature limit.')
CALL ShowContinueErrorTimeStamp(' Water heater tank set point temperature is reset to Tank Temperature'// &
' Limit minus 1 C ('//TRIM(TrimSigDigits(WaterThermalTank(WaterThermalTankNum)%SetpointTemp,2))// &
') and simulation continues. ')
WaterThermalTank(WaterThermalTankNum)%ShowSetpointWarning = .FALSE.
END IF
END IF
ELSE
IF (WaterThermalTank(WaterThermalTankNum)%SetpointTemp < WaterThermalTank(WaterThermalTankNum)%TankTempLimit) THEN
! Setpoint temperature scheduled lower than minimum tank temperature limit
WaterThermalTank(WaterThermalTankNum)%SetpointTemp = WaterThermalTank(WaterThermalTankNum)%TankTempLimit + 1.0d0
IF(WaterThermalTank(WaterThermalTankNum)%ShowSetpointWarning)THEN
CALL ShowSevereError('Chilled Water Tank = '//TRIM(WaterThermalTank(WaterThermalTankNum)%Name)// &
': Water heater tank set point temperature is lower than the minimum tank temperature limit.')
CALL ShowContinueErrorTimeStamp(' Chilled water tank set point temperature is reset to Tank Temperature'// &
' Limit plus 1 C ('//TRIM(TrimSigDigits(WaterThermalTank(WaterThermalTankNum)%SetpointTemp,2))// &
') and simulation continues. ')
WaterThermalTank(WaterThermalTankNum)%ShowSetpointWarning = .FALSE.
END IF
END IF
ENDIF
SchIndex = WaterThermalTank(WaterThermalTankNum)%SetpointTempSchedule2
IF (SchIndex > 0) THEN
WaterThermalTank(WaterThermalTankNum)%SetpointTemp2 = GetCurrentScheduleValue(SchIndex)
END IF
SELECT CASE (WaterThermalTank(WaterThermalTankNum)%AmbientTempIndicator)
CASE (AmbientTempSchedule)
SchIndex = WaterThermalTank(WaterThermalTankNum)%AmbientTempSchedule
WaterThermalTank(WaterThermalTankNum)%AmbientTemp = GetCurrentScheduleValue(SchIndex)
CASE (AmbientTempZone)
WaterThermalTank(WaterThermalTankNum)%AmbientTemp = MAT(WaterThermalTank(WaterThermalTankNum)%AmbientTempZone)
CASE (AmbientTempOutsideAir)
WaterThermalTank(WaterThermalTankNum)%AmbientTemp = &
Node(WaterThermalTank(WaterThermalTankNum)%AmbientTempOutsideAirNode)%Temp
END SELECT
IF (UseInletNode == 0) THEN ! Stand-alone operation
SchIndex = WaterThermalTank(WaterThermalTankNum)%UseInletTempSchedule
IF (SchIndex > 0) THEN
WaterThermalTank(WaterThermalTankNum)%UseInletTemp = GetCurrentScheduleValue(SchIndex)
ELSE
WaterThermalTank(WaterThermalTankNum)%UseInletTemp = WaterMainsTemp
END IF
SchIndex = WaterThermalTank(WaterThermalTankNum)%FlowRateSchedule
IF (SchIndex > 0) THEN
WaterThermalTank(WaterThermalTankNum)%UseMassFlowRate = GetCurrentScheduleValue(SchIndex)* &
WaterThermalTank(WaterThermalTankNum)%MassFlowRateMax
WaterThermalTank(WaterThermalTankNum)%VolFlowRate = &
WaterThermalTank(WaterThermalTankNum)%UseMassFlowRate / RhoH2O(InitConvTemp)
ELSE
WaterThermalTank(WaterThermalTankNum)%UseMassFlowRate = &
WaterThermalTank(WaterThermalTankNum)%MassFlowRateMax
WaterThermalTank(WaterThermalTankNum)%VolFlowRate = &
WaterThermalTank(WaterThermalTankNum)%UseMassFlowRate / RhoH2O(InitConvTemp)
END IF
END IF
IF (WaterThermalTank(WaterThermalTankNum)%HeatPumpNum .GT. 0) THEN
HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SetpointTemp = &
GetCurrentScheduleValue(HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SetpointTempSchedule)
IF (HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SetpointTemp .GE. &
WaterThermalTank(WaterThermalTankNum)%TankTempLimit) THEN
! HP setpoint temperature scheduled equal to or higher than tank temperature limit
HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SetpointTemp = &
WaterThermalTank(WaterThermalTankNum)%TankTempLimit - 1.0d0
IF(HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%ShowSetpointWarning)THEN
CALL ShowSevereError('Heat Pump Water Heater = '// &
TRIM(HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%Name)// &
': Heat Pump water heater set point temperature is equal to or greater than the maximum tank temperature limit.')
CALL ShowContinueErrorTimeStamp(' Heat Pump water heater tank set point temperature is reset to Tank Temperature'// &
' Limit minus 1 C ('// &
TRIM(TrimSigDigits(HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%SetpointTemp,2))// &
') and simulation continues. ')
HPWaterHeater(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum)%ShowSetpointWarning = .FALSE.
END IF
END IF
END IF
IF (WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum .GT. 0) THEN
WaterHeaterDesuperheater(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum)%SetpointTemp = &
GetCurrentScheduleValue( &
WaterHeaterDesuperheater(WaterThermalTank(WaterThermalTankNum)%DesuperheaterNum)%SetpointTempSchedule)
END IF
ENDIF ! first HVAC Iteration
IF (UseInletNode > 0 .AND. .NOT. SetLoopIndexFlag(WaterThermalTankNum)) THEN ! setup mass flows for plant connections
IF (WaterThermalTank(WaterThermalTankNum)%IsChilledWaterTank) Then
DeadBandTemp = WaterThermalTank(WaterThermalTankNum)%SetpointTemp + WaterThermalTank(WaterThermalTankNum)%DeadbandDeltaTemp
ELSE
DeadBandTemp = WaterThermalTank(WaterThermalTankNum)%SetpointTemp - WaterThermalTank(WaterThermalTankNum)%DeadbandDeltaTemp
ENDIF
mdotUse = PlantMassFlowRatesFunc(WaterThermalTankNum, UseInletNode, &
FirstHVACIteration, UseSide, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%UseSideSeries, &
WaterThermalTank(WaterThermalTankNum)%UseBranchControlType, &
WaterThermalTank(WaterThermalTankNum)%SavedUseOutletTemp, &
DeadBandTemp, WaterThermalTank(WaterThermalTankNum)%SetpointTemp)
CALL SetComponentFlowRate(mdotUse, UseInletNode, UseOutletNode, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantBranchNum, &
WaterThermalTank(WaterThermalTankNum)%UseSidePlantCompNum)
WaterThermalTank(WaterThermalTankNum)%UseInletTemp = Node(UseInletNode)%Temp
WaterThermalTank(WaterThermalTankNum)%UseMassFlowRate = mdotUse
ENDIF
IF (SourceInletNode > 0.AND. .NOT. SetLoopIndexFlag(WaterThermalTankNum)) THEN ! setup mass flows for plant connections
IF (WaterThermalTank(WaterThermalTankNum)%IsChilledWaterTank) Then
DeadBandTemp = WaterThermalTank(WaterThermalTankNum)%SetpointTemp + WaterThermalTank(WaterThermalTankNum)%DeadbandDeltaTemp
ELSE
DeadBandTemp = WaterThermalTank(WaterThermalTankNum)%SetpointTemp - WaterThermalTank(WaterThermalTankNum)%DeadbandDeltaTemp
ENDIF
IF (WaterThermalTank(WaterThermalTankNum)%TypeNum == StratifiedChilledWaterStorage) THEN
tmpNodeNum = WaterThermalTank(WaterThermalTankNum)%HeaterNode1
sensedTemp = WaterThermalTank(WaterThermalTankNum)%Node(tmpNodeNum)%SavedTemp
ELSE
sensedTemp = WaterThermalTank(WaterThermalTankNum)%SavedSourceOutletTemp
ENDIF
mdotSource = PlantMassFlowRatesFunc(WaterThermalTankNum, SourceInletNode, &
FirstHVACIteration, SourceSide, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%SourceSideSeries, &
WaterThermalTank(WaterThermalTankNum)%SourceBranchControlType, &
sensedTemp, &
DeadBandTemp, WaterThermalTank(WaterThermalTankNum)%SetpointTemp)
IF (WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum > 0) THEN
CALL SetComponentFlowRate(mdotSource, SourceInletNode, SourceOutletNode, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantLoopSide, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantBranchNum, &
WaterThermalTank(WaterThermalTankNum)%SourceSidePlantCompNum)
ELSE !not really plant connected (desuperheater or heat pump)
Node(SourceInletNode)%MassFLowRate = mdotSource
Node(SourceOutletNode)%MassFLowRate = mdotSource
ENDIF
WaterThermalTank(WaterThermalTankNum)%SourceInletTemp = Node(SourceInletNode)%Temp
WaterThermalTank(WaterThermalTankNum)%SourceMassFlowRate = mdotSource
ENDIF
!
! initialize HPWHs each iteration
IF(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum .GT. 0)THEN
HPNum = WaterThermalTank(WaterThermalTankNum)%HeatPumpNum
IF(MyHPSizeFlag(HPNum))THEN
! autosize info must be calculated in GetWaterThermalTankInputFlag for use in StandardRating procedure
! (called at end of GetWaterThermalTankInputFlag)
! report autosizing information here (must be done after GetWaterThermalTankInputFlag is complete)
IF(HPWaterHeater(HPNum)%WaterFlowRateAutosized)THEN
CALL ReportSizingOutput(HPWaterHeater(HPNum)%Type, HPWaterHeater(HPNum)%Name, &
'Condenser water flow rate [m3/s]', HPWaterHeater(HPNum)%OperatingWaterFlowRate)
END IF
IF(HPWaterHeater(HPNum)%AirFlowRateAutosized)THEN
CALL ReportSizingOutput(HPWaterHeater(HPNum)%Type, HPWaterHeater(HPNum)%Name, &
'Evaporator air flow rate [m3/s]', HPWaterHeater(HPNum)%OperatingAirFlowRate)
END IF
MyHPSizeFlag(HPNum) = .FALSE.
END IF
HPAirInletNode = HPWaterHeater(HPNum)%HeatPumpAirInletNode
HPAirOutletNode = HPWaterHeater(HPNum)%HeatPumpAirOutletNode
OutdoorAirNode = HPWaterHeater(HPNum)%OutsideAirNode
ExhaustAirNode = HPWaterHeater(HPNum)%ExhaustAirNode
HPWaterInletNode = HPWaterHeater(HPNum)%CondWaterInletNode
HPWaterOutletNode = HPWaterHeater(HPNum)%CondWaterOutletNode
InletAirMixerNode = HPWaterHeater(HPNum)%InletAirMixerNode
OutletAirSplitterNode = HPWaterHeater(HPNum)%OutletAirSplitterNode
SELECT CASE (HPWaterHeater(HPNum)%CrankcaseTempIndicator)
CASE (CrankcaseTempZone)
HPWHCrankcaseDBTemp = MAT(HPWaterHeater(HPNum)%AmbientTempZone)
CASE (CrankcaseTempExterior)
HPWHCrankcaseDBTemp = OutDryBulbTemp
CASE (CrankcaseTempSchedule)
HPWHCrankcaseDBTemp = GetCurrentScheduleValue(HPWaterHeater(HPNum)%CrankcaseTempSchedule)
END SELECT
! initialize HPWH report variables to 0 and set tank inlet node equal to outlet node
HPWaterHeater(HPNum)%HPWaterHeaterSensibleCapacity = 0.0d0
HPWaterHeater(HPNum)%HPWaterHeaterLatentCapacity = 0.0d0
WaterThermalTank(WaterThermalTankNum)%SourceMassFlowRate = 0.0d0
HPWaterHeater(HPNum)%HeatingPLR = 0.0d0
WaterThermalTank(WaterThermalTankNum)%SourceInletTemp = WaterThermalTank(WaterThermalTankNum)%SourceOutletTemp
! determine HPWH inlet air conditions based on inlet air configuration (Zone, ZoneAndOA, OutdoorAir, or Schedule)
SELECT CASE (HPWaterHeater(HPNum)%InletAirConfiguration)
CASE (AmbientTempZone)
MixerInletAirSchedule = 0.0d0
HPInletDryBulbTemp = Node(HPAirInletNode)%Temp
HPInletHumRat = Node(HPAirInletNode)%HumRat
CASE (AmbientTempZoneandOA)
IF(HPWaterHeater(HPNum)%InletAirMixerSchPtr .GT. 0)THEN
! schedule values are checked for boundary of 0 and 1 in GetWaterThermalTankInputFlag
MixerInletAirSchedule = GetCurrentScheduleValue(HPWaterHeater(HPNum)%InletAirMixerSchPtr)
ELSE
MixerInletAirSchedule = 0.0d0
END IF
HPInletDryBulbTemp = MixerInletAirSchedule * Node(OutdoorAirNode)%Temp + &
(1.0d0 - MixerInletAirSchedule) * Node(HPAirInletNode)%Temp
HPInletHumRat = MixerInletAirSchedule * Node(OutdoorAirNode)%Humrat + &
(1.0d0 - MixerInletAirSchedule) * Node(HPAirInletNode)%HumRat
CASE (AmbientTempOutsideAir)
MixerInletAirSchedule = 1.0d0
HPInletDryBulbTemp = Node(OutdoorAirNode)%Temp
HPInletHumRat = Node(OutdoorAirNode)%Humrat
CASE (AmbientTempSchedule)
HPInletDryBulbTemp = GetCurrentScheduleValue(HPWaterHeater(HPNum)%AmbientTempSchedule)
HPInletRelHum = GetCurrentScheduleValue(HPWaterHeater(HPNum)%AmbientRHSchedule)
HPInletHumRat = PsyWFnTdbRhPb(HPInletDryBulbTemp,HPInletRelHum,OutBaroPress, 'InitWaterThermalTank')
Node(HPAirInletNode)%Temp = HPInletDryBulbTemp
Node(HPAirInletNode)%HumRat = HPInletHumRat
Node(HPAirInletNode)%Enthalpy = PsyHFnTdbW(HPInletDryBulbTemp,HPInletHumRat)
Node(HPAirInletNode)%Press = OutBaroPress
END SELECT
MdotAir = HPWaterHeater(HPNum)%OperatingAirFlowRate * &
PsyRhoAirFnPbTdbW(OutBaroPress,HPInletDryBulbTemp, HPInletHumRat)
! set up initial conditions on nodes
IF(InletAirMixerNode .GT. 0) THEN
Node(InletAirMixerNode)%MassFlowRate = 0.0d0
Node(InletAirMixerNode)%MassFlowRateMax = MdotAir
Node(InletAirMixerNode)%MassFlowRateMaxAvail = MdotAir
Node(InletAirMixerNode)%Temp = HPInletDryBulbTemp
Node(InletAirMixerNode)%HumRat = HPInletHumRat
Node(InletAirMixerNode)%Enthalpy = PsyHFnTdbW(HPInletDryBulbTemp,HPInletHumRat)
Node(HPAirInletNode)%MassFlowRate = 0.0d0
Node(HPAirOutletNode)%MassFlowRate = 0.0d0
Node(OutdoorAirNode)%MassFlowRate = 0.0d0
Node(ExhaustAirNode)%MassFlowRate = 0.0d0
ELSE
IF(OutdoorAirNode .EQ. 0)THEN
Node(HPAirInletNode)%MassFlowRate = 0.0d0
Node(HPAirInletNode)%MassFlowRateMax = MdotAir
Node(HPAirInletNode)%MassFlowRateMaxAvail = MdotAir
Node(HPAirOutletNode)%MassFlowRate = 0.0d0
ELSE
Node(OutdoorAirNode)%MassFlowRate = 0.0d0
Node(OutdoorAirNode)%MassFlowRateMax = MdotAir
Node(OutdoorAirNode)%MassFlowRateMaxAvail = MdotAir
Node(ExhaustAirNode)%MassFlowRate = 0.0d0
END IF
END IF
IF(OutletAirSplitterNode .GT. 0)Node(OutletAirSplitterNode)%MassFlowRate = 0.0d0
!these are water nodes are not managed by plant. the HP connects
! directly to the WH without using plant. will not change this code for DSU because of this
Node(HPWaterInletNode)%MassFlowRate = 0.0d0
Node(HPWaterOutletNode)%MassFlowRate = 0.0d0
! set the max mass flow rate for outdoor fans
Node(HPWaterHeater(HPNum)%FanOutletNode)%MassFlowRateMax = MdotAir
! Curve objects in CalcHPWHDXCoil will use inlet conditions to HPWH not inlet air conditions to DX Coil
! HPWHInletDBTemp and HPWHInletWBTemp are DataHVACGlobals to pass info to HPWHDXCoil
HPWHInletDBTemp = HPInletDryBulbTemp
HPWHInletWBTemp = PsyTwbFnTdbWPb(HPWHInletDBTemp,HPInletHumRat,OutBaroPress)
END IF ! IF(WaterThermalTank(WaterThermalTankNum)%HeatPumpNum .GT. 0)THEN
RETURN
END SUBROUTINE InitWaterThermalTank