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 UpdateDemandManagers
! SUBROUTINE INFORMATION:
! AUTHOR Peter Graham Ellis
! DATE WRITTEN July 2005
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Expires limits and rotates loads after specified time duration.
! It updates availability flags, expires managers that ended in the last timestep, etc.
! METHODOLOGY EMPLOYED:
!
! USE STATEMENTS:
USE DataGlobals, ONLY: MinutesPerTimeStep
USE ExteriorEnergyUse, ONLY: ExteriorLights
USE DataHeatBalance, ONLY: Lights, ZoneElectric
USE DataZoneControls, ONLY: TempControlledZone
USE ScheduleManager, ONLY: GetCurrentScheduleValue
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: MgrNum, LoadNum, LoadPtr
LOGICAL :: Available
LOGICAL :: CanReduceDemand
INTEGER :: RotatedLoadNum
! FLOW:
DO MgrNum = 1, NumDemandMgr
! Check availability
! IF (DemandMgr(MgrNum)%AvailSchedule .EQ. 0) THEN
! Available = .TRUE. ! No schedule defaults to available
! ELSE
IF (GetCurrentScheduleValue(DemandMgr(MgrNum)%AvailSchedule) > 0.0d0) THEN
Available = .TRUE.
ELSE
Available = .FALSE.
END IF
! END IF
DemandMgr(MgrNum)%Available = Available
! Update demand manager status
IF (Available) THEN
IF (DemandMgr(MgrNum)%Active) THEN
DemandMgr(MgrNum)%ElapsedTime = DemandMgr(MgrNum)%ElapsedTime + MinutesPerTimeStep
! Check for expiring limit duration
IF (DemandMgr(MgrNum)%ElapsedTime >= DemandMgr(MgrNum)%LimitDuration) THEN
DemandMgr(MgrNum)%ElapsedTime = 0
DemandMgr(MgrNum)%ElapsedRotationTime = 0
DemandMgr(MgrNum)%Active = .FALSE.
! Demand Manager is not available, remove demand limits from all loads
DO LoadNum = 1, DemandMgr(MgrNum)%NumOfLoads
LoadPtr = DemandMgr(MgrNum)%Load(LoadNum)
CALL LoadInterface(ClearLimit, MgrNum, LoadPtr, CanReduceDemand)
END DO ! LoadNum
ELSE
SELECT CASE (DemandMgr(MgrNum)%SelectionControl)
CASE (ManagerSelectionAll)
! Do nothing; limits remain on all loads
CASE (ManagerSelectionMany) ! All loads are limited except for one
DemandMgr(MgrNum)%ElapsedRotationTime = DemandMgr(MgrNum)%ElapsedRotationTime + MinutesPerTimeStep
IF (DemandMgr(MgrNum)%ElapsedRotationTime >= DemandMgr(MgrNum)%RotationDuration) THEN
DemandMgr(MgrNum)%ElapsedRotationTime = 0
IF (DemandMgr(MgrNum)%NumOfLoads > 1) THEN
! Turn ON limiting for the old rotated load
RotatedLoadNum = DemandMgr(MgrNum)%RotatedLoadNum
LoadPtr = DemandMgr(MgrNum)%Load(RotatedLoadNum)
CALL LoadInterface(SetLimit, MgrNum, LoadPtr, CanReduceDemand)
! Set next rotated load
RotatedLoadNum = RotatedLoadNum + 1
IF (RotatedLoadNum > DemandMgr(MgrNum)%NumOfLoads) RotatedLoadNum = 1
DemandMgr(MgrNum)%RotatedLoadNum = RotatedLoadNum
! Turn OFF limiting for the new rotated load
LoadPtr = DemandMgr(MgrNum)%Load(RotatedLoadNum)
CALL LoadInterface(ClearLimit, MgrNum, LoadPtr, CanReduceDemand)
END IF
END IF
CASE (ManagerSelectionOne) ! Only one load is limited
DemandMgr(MgrNum)%ElapsedRotationTime = DemandMgr(MgrNum)%ElapsedRotationTime + MinutesPerTimeStep
IF (DemandMgr(MgrNum)%ElapsedRotationTime >= DemandMgr(MgrNum)%RotationDuration) THEN
DemandMgr(MgrNum)%ElapsedRotationTime = 0
IF (DemandMgr(MgrNum)%NumOfLoads > 1) THEN
! Turn OFF limiting for the old rotated load
RotatedLoadNum = DemandMgr(MgrNum)%RotatedLoadNum
LoadPtr = DemandMgr(MgrNum)%Load(RotatedLoadNum)
CALL LoadInterface(ClearLimit, MgrNum, LoadPtr, CanReduceDemand)
! Set next rotated load
RotatedLoadNum = RotatedLoadNum + 1
IF (RotatedLoadNum > DemandMgr(MgrNum)%NumOfLoads) RotatedLoadNum = 1
DemandMgr(MgrNum)%RotatedLoadNum = RotatedLoadNum
! Turn ON limiting for the new rotated load
LoadPtr = DemandMgr(MgrNum)%Load(RotatedLoadNum)
CALL LoadInterface(SetLimit, MgrNum, LoadPtr, CanReduceDemand)
END IF
END IF
END SELECT
END IF
END IF
ELSE ! Demand Manager is not available
DemandMgr(MgrNum)%Active = .FALSE.
! Demand Manager is not available, remove demand limits from all loads
DO LoadNum = 1, DemandMgr(MgrNum)%NumOfLoads
LoadPtr = DemandMgr(MgrNum)%Load(LoadNum)
CALL LoadInterface(ClearLimit, MgrNum, LoadPtr, CanReduceDemand)
END DO ! LoadNum
END IF
END DO ! MgrNum
RETURN
END SUBROUTINE UpdateDemandManagers