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) | :: | IceStorageType | |||
integer | :: | IceNum | ||||
real(kind=r64) | :: | MyLoad | ||||
logical, | intent(in) | :: | RunFlag | |||
logical | :: | FirstIteration | ||||
real(kind=r64), | intent(in) | :: | MaxCap |
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 CalcIceStorageDischarge(IceStorageType,IceNum,MyLoad,Runflag,FirstIteration,MaxCap)
! SUBROUTINE INFORMATION:
! PURPOSE OF THIS SUBROUTINE:
! METHODOLOGY EMPLOYED:
! REFERENCES:
! USE STATEMENTS:
USE DataGlobals, ONLY: HourOfDay,TimeStep,NumOfTimeStepInHour
USE DataInterfaces, ONLY: ShowFatalError
USE DataHVACGlobals, ONLY : TimeStepSys
USE DataPlant, ONLY: PlantLoop, SingleSetpoint, DualSetpointDeadband
USE FluidProperties, ONLY: GetDensityGlycol
USE PlantUtilities, ONLY: SetComponentFlowRate
IMPLICIT NONE
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER,INTENT(IN) :: IceStorageType !by ZG
INTEGER :: IceNum ! ice storage number
REAL(r64) :: MyLoad ! operating load
LOGICAL :: FirstIteration ! TRUE when first iteration of timestep
LOGICAL, INTENT(IN) :: RunFlag ! TRUE when ice storage operating
REAL(r64), INTENT(IN) :: MaxCap ! Max possible discharge rate (positive value)
! SUBROUTINE PARAMETER DEFINITIONS:
REAL(r64), PARAMETER :: TempTol = 0.0001d0 ! C - minimum significant mass flow rate
! INTERFACE BLOCK SPECIFICATIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
! FLOW
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
! External function
! Local
REAL(r64) :: Umax =0.0d0 ! Max Urate adjusted Urate based on Error protection (I) [fraction]
REAL(r64) :: Umin =0.0d0 ! Min Urate adjusted Urate based on Error protection (I) [fraction]
REAL(r64) :: Uact =0.0d0 ! Acting between Usys and UsysLow Urate adjusted Urate based on Error protection (I) [fraction]
REAL(r64) :: Umyload =0.0d0
! unused REAL(r64) :: QiceMin
REAL(r64) :: Qice =0.0d0
REAL(r64) :: DeltaTemp =0.0d0
INTEGER :: LoopNum
INTEGER :: LoopSideNum
REAL(r64) :: CpFluid ! local temporary for plant loop's fluid specific heat
! FLOW
SELECT CASE (IceStorageType)
CASE(IceStorageType_Simple)
! Initialize processed Rate and Energy
ITSMassFlowRate = 0.0d0
ITSCoolingRate = 0.0d0
ITSCoolingEnergy = 0.0d0
SELECT CASE (PlantLoop(IceStorage(IceNum)%LoopNum)%LoopDemandCalcScheme)
CASE (SingleSetPoint)
ITSOutletSetPointTemp = Node(OutletNodeNum)%TempSetPoint
CASE (DualSetPointDeadBand)
ITSOutletSetPointTemp = Node(OutletNodeNum)%TempSetPointHi
END SELECT
! Initialize processed U values
Umax = 0.0d0
Umin = 0.0d0
Uact = 0.0d0
Umyload = 0.0d0
Urate = 0.0d0
! If no component demand or ITS OFF, then RETURN.
IF( MyLoad == 0 .OR. .NOT.RunFlag ) THEN
ITSMassFlowRate = 0.0d0
ITSInletTemp = Node(InletNodeNum)%Temp
ITSOutletTemp = ITSInletTemp
ITSCoolingRate = 0.0d0
ITSCoolingEnergy = 0.0d0
RETURN
END IF
! If FlowLock(provided by PlantSupplyManager) is False(=0), that is, MyLoad is not changed.
! then based on MyLoad, new ITSMassFlowRate will be calculated.
!----------------------------
LoopNum = IceStorage(IceNum)%LoopNum
LoopSideNum = IceStorage(IceNum)%LoopSideNum
CpFluid = GetDensityGlycol(PlantLoop(LoopNum)%FluidName, &
Node(InletNodeNum)%Temp, &
PlantLoop(LoopNum)%FluidIndex, &
'CalcIceStorageDischarge')
! Calculate Umyload based on MyLoad from E+
Umyload = -MyLoad*TimeInterval/ITSNomCap
! Calculate Umax and Umin
! Cannot discharge more than the fraction that is left
Umax = -IceStorageReport(IceNum)%IceFracRemain/TimeStepSys
! Calculate Umin based on returned Myload from E+.
Umin = MIN( Umyload, 0.0d0 )
! Based on Umax and Umin, if necessary to run E+, calculate proper Uact
! U is negative here.
Uact = MAX(Umin,Umax)
! Set ITSInletTemp provided by E+
ITSInletTemp = Node(InletNodeNum)%Temp
!The first thing is to set the ITSMassFlowRate
ITSMassFlowRate = IceStorage(IceNum)%DesignMassFlowRate ![kg/s]
CALL SetComponentFlowRate(ITSMassFlowRate, &
IceStorage(IceNum)%PltInletNodeNum, &
IceStorage(IceNum)%PltOutletNodeNum, &
IceStorage(IceNum)%LoopNum, &
IceStorage(IceNum)%LoopSideNum, &
IceStorage(IceNum)%BranchNum, &
IceStorage(IceNum)%CompNum )
! Qice is calculate input U which is within boundary between Umin and Umax.
Qice = Uact*ITSNomCap/TimeInterval
! Qice cannot exceed MaxCap calulated by CalcIceStorageCapacity
! Note Qice is negative here, MaxCap is positive
Qice = MAX(Qice, -MaxCap)
! Calculate leaving water temperature
IF((Qice .GE. 0.0d0) .OR. (XCurIceFrac .LE. 0.0d0)) THEN
ITSOutletTemp = ITSInletTemp
DeltaTemp = 0.0d0
Qice = 0.0d0
Uact = 0.0d0
ELSE
DeltaTemp = Qice/CpFluid/ITSMassFlowRate
ITSOutletTemp = ITSInletTemp + DeltaTemp
! Limit leaving temp to be no less than setpoint or freezing temp plus 1C
ITSOutletTemp = MAX(ITSOutletTemp, ITSOutletSetPointTemp, (FreezTemp+1))
! Limit leaving temp to be no greater than inlet temp
ITSOutletTemp = MIN(ITSOutletTemp, ITSInletTemp)
DeltaTemp = ITSOutletTemp - ITSInletTemp
Qice = DeltaTemp*CpFluid*ITSMassFlowRate
Uact = Qice/(ITSNomCap/TimeInterval)
END IF ! End of leaving temp checks
! Calculate reported U value
Urate = Uact
! Calculate ITSCoolingEnergy [J]
ITSCoolingRate = -Qice
ITSCoolingEnergy = ITSCoolingRate*TimeStepSys*SecInHour
CASE DEFAULT
END SELECT
RETURN
END SUBROUTINE CalcIceStorageDischarge