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) | :: | WaterThermalTankNum | |||
integer, | intent(in) | :: | InNodeNum | |||
logical, | intent(in) | :: | FirstHVACIteration | |||
integer, | intent(in) | :: | WaterThermalTankSide | |||
integer, | intent(in) | :: | PlantLoopSide | |||
logical, | intent(in) | :: | PlumbedInSeries | |||
integer, | intent(in) | :: | BranchControlType | |||
real(kind=r64), | intent(in) | :: | OutletTemp | |||
real(kind=r64), | intent(in) | :: | DeadBandTemp | |||
real(kind=r64), | intent(in) | :: | SetpointTemp |
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.
REAL(r64) FUNCTION PlantMassFlowRatesFunc(WaterThermalTankNum, InNodeNum, FirstHVACIteration, &
WaterThermalTankSide, &
PlantLoopSide, PlumbedInSeries, BranchControlType, &
OutletTemp, DeadBandTemp, SetpointTemp)
! FUNCTION INFORMATION:
! AUTHOR Brent Griffith
! DATE WRITTEN October 2007
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! collect routines for setting flow rates for Water heaters
! with plant connections.
! METHODOLOGY EMPLOYED:
! <description>
! REFERENCES:
! na
! USE STATEMENTS:
USE DataLoopNode, ONLY: Node
USE DataBranchAirLoopPlant
USE ScheduleManager, ONLY: GetCurrentScheduleValue
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: WaterThermalTankNum !
INTEGER, INTENT(IN) :: InNodeNum !
LOGICAL, INTENT(IN) :: FirstHVACIteration !
Integer, INTENT(IN) :: WaterThermalTankSide !
INTEGER, INTENT(IN) :: PlantLoopSide !
LOGICAL, INTENT(IN) :: PlumbedInSeries ! !unused1208
INTEGER, INTENT(IN) :: BranchControlType !
REAL(r64) , INTENT(IN) :: OutletTemp !
REAL(r64) , INTENT(IN) :: DeadBandTemp !
REAL(r64) , INTENT(IN) :: SetpointTemp !
! FUNCTION PARAMETER DEFINITIONS:
INTEGER, PARAMETER :: PassingFlowThru = 1
INTEGER, PARAMETER :: MaybeRequestingFlow = 2
INTEGER, PARAMETER :: ThrottlingFlow = 3
! FUNCTION BLOCK SPECIFICATIONS:
! na
! FUNCTION TYPE DEFINITIONS:
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
INTEGER :: CurrentMode
REAL(r64) :: MassFlowRequest
LOGICAL :: NeedsHeat
LOGICAL :: NeedsCool
REAL(r64) :: FlowResult
LOGICAL :: ScheduledAvail
REAL(r64) :: AltSetpointTemp
REAL(r64) :: AltDeadBandTemp
NeedsHeat = .FALSE. ! init
NeedsCool = .FALSE. ! init
! determine current mode. there are three possible
! 1. passing thru what was given to inlet node
! 2. potentially making a flow request
! 3. throttling flow in response to Plant's restrictions (MassFlowRateMaxAvail)
! init default mode to passing thru
CurrentMode=PassingFlowThru ! default
If (PlantLoopSide == DemandSupply_No) then
CurrentMode = PassingFlowThru
Else If (PlantLoopSide == SupplySide) then
! If FlowLock is False (0), the tank sets the plant loop mdot
! If FlowLock is True (1), the new resolved plant loop mdot is used
If (WaterThermalTank(WaterThermalTankNum)%UseCurrentFlowLock == 0) Then
CurrentMode = PassingFlowThru
IF ((WaterThermalTank(WaterThermalTankNum)%UseSideLoadRequested > 0.0D0) &
.AND. (WaterThermalTankSide == UseSide) ) THEN
CurrentMode = MaybeRequestingFlow
ENDIF
ELSE
CurrentMode = PassingFlowThru
ENDIF
IF (WaterThermalTankSide == SourceSide) THEN
CurrentMode = MaybeRequestingFlow
ENDIF
ELSE IF (PlantLoopSide == DemandSide) then
! 1. pass thru is default
CurrentMode = PassingFlowThru
! 2. Might be Requesting Flow.
IF (FirstHVACIteration) THEN
IF (BranchControlType == ControlType_Bypass) THEN
CurrentMode = PassingFlowThru
ELSE
! IF (.not. PlumbedInSeries) THEN
CurrentMode = MaybeRequestingFlow
! ELSE
! CurrentMode = PassingFlowThru
! ENDIF
ENDIF
! ENDIF
ELSE !(.not. FirstHVACIteration)
IF (BranchControlType == ControlType_Bypass) THEN
CurrentMode = PassingFlowThru
ELSE
! 3. ThrottlingFlow
! IF (.not. PlumbedInSeries) THEN
CurrentMode = ThrottlingFlow
! ELSE
! CurrentMode = PassingFlowThru
! ENDIF
ENDIF
ENDIF
ENDIF
! evaluate Availability schedule,
ScheduledAvail = .TRUE.
IF (WaterThermalTankSide == UseSide) THEN
! IF (WaterThermalTank(WaterThermalTankNum)%UseSideAvailSchedNum > 0) Then
IF (GetCurrentScheduleValue(WaterThermalTank(WaterThermalTankNum)%UseSideAvailSchedNum) == 0.0D0) Then
ScheduledAvail = .FALSE.
ENDIF
! ENDIF
ELSE IF (WaterThermalTankSide == SourceSide) THEN
! IF (WaterThermalTank(WaterThermalTankNum)%SourceSideAvailSchedNum > 0) Then
IF (GetCurrentScheduleValue(WaterThermalTank(WaterThermalTankNum)%SourceSideAvailSchedNum) == 0.0D0) Then
ScheduledAvail = .FALSE.
ENDIF
! ENDIF
END IF
! now act based on current mode
SELECT CASE (currentMode)
CASE (PassingFlowThru)
IF (.NOT. ScheduledAvail ) Then
FlowResult = 0.0D0
ELSE
FlowResult = Node(InNodeNum)%MassFlowRate
ENDIF
CASE (ThrottlingFlow)
! first determine what mass flow would be if it is to requested
IF (.NOT. ScheduledAvail ) Then
MassFlowRequest = 0.0D0
ELSE
IF (WaterThermalTankSide == UseSide) THEN
MassFlowRequest = WaterThermalTank(WaterThermalTankNum)%PlantUseMassFlowRateMax
ELSE IF (WaterThermalTankSide == SourceSide) THEN
MassFlowRequest = WaterThermalTank(WaterThermalTankNum)%PlantSourceMassFlowRateMax
END IF
ENDIF
! next determine if tank temperature is such that source side flow might be requested
IF (.NOT. WaterThermalTank(WaterThermalTankNum)%IsChilledWaterTank) THEN
IF (OutletTemp < DeadBandTemp) THEN
NeedsHeat = .TRUE.
ELSE IF ((OutletTemp >= DeadBandTemp) .and. (OutletTemp < SetpointTemp)) THEN
! inside the deadband, use saved mode from water heater calcs
IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == HeatMode) THEN
NeedsHeat = .TRUE.
ELSE IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == FloatMode) THEN
NeedsHeat = .FALSE.
ENDIF
ELSE IF (OutletTemp >= SetpointTemp) THEN
NeedsHeat = .FALSE.
ENDIF
ELSE ! is a chilled water tank so flip logic
IF (OutletTemp > DeadBandTemp) THEN
NeedsCool = .TRUE.
ELSE IF ((OutletTemp <= DeadBandTemp) .and. (OutletTemp > SetpointTemp)) THEN
! inside the deadband, use saved mode from water thermal tank calcs (modes only for mixed)
IF (WaterThermalTank(WaterThermalTankNum)%TypeNum == MixedChilledWaterStorage) THEN
IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == CoolMode) THEN
NeedsCool = .TRUE.
ELSE IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == FloatMode) THEN
NeedsCool = .FALSE.
ENDIF
ELSEIF (WaterThermalTank(WaterThermalTankNum)%TypeNum == StratifiedChilledWaterStorage) THEN
NeedsCool = .TRUE.
ENDIF
ELSE IF (OutletTemp <= SetpointTemp) THEN
NeedsCool = .FALSE.
ENDIF
ENDIF
IF (MassFlowRequest > 0.0D0) THEN
IF (WaterThermalTankSide == UseSide) THEN
FlowResult = MassFlowRequest
ELSE IF (WaterThermalTankSide == SourceSide) THEN
IF (NeedsHeat .or. NeedsCool) THEN
FlowResult = MassFlowRequest
ELSE
FlowResult = 0.0D0
ENDIF
END IF
ELSE
FlowResult = 0.0D0
ENDIF
! now throttle against MassFlowRateMaxAvail, MassFlowRateMinAvail, MassFlowRateMax, and MassFlowRateMin
! see notes about reverse dd compliance (specifically 5ZoneWaterSystems file)
FlowResult = MAX(Node(InNodeNum)%MassFlowRateMinAvail, FlowResult) ! okay for compliance (reverse dd)
FlowResult = MAX(Node(InNodeNum)%MassFlowRateMin, FlowResult) ! okay for compliance (reverse dd)
FlowResult = MIN(Node(InNodeNum)%MassFlowRateMaxAvail, FlowResult)
!=> following might take out of reverse dd compliance
FlowResult = MIN(Node(InNodeNum)%MassFlowRateMax, FlowResult)
!DSU> use SetComponentFlowRate for above?
CASE (MaybeRequestingFlow)
! first determine what mass flow would be if it is to requested
IF (.NOT. ScheduledAvail ) Then
MassFlowRequest = 0.0D0
ELSE
IF (WaterThermalTankSide == UseSide) THEN
IF ((WaterThermalTank(WaterThermalTankNum)%IsChilledWaterTank) &
.AND. (WaterThermalTank(WaterThermalTankNum)%UseSideLoadRequested > 0.0D0)) THEN
MassFlowRequest = WaterThermalTank(WaterThermalTankNum)%PlantUseMassFlowRateMax
ELSEIF ((WaterThermalTank(WaterThermalTankNum)%IsChilledWaterTank) &
.AND. (WaterThermalTank(WaterThermalTankNum)%UseSideLoadRequested == 0.0D0)) THEN
MassFlowRequest = 0.0D0
ELSE
MassFlowRequest = WaterThermalTank(WaterThermalTankNum)%PlantUseMassFlowRateMax
ENDIF
ELSE IF (WaterThermalTankSide == SourceSide) THEN
MassFlowRequest = WaterThermalTank(WaterThermalTankNum)%PlantSourceMassFlowRateMax
END IF
ENDIF
IF (WaterThermalTankSide == SourceSide) THEN ! temperature dependent controls for indirect heating/cooling
IF (.NOT. WaterThermalTank(WaterThermalTankNum)%IsChilledWaterTank) THEN
! next determine if tank temperature is such that flow is requested depending on mode
IF (WaterThermalTank(WaterThermalTankNum)%SourceSideControlMode == SourceSideIndirectHeatPrimarySetpoint) THEN
IF (OutletTemp < DeadBandTemp) THEN
NeedsHeat = .TRUE.
ELSE IF ((OutletTemp >= DeadBandTemp) .and. (OutletTemp < SetpointTemp)) THEN
! inside the deadband, use saved mode from water heater calcs
IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == HeatMode) THEN
NeedsHeat = .TRUE.
ELSE IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == FloatMode) THEN
NeedsHeat = .FALSE.
ENDIF
ELSE IF (OutletTemp >= SetpointTemp) THEN
NeedsHeat = .FALSE.
ENDIF
ELSEIF (WaterThermalTank(WaterThermalTankNum)%SourceSideControlMode == SourceSideIndirectHeatAltSetpoint) THEN
! get alternate setpoint
AltSetpointTemp = GetCurrentScheduleValue(WaterThermalTank(WaterThermalTankNum)%SourceSideAltSetpointSchedNum)
AltDeadBandTemp = AltSetpointTemp - WaterThermalTank(WaterThermalTankNum)%DeadbandDeltaTemp
IF (OutletTemp < AltDeadBandTemp) THEN
NeedsHeat = .TRUE.
ELSE IF ((OutletTemp >= AltDeadBandTemp) .and. (OutletTemp < AltSetpointTemp)) THEN
! inside the deadband, use saved mode from water heater calcs
IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == HeatMode) THEN
NeedsHeat = .TRUE.
ELSE IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == FloatMode) THEN
NeedsHeat = .FALSE.
ENDIF
ELSE IF (OutletTemp >= AltSetpointTemp) THEN
NeedsHeat = .FALSE.
ENDIF
ELSEIF (WaterThermalTank(WaterThermalTankNum)%SourceSideControlMode == SourceSideStorageTank) THEN
IF (OutletTemp < WaterThermalTank(WaterThermalTankNum)%TankTempLimit) THEN
NeedsHeat = .TRUE.
ELSE
NeedsHeat = .FALSE.
ENDIF
ENDIF
ELSE ! is a chilled water tank so flip logic
IF (OutletTemp > DeadBandTemp) THEN
NeedsCool = .TRUE.
ELSE IF ((OutletTemp <= DeadBandTemp) .and. (OutletTemp > SetpointTemp)) THEN
! inside the deadband, use saved mode from water thermal tank calcs (modes only for mixed)
IF (WaterThermalTank(WaterThermalTankNum)%TypeNum == MixedChilledWaterStorage) THEN
IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == CoolMode) THEN
NeedsCool = .TRUE.
ELSE IF (WaterThermalTank(WaterThermalTankNum)%SavedMode == FloatMode) THEN
NeedsCool = .FALSE.
ENDIF
ELSEIF (WaterThermalTank(WaterThermalTankNum)%TypeNum == StratifiedChilledWaterStorage) THEN
NeedsCool = .TRUE.
ENDIF
ELSE IF (OutletTemp >= SetpointTemp) THEN
NeedsCool = .FALSE.
ENDIF
ENDIF ! chilled water
IF (MassFlowRequest > 0.0D0) THEN
IF (NeedsHeat .OR. NeedsCool) THEN
FlowResult = MassFlowRequest
ELSE
FlowResult = 0.0D0
ENDIF
ELSE
FlowResult = 0.0D0
ENDIF
Else ! end source side, begin use side
IF (MassFlowRequest > 0.0D0) THEN
FlowResult = MassFlowRequest
ELSE
FlowResult = 0.0D0
ENDIF
ENDIF
! IF (FirstHVACIteration) Then
! Node(InNodeNum)%MassFlowRateMaxAvail = FlowResult
! Node(InNodeNum)%MassFlowRateMinAvail = 0.0D0
! ENDIF
END SELECT
PlantMassFlowRatesFunc = FlowResult
RETURN
END FUNCTION PlantMassFlowRatesFunc