Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | CompType | |||
character(len=*), | intent(in) | :: | CompName | |||
integer, | intent(inout) | :: | CompIndex | |||
logical, | intent(in) | :: | RunFlag | |||
logical, | intent(in) | :: | InitLoopEquip | |||
real(kind=r64), | intent(inout) | :: | MyLoad | |||
real(kind=r64), | intent(inout) | :: | MaxCap | |||
real(kind=r64), | intent(inout) | :: | MinCap | |||
real(kind=r64), | intent(inout) | :: | OptCap | |||
logical, | intent(in) | :: | FirstHVACIteration | |||
integer, | intent(in), | optional | :: | LoopNum | ||
integer, | intent(in), | optional | :: | LoopSideNum |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
SUBROUTINE SimWaterThermalTank(CompType,CompName,CompIndex,RunFlag,InitLoopEquip, & !DSU
MyLoad,MaxCap,MinCap,OptCap,FirstHVACIteration, LoopNum, LoopSideNum)
! SUBROUTINE INFORMATION:
! AUTHOR Brandon Anderson
! DATE WRITTEN May 2000
! MODIFIED FSEC, July 2005
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! The main subroutine for simulating a water heater, heat pump water heater, or desuperheater
! heating coil. This routine will:
!
! 1. Gets Input if necessary
! 2. Determines the load the water heater (or heat pump water heater) must support
! 3. Determine the type of water heater, heat pump water heater, or desuperheater
! heating coil to be simulated
! 4. Calls simulation routines
! METHODOLOGY EMPLOYED:
! Standard EnergyPlus methodology. Subroutine is called from PlantLoopEquipments
! USE STATEMENTS:
USE DataGlobals, ONLY: BeginEnvrnFlag, KickOffSimulation
USE InputProcessor, ONLY: FindItem,MakeUPPERCase
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: CompType
CHARACTER(len=*), INTENT(IN) :: CompName
INTEGER, INTENT(INOUT) :: CompIndex
LOGICAL, INTENT(IN) :: RunFlag !unused1208
LOGICAL, INTENT(IN) :: InitLoopEquip
REAL(r64), INTENT(INOUT) :: MyLoad
REAL(r64), INTENT(INOUT) :: MinCap
REAL(r64), INTENT(INOUT) :: MaxCap
REAL(r64), INTENT(INOUT) :: OptCap
LOGICAL, INTENT(IN) :: FirstHVACIteration ! TRUE if First iteration of simulation
INTEGER, INTENT(IN) , Optional :: LoopNum
INTEGER, INTENT(IN) , Optional :: LoopSideNum
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
Logical, save :: OneTimeSetupFlag = .true.
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyOneTimeFlagWH ! first pass log
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyTwoTimeFlagWH ! second pass do input check
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyOneTimeFlagHP ! first pass log
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyTwoTimeFlagHP ! second pass do input check
INTEGER :: tmpLoopNum
INTEGER :: tmpLoopSideNum
INTEGER :: CompNum
INTEGER :: TankNum
! FLOW:
IF (GetWaterThermalTankInputFlag) THEN
CALL GetWaterThermalTankInput
GetWaterThermalTankInputFlag = .FALSE.
END IF
If (OneTimeSetupFlag) THEN
ALLOCATE (MyOneTimeFlagWH ( NumWaterThermalTank ))
ALLOCATE (MyTwoTimeFlagWH ( NumWaterThermalTank ))
ALLOCATE (MyOneTimeFlagHP (NumHeatPumpWaterHeater ))
ALLOCATE (MyTwoTimeFlagHP (NumHeatPumpWaterHeater ))
MyOneTimeFlagWH = .TRUE.
MyTwoTimeFlagWH = .TRUE.
MyOneTimeFlagHP = .TRUE.
MyTwoTimeFlagHP = .TRUE.
OneTimeSetupFlag = .FALSE.
END IF
! Find the correct Equipment
IF (CompType /= TypeOf_HeatPumpWtrHeater) THEN
IF (CompIndex == 0) THEN
CompNum = FindItem(CompName,WaterThermalTank%Name,NumWaterThermalTank)
IF (CompNum == 0) THEN
CALL ShowFatalError('SimWaterThermalTank: Unit not found='//TRIM(CompName))
ENDIF
CompIndex=CompNum
ELSE
CompNum=CompIndex
IF (CompNum > NumWaterThermalTank .or. CompNum < 1) THEN
CALL ShowFatalError('SimWaterThermalTank: Invalid CompIndex passed='// &
TRIM(TrimSigDigits(CompNum))// &
', Number of Units='//TRIM(TrimSigDigits(NumWaterThermalTank))// &
', Entered Unit name='//TRIM(CompName))
ENDIF
IF (CheckWTTEquipName(CompNum)) THEN
IF (CompName /= WaterThermalTank(CompNum)%Name) THEN
CALL ShowFatalError('SimWaterThermalTank: Invalid CompIndex passed='// &
TRIM(TrimSigDigits(CompNum))// &
', Unit name='//TRIM(CompName)//', stored Unit Name for that index='// &
TRIM(WaterThermalTank(CompNum)%Name))
ENDIF
CheckWTTEquipName(CompNum)=.false.
ENDIF
ENDIF
ELSE
IF (CompIndex == 0) THEN
CompNum = FindItem(CompName,HPWaterHeater%Name,NumHeatPumpWaterHeater)
IF (CompNum == 0) THEN
CALL ShowFatalError('SimWaterThermalTank: Unit not found='//TRIM(CompName))
ENDIF
CompIndex=CompNum
ELSE
CompNum=CompIndex
IF (CompNum > NumWaterThermalTank .or. CompNum < 1) THEN
CALL ShowFatalError('SimWaterThermalTank: Invalid CompIndex passed='// &
TRIM(TrimSigDigits(CompNum))// &
', Number of Units='//TRIM(TrimSigDigits(NumHeatPumpWaterHeater))// &
', Entered Unit name='//TRIM(CompName))
ENDIF
IF (CheckHPWHEquipName(CompNum)) THEN
IF (CompName /= HPWaterHeater(CompNum)%Name) THEN
CALL ShowFatalError('SimWaterThermalTank: Invalid CompIndex passed='// &
TRIM(TrimSigDigits(CompNum))// &
', Unit name='//TRIM(CompName)//', stored Unit Name for that index='// &
TRIM(HPWaterHeater(CompNum)%Name))
ENDIF
CheckHPWHEquipName(CompNum)=.false.
ENDIF
ENDIF
ENDIF
! this case statement needs integerization.
SELECT CASE (CompType)
! string comparisons to remove here.
! ========================= Water Heater and Chilled Water Storage
CASE (TypeOf_WtrHeaterMixed, TypeOf_WtrHeaterStratified, &
TypeOf_ChilledWaterTankMixed, TypeOf_ChilledWaterTankStratified)
IF (InitLoopEquip) THEN
IF (PRESENT(LoopNum)) THEN
CALL InitWaterThermalTank(CompNum, FirstHVACIteration, LoopNum, LoopSideNum)
ELSE
CALL InitWaterThermalTank(CompNum, FirstHVACIteration)
ENDIF
Call MinePlantStructForInfo(CompNum)
IF (PRESENT(LoopNum)) THEN
IF (((WaterThermalTank(CompNum)%SourceSidePlantLoopNum == LoopNum) &
.AND. (WaterThermalTank(CompNum)%SourceSidePlantLoopSide == LoopSideNum)) &
.OR. ((WaterThermalTank(CompNum)%UseSidePlantLoopNum == LoopNum) &
.AND. (WaterThermalTank(CompNum)%UseSidePlantLoopSide == LoopSideNum))) THEN
CALL SizeTankForDemandSide(CompNum)
CALL SizeDemandSidePlantConnections(CompNum)
CALL SizeSupplySidePlantConnections(CompNum, LoopNum, LoopSideNum)
CALL SizeTankForSupplySide(CompNum)
ELSE
RETURN
ENDIF
ELSE
CALL SizeTankForDemandSide(CompNum)
CALL SizeDemandSidePlantConnections(CompNum)
CALL SizeSupplySidePlantConnections(CompNum)
CALL SizeTankForSupplySide(CompNum)
ENDIF
! Calculate and report water heater standard ratings to EIO file (now that sizing is done)
IF (PlantSizesOkayToFinalize) THEN
IF (.NOT. WaterThermalTank(CompNum)%IsChilledWaterTank) Then
CALL CalcStandardRatings(CompNum)
ELSE
CALL ReportCWTankInits(CompNum)
ENDIF
ENDIF
MinCap = 0.0d0
MaxCap = WaterThermalTank(CompNum)%MaxCapacity
OptCap = WaterThermalTank(CompNum)%MaxCapacity
IF (PRESENT(LoopNum)) THEN
CALL InitWaterThermalTank(CompNum, FirstHVACIteration, LoopNum, LoopSideNum)
ELSE
CALL InitWaterThermalTank(CompNum, FirstHVACIteration)
ENDIF
RETURN
END IF
If (MyOneTimeFlagWH(CompNum)) THen
MyOneTimeFlagWH(CompNum) =.false.
ELSE
If (MyTwoTimeFlagWH(CompNum)) THEN
Call MinePlantStructForInfo(CompNum) ! call it again to get control types filled out
MyTwoTimeFlagWH(CompNum) = .FALSE.
ENDIF
ENDIF
WaterThermalTank(CompNum)%UseSideLoadRequested = ABS(MyLoad)
tmpLoopNum = WaterThermalTank(CompNum)%UseSidePlantLoopNum
tmpLoopSideNum = WaterThermalTank(CompNum)%UseSidePlantLoopSide
IF (tmpLoopNum > 0 .AND. tmpLoopSideNum > 0 .and. .not. KickOffSimulation) THEN
WaterThermalTank(CompNum)%UseCurrentFlowLock = &
PlantLoop(tmpLoopNum)%Loopside(LoopSideNum)%FlowLock
ELSE
WaterThermalTank(CompNum)%UseCurrentFlowLock = 1
ENDIF
tmpLoopNum = WaterThermalTank(CompNum)%SourceSidePlantLoopNum
tmpLoopSideNum = WaterThermalTank(CompNum)%SourceSidePlantLoopSide
IF (tmpLoopNum > 0 .AND. tmpLoopSideNum > 0 .and. .not. KickOffSimulation) THEN
WaterThermalTank(CompNum)%SourceCurrentFlowLock = &
PlantLoop(tmpLoopNum)%Loopside(LoopSideNum)%FlowLock
ELSE
WaterThermalTank(CompNum)%SourceCurrentFlowLock = 1
ENDIF
CALL InitWaterThermalTank(CompNum, FirstHVACIteration)
! Plant connected water heaters may have a desuperheater heating coil attached
IF(WaterThermalTank(CompNum)%DesuperheaterNum .EQ. 0)THEN
IF ((WaterThermalTank(CompNum)%TypeNum == MixedWaterHeater) &
.OR. (WaterThermalTank(CompNum)%TypeNum == MixedChilledWaterStorage)) THEN
CALL CalcWaterThermalTankMixed(CompNum)
ELSE IF ( ( WaterThermalTank(CompNum)%TypeNum == StratifiedWaterHeater) &
.OR. ( WaterThermalTank(CompNum)%TypeNum == StratifiedChilledWaterStorage )) THEN
CALL CalcWaterThermalTankStratified(CompNum)
END IF
ELSEIF(WaterThermalTank(CompNum)%DesuperheaterNum .GT. 0)THEN
CALL CalcDesuperheaterWaterHeater(CompNum, FirstHVACIteration)
END IF
CALL UpdateWaterThermalTank(CompNum)
CALL ReportWaterThermalTank(CompNum)
! ========================= Heat Pump Water Heater
CASE (TypeOf_HeatPumpWtrHeater)
IF (InitLoopEquip) THEN
! CompNum is index to heatpump model, not tank so get the tank index
TankNum = HPWaterHeater(CompNum)%WaterHeaterTankNum
IF (PRESENT(LoopNum)) THEN
CALL InitWaterThermalTank(TankNum, FirstHVACIteration, LoopNum, LoopSideNum)
ELSE
CALL InitWaterThermalTank(TankNum, FirstHVACIteration)
ENDIF
Call MinePlantStructForInfo(TankNum)
IF (PRESENT(LoopNum)) THEN
IF (((WaterThermalTank(TankNum)%SourceSidePlantLoopNum == LoopNum) &
.AND. (WaterThermalTank(TankNum)%SourceSidePlantLoopSide == LoopSideNum)) &
.OR. ((WaterThermalTank(TankNum)%UseSidePlantLoopNum == LoopNum) &
.AND. (WaterThermalTank(TankNum)%UseSidePlantLoopSide == LoopSideNum))) THEN
CALL SizeTankForDemandSide(CompNum)
CALL SizeDemandSidePlantConnections(CompNum)
CALL SizeSupplySidePlantConnections(TankNum, LoopNum, LoopSideNum)
CALL SizeTankForSupplySide(TankNum)
ELSE
RETURN
ENDIF
ELSE
CALL SizeTankForDemandSide(CompNum)
CALL SizeDemandSidePlantConnections(CompNum)
CALL SizeSupplySidePlantConnections(TankNum)
CALL SizeTankForSupplySide(TankNum)
ENDIF
IF (PlantSizesOkayToFinalize) THEN
CALL CalcStandardRatings(TankNum)
ENDIF
MinCap = 0.0d0
MaxCap = HPWaterHeater(CompNum)%Capacity
OptCap = HPWaterHeater(CompNum)%Capacity
RETURN
END IF
If (MyOneTimeFlagHP(CompNum)) THen
MyOneTimeFlagHP(CompNum) =.false.
ELSE
If (MyTwoTimeFlagHP(CompNum)) THEN
Call MinePlantStructForInfo(HPWaterHeater(CompNum)%WaterHeaterTankNum) ! call it again to get control types filled out
MyTwoTimeFlagHP(CompNum) = .FALSE.
ENDIF
ENDIF
WaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum)%UseSideLoadRequested = ABS(MyLoad)
tmpLoopNum = WaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum)%UseSidePlantLoopNum
tmpLoopSideNum = WaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum)%UseSidePlantLoopSide
IF (tmpLoopNum > 0 .AND. tmpLoopSideNum > 0 .and. .not. KickOffSimulation) THEN
WaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum)%UseCurrentFlowLock = &
PlantLoop(tmpLoopNum)%Loopside(LoopSideNum)%FlowLock
ELSE
WaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum)%UseCurrentFlowLock = 1
ENDIF
IF (PRESENT(LoopNum)) THEN
CALL InitWaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum, FirstHVACIteration, LoopNum, LoopSideNum)
ELSE
CALL InitWaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum, FirstHVACIteration)
ENDIF
CALL CalcHeatPumpWaterHeater(HPWaterHeater(CompNum)%WaterHeaterTankNum, FirstHVACIteration)
CALL UpdateWaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum)
CALL ReportWaterThermalTank(HPWaterHeater(CompNum)%WaterHeaterTankNum)
CASE DEFAULT
CALL ShowSevereError('SimWaterThermalTank: Invalid Water Thermal Tank Equipment Type='//TRIM(TrimSigDigits(CompType)))
CALL ShowContinueError('Occurs in Water Thermal Tank Equipment named = '//TRIM(CompName))
CALL ShowFatalError('Preceding condition causes termination.')
END SELECT
RETURN
END SUBROUTINE SimWaterThermalTank