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.
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 ManageDemand
! SUBROUTINE INFORMATION:
! AUTHOR Peter Graham Ellis
! DATE WRITTEN July 2005
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
!
! METHODOLOGY EMPLOYED:
! Standard EnergyPlus methodology.
! USE STATEMENTS:
USE DataGlobals, ONLY: WarmupFlag, DoingSizing
USE DataInterfaces, ONLY: ShowFatalError
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: ListNum !
LOGICAL, SAVE :: FirstTime ! Flag to allow Demand Manager List to simulate at least once
LOGICAL, SAVE :: ResimExt ! Flag to resimulate the exterior energy use simulation
LOGICAL, SAVE :: ResimHB ! Flag to resimulate the heat balance simulation (including HVAC)
LOGICAL, SAVE :: ResimHVAC ! Flag to resimulate the HVAC simulation
LOGICAL, SAVE :: BeginDemandSim ! TRUE in the first timestep after warmup of a new environment
LOGICAL, SAVE :: ClearHistory ! TRUE in the first timestep during warmup of a new environment
! FLOW:
IF (GetInput .AND. .NOT. DoingSizing) THEN
CALL GetDemandManagerInput
CALL GetDemandManagerListInput
GetInput = .FALSE.
END IF
IF (NumDemandManagerList > 0) THEN
IF (WarmupFlag) THEN
BeginDemandSim = .TRUE.
IF (ClearHistory) THEN
! Clear historical variables
DO ListNum = 1, NumDemandManagerList
DemandManagerList(ListNum)%History = 0.0d0
DemandManagerList(ListNum)%MeterDemand = 0.0d0
DemandManagerList(ListNum)%AverageDemand = 0.0d0
DemandManagerList(ListNum)%PeakDemand = 0.0d0
DemandManagerList(ListNum)%ScheduledLimit = 0.0d0
DemandManagerList(ListNum)%DemandLimit = 0.0d0
DemandManagerList(ListNum)%AvoidedDemand = 0.0d0
DemandManagerList(ListNum)%OverLimit = 0.0d0
DemandManagerList(ListNum)%OverLimitDuration = 0.0d0
END DO ! ListNum
! Clear demand manager variables
DemandMgr%Active = .FALSE.
DemandMgr%ElapsedTime = 0
DemandMgr%ElapsedRotationTime = 0
DemandMgr%RotatedLoadNum = 0
ENDIF
ClearHistory=.false.
ENDIF
IF (.NOT. WarmupFlag .AND. .NOT. DoingSizing) THEN
IF (BeginDemandSim) THEN
BeginDemandSim = .FALSE.
ClearHistory=.true.
END IF
DemandManagerExtIterations = 0
DemandManagerHBIterations = 0
DemandManagerHVACIterations = 0
FirstTime = .TRUE.
ResimExt = .FALSE.
ResimHB = .FALSE.
ResimHVAC = .FALSE.
DO WHILE (FirstTime .OR. ResimExt .OR. ResimHB .OR. ResimHVAC)
FirstTime = .FALSE.
CALL Resimulate(ResimExt, ResimHB, ResimHVAC)
ResimExt = .FALSE.
ResimHB = .FALSE.
ResimHVAC = .FALSE.
CALL SurveyDemandManagers ! Determines which Demand Managers can reduce demand
DO ListNum = 1, NumDemandManagerList
CALL SimulateDemandManagerList(ListNum, ResimExt, ResimHB, ResimHVAC)
END DO ! ListNum
CALL ActivateDemandManagers ! Sets limits on loads
IF (DemandManagerExtIterations + DemandManagerHBIterations + DemandManagerHVACIterations > 500) THEN
! This error can only happen if there is a bug in the code
CALL ShowFatalError('Too many DemandManager iterations. (>500)')
EXIT
END IF
END DO
DO ListNum = 1, NumDemandManagerList
CALL ReportDemandManagerList(ListNum)
END DO ! ListNum
END IF
END IF
RETURN
END SUBROUTINE ManageDemand