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 UpdateThermalHistories
! SUBROUTINE INFORMATION:
! AUTHOR Russ Taylor
! DATE WRITTEN June 1990
! MODIFIED na
! RE-ENGINEERED Mar98 (RKS)
! PURPOSE OF THIS SUBROUTINE:
! This subroutine updates and shifts the thermal and flux histories.
! METHODOLOGY EMPLOYED:
! If a surface runs on the user selected subhourly time step, then the
! history terms for the temperatures and fluxes must simply be updated
! and shifted. However, if the surface runs at a different (longer) time
! step, then the "master" history series is used for the interpolated
! update scheme.
! REFERENCES:
! (I)BLAST legacy routine UTHRMH
! Taylor et.al., Impact of Simultaneous Simulation of Buildings and
! Mechanical Systems in Heat Balance Based Energy Analysis Programs
! on System Response and Control, Building Simulation '91, IBPSA, Nice, France.
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: ConstrNum ! Construction index for the current surface
INTEGER :: HistTermNum ! DO loop counter for history terms
INTEGER :: SideNum ! DO loop counter for surfaces sides (inside, outside)
INTEGER :: SurfNum ! Surface number DO loop counter
INTEGER :: ZoneNum ! Zone number DO loop counter
REAL(r64), SAVE, ALLOCATABLE, DIMENSION(:) :: QExt1 ! Heat flux at the exterior surface during first time step/series
REAL(r64), SAVE, ALLOCATABLE, DIMENSION(:) :: QInt1 ! Heat flux at the interior surface during first time step/series
REAL(r64), SAVE, ALLOCATABLE, DIMENSION(:) :: TempInt1 ! Temperature of interior surface during first time step/series
REAL(r64), SAVE, ALLOCATABLE, DIMENSION(:) :: TempExt1 ! Temperature of exterior surface during first time step/series
REAL(r64), SAVE, ALLOCATABLE, DIMENSION(:) :: Qsrc1 ! Heat source/sink (during first time step/series)
REAL(r64), SAVE, ALLOCATABLE, DIMENSION(:) :: Tsrc1 ! Temperature at source/sink (during first time step/series)
REAL(r64), SAVE, ALLOCATABLE, DIMENSION(:) :: SumTime ! Amount of time that has elapsed from start of master history to
! the current time step
LOGICAL, SAVE :: FirstTimeFlag=.true.
! FLOW:
IF (FirstTimeFlag) THEN
ALLOCATE(QExt1(TotSurfaces))
QExt1 = 0.0D0
ALLOCATE(QInt1(TotSurfaces))
QInt1 = 0.0D0
ALLOCATE(TempInt1(TotSurfaces))
TempInt1 = 0.0D0
ALLOCATE(TempExt1(TotSurfaces))
TempExt1 = 0.0D0
ALLOCATE(SumTime(TotSurfaces))
SumTime = 0.0D0
ALLOCATE(Qsrc1(TotSurfaces))
Qsrc1 = 0.0D0
ALLOCATE(Tsrc1(TotSurfaces))
Tsrc1 = 0.0D0
FirstTimeFlag=.false.
END IF
DO SurfNum = 1, TotSurfaces ! Loop through all (heat transfer) surfaces...
IF (Surface(SurfNum)%Class == SurfaceClass_Window .or. .NOT.Surface(SurfNum)%HeatTransSurf) CYCLE
IF ((Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_CTF) .AND. &
(Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_EMPD) ) CYCLE
ConstrNum = Surface(SurfNum)%Construction
IF (Construct(ConstrNum)%NumCTFTerms == 0) CYCLE ! Skip surfaces with no history terms
! Sign convention for the various terms in the following two equations
! is based on the form of the Conduction Transfer Function equation
! given by:
! Qin,now = (Sum of)(Y Tout) - (Sum of)(Z Tin) + (Sum of)(F Qin,old) + (Sum of)(V Qsrc)
! Qout,now = (Sum of)(X Tout) - (Sum of)(Y Tin) + (Sum of)(F Qout,old) + (Sum of)(W Qsrc)
! In both equations, flux is positive from outside to inside. The V and W terms are for radiant systems only.
! Set current inside flux:
QH(SurfNum,1,2) = TH(SurfNum,1,1)*Construct(ConstrNum)%CTFCross(0) &
-TempSurfIn(SurfNum)*Construct(ConstrNum)%CTFInside(0) &
+QsrcHist(SurfNum,1)*Construct(ConstrNum)%CTFSourceIn(0) & ! Heat source/sink term for radiant systems
+CTFConstInPart(SurfNum)
IF(Surface(SurfNum)%Class==SurfaceClass_Floor .OR. Surface(SurfNum)%Class==SurfaceClass_Wall .OR. &
Surface(SurfNum)%Class==SurfaceClass_IntMass .or. &
Surface(SurfNum)%Class==SurfaceClass_Roof .OR. Surface(SurfNum)%Class==SurfaceClass_Door) THEN
OpaqSurfInsFaceConduction(SurfNum) = Surface(SurfNum)%Area * QH(SurfNum,1,2)
OpaqSurfInsFaceConductionFlux(SurfNum) = QH(SurfNum,1,2) !CR 8901
! IF (Surface(SurfNum)%Class/=SurfaceClass_IntMass) &
! ZoneOpaqSurfInsFaceCond(Surface(SurfNum)%Zone) = ZoneOpaqSurfInsFaceCond(Surface(SurfNum)%Zone) + &
! OpaqSurfInsFaceConduction(SurfNum)
OpaqSurfInsFaceCondGainRep(SurfNum) = 0.0d0
OpaqSurfInsFaceCondLossRep(SurfNum) = 0.0d0
IF(OpaqSurfInsFaceConduction(SurfNum) >= 0.0d0) THEN
OpaqSurfInsFaceCondGainRep(SurfNum) = OpaqSurfInsFaceConduction(SurfNum)
ELSE
OpaqSurfInsFaceCondLossRep(SurfNum) = -OpaqSurfInsFaceConduction(SurfNum)
END IF
END IF
! Update the temperature at the source/sink location (if one is present)
IF (Construct(ConstrNum)%SourceSinkPresent) THEN
TsrcHist(SurfNum,1) = TH(SurfNum,1,1)*Construct(ConstrNum)%CTFTSourceOut(0) &
+TempSurfIn(SurfNum)*Construct(ConstrNum)%CTFTSourceIn(0) &
+QsrcHist(SurfNum,1)*Construct(ConstrNum)%CTFTSourceQ(0) &
+CTFTsrcConstPart(SurfNum)
TempSource(SurfNum) = TsrcHist(SurfNum,1)
END IF
IF (Surface(SurfNum)%ExtBoundCond > 0) CYCLE ! Don't need to evaluate outside for partitions
! Set current outside flux:
QH(SurfNum,1,1) = TH(SurfNum,1,1)*Construct(ConstrNum)%CTFOutside(0) &
-TempSurfIn(SurfNum)*Construct(ConstrNum)%CTFCross(0) &
+QsrcHist(SurfNum,1)*Construct(ConstrNum)%CTFSourceOut(0) & ! Heat source/sink term for radiant systems
+CTFConstOutPart(SurfNum)
IF(Surface(SurfNum)%Class==SurfaceClass_Floor .OR. Surface(SurfNum)%Class==SurfaceClass_Wall .OR. &
Surface(SurfNum)%Class==SurfaceClass_IntMass .or. &
Surface(SurfNum)%Class==SurfaceClass_Roof .OR. Surface(SurfNum)%Class==SurfaceClass_Door) THEN
OpaqSurfOutsideFaceConductionFlux(SurfNum) = - QH(SurfNum,1,1) ! switch sign for balance at outside face
OpaqSurfOutsideFaceConduction(SurfNum) = Surface(SurfNum)%Area * OpaqSurfOutsideFaceConductionFlux(SurfNum)
END IF
END DO ! ...end of loop over all (heat transfer) surfaces...
DO SurfNum = 1, TotSurfaces ! Loop through all (heat transfer) surfaces...
IF (Surface(SurfNum)%Class == SurfaceClass_Window .or. .NOT.Surface(SurfNum)%HeatTransSurf) CYCLE
IF ((Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_CTF) .AND. &
(Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_EMPD) .AND. &
(Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_TDD)) CYCLE
IF (SUMH(SurfNum) == 0) THEN ! First time step in a block for a surface, update arrays
TempExt1(SurfNum) = TH(SurfNum,1,1)
TempInt1(SurfNum) = TempSurfIn(SurfNum)
Tsrc1(SurfNum) = TsrcHist(SurfNum,1)
QExt1(SurfNum) = QH(SurfNum,1,1)
QInt1(SurfNum) = QH(SurfNum,1,2)
Qsrc1(SurfNum) = QsrcHist(SurfNum,1)
END IF
END DO ! ...end of loop over all (heat transfer) surfaces...
! SHIFT TEMPERATURE AND FLUX HISTORIES:
! SHIFT AIR TEMP AND FLUX SHIFT VALUES WHEN AT BOTTOM OF ARRAY SPACE.
DO SurfNum = 1, TotSurfaces ! Loop through all (heat transfer) surfaces...
IF (Surface(SurfNum)%Class == SurfaceClass_Window .or. Surface(SurfNum)%Class == SurfaceClass_TDD_Dome &
.or. .NOT.Surface(SurfNum)%HeatTransSurf) CYCLE
IF ((Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_CTF) .AND. &
(Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_EMPD) .AND. &
(Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_TDD) ) CYCLE
ConstrNum = Surface(SurfNum)%Construction
SUMH(SurfNum) = SUMH(SurfNum)+1
SumTime(SurfNum) = REAL(SUMH(SurfNum),r64)*TimeStepZone
IF (SUMH(SurfNum) == Construct(ConstrNum)%NumHistories) THEN
SUMH(SurfNum) = 0
IF (Construct(ConstrNum)%NumCTFTerms > 1) THEN
DO HistTermNum = Construct(ConstrNum)%NumCTFTerms+1, 3, -1
DO SideNum = 1, 2
THM(SurfNum,HistTermNum,SideNum) = THM(SurfNum,HistTermNum-1,SideNum)
QHM(SurfNum,HistTermNum,SideNum) = QHM(SurfNum,HistTermNum-1,SideNum)
TH(SurfNum,HistTermNum,SideNum) = THM(SurfNum,HistTermNum,SideNum)
QH(SurfNum,HistTermNum,SideNum) = QHM(SurfNum,HistTermNum,SideNum)
END DO
TsrcHistM(SurfNum,HistTermNum) = TsrcHistM(SurfNum,HistTermNum-1)
TsrcHist(SurfNum,HistTermNum) = TsrcHistM(SurfNum,HistTermNum)
QsrcHistM(SurfNum,HistTermNum) = QsrcHistM(SurfNum,HistTermNum-1)
QsrcHist(SurfNum,HistTermNum) = QsrcHistM(SurfNum,HistTermNum)
END DO
END IF
THM(SurfNum,2,1) = TempExt1(SurfNum)
THM(SurfNum,2,2) = TempInt1(SurfNum)
TsrcHistM(SurfNum,2) = Tsrc1(SurfNum)
QHM(SurfNum,2,1) = QExt1(SurfNum)
QHM(SurfNum,2,2) = QInt1(SurfNum)
QsrcHistM(SurfNum,2) = Qsrc1(SurfNum)
TH(SurfNum,2,1) = THM(SurfNum,2,1)
TH(SurfNum,2,2) = THM(SurfNum,2,2)
TsrcHist(SurfNum,2) = TsrcHistM(SurfNum,2)
QH(SurfNum,2,1) = QHM(SurfNum,2,1)
QH(SurfNum,2,2) = QHM(SurfNum,2,2)
QsrcHist(SurfNum,2) = QsrcHistM(SurfNum,2)
ELSE
IF (Construct(ConstrNum)%NumCTFTerms > 1) THEN
DO HistTermNum = Construct(ConstrNum)%NumCTFTerms+1, 3, -1
DO SideNum = 1, 2
TH(SurfNum,HistTermNum,SideNum) = THM(SurfNum,HistTermNum,SideNum) &
-( THM(SurfNum,HistTermNum,SideNum) &
-THM(SurfNum,HistTermNum-1,SideNum) ) &
*SumTime(SurfNum) &
/Construct(ConstrNum)%CTFTimeStep
QH(SurfNum,HistTermNum,SideNum) = QHM(SurfNum,HistTermNum,SideNum) &
-( QHM(SurfNum,HistTermNum,SideNum) &
-QHM(SurfNum,HistTermNum-1,SideNum) ) &
*SumTime(SurfNum) &
/Construct(ConstrNum)%CTFTimeStep
END DO
TsrcHist(SurfNum,HistTermNum) = TsrcHistM(SurfNum,HistTermNum) &
-( TsrcHistM(SurfNum,HistTermNum) &
-TsrcHistM(SurfNum,HistTermNum-1) ) &
*SumTime(SurfNum) &
/Construct(ConstrNum)%CTFTimeStep
QsrcHist(SurfNum,HistTermNum) = QsrcHistM(SurfNum,HistTermNum) &
-( QsrcHistM(SurfNum,HistTermNum) &
-QsrcHistM(SurfNum,HistTermNum-1) ) &
*SumTime(SurfNum) &
/Construct(ConstrNum)%CTFTimeStep
END DO
ENDIF
TH(SurfNum,2,1) = THM(SurfNum,2,1) &
-(THM(SurfNum,2,1)-TempExt1(SurfNum)) &
*SumTime(SurfNum)/Construct(ConstrNum)%CTFTimeStep
TH(SurfNum,2,2) = THM(SurfNum,2,2) &
-(THM(SurfNum,2,2)-TempInt1(SurfNum)) &
*SumTime(SurfNum)/Construct(ConstrNum)%CTFTimeStep
QH(SurfNum,2,1) = QHM(SurfNum,2,1) &
-(QHM(SurfNum,2,1)-QExt1(SurfNum)) &
*SumTime(SurfNum)/Construct(ConstrNum)%CTFTimeStep
QH(SurfNum,2,2) = QHM(SurfNum,2,2) &
-(QHM(SurfNum,2,2)-QInt1(SurfNum)) &
*SumTime(SurfNum)/Construct(ConstrNum)%CTFTimeStep
TsrcHist(SurfNum,2) = TsrcHistM(SurfNum,2) &
-(TsrcHistM(SurfNum,2)-Tsrc1(SurfNum)) &
*SumTime(SurfNum)/Construct(ConstrNum)%CTFTimeStep
QsrcHist(SurfNum,2) = QsrcHistM(SurfNum,2) &
-(QsrcHistM(SurfNum,2)-Qsrc1(SurfNum)) &
*SumTime(SurfNum)/Construct(ConstrNum)%CTFTimeStep
END IF
END DO ! ...end of loop over all (heat transfer) surfaces
RETURN
END SUBROUTINE UpdateThermalHistories