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) | :: | ThisLoopNum | |||
integer, | intent(in) | :: | ThisLoopSide | |||
logical, | intent(in) | :: | FirstHVACIteration |
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.
LOGICAL FUNCTION CheckPlantConvergence(ThisLoopNum, ThisLoopSide, FirstHVACIteration) RESULT(Converged)
! FUNCTION INFORMATION:
! AUTHOR Edwin Lee
! DATE WRITTEN Summer 2011
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This routine checks the history values in the convergence arrays of this loop/loopside combination
! METHODOLOGY EMPLOYED:
! On FirstHVAC, we are not converged yet, thus forcing at least two iterations
! Calculate the average of each related variable history (generalized: could be any number of history terms)
! If any of the history terms do not match this average, then at least one value is different, so not converged
! Although this routine appears to check for convergence, it is also used to check for stuck (max iteration) conditions
! in cases where demand side (air loop, for example) equipment is "fighting" with the plant loop
! The result of this routine can help the plant "lock-in" and take action to stop the iteration
! REFERENCES:
! na
! USE STATEMENTS:
USE DataPlant
USE DataLoopNode
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: ThisLoopNum, ThisLoopSide
LOGICAL, INTENT(IN) :: FirstHVACIteration
! FUNCTION PARAMETER DEFINITIONS:
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: InletAvgTemp
REAL(r64) :: InletAvgMdot
REAL(r64) :: OutletAvgTemp
REAL(r64) :: OutletAvgMdot
IF (FirstHVACIteration) THEN
Converged = .FALSE.
RETURN
END IF
InletAvgTemp = SUM(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%InletNode%TemperatureHistory) / &
SIZE(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%InletNode%TemperatureHistory)
IF(ANY(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%InletNode%TemperatureHistory .NE. InletAvgTemp)) THEN
Converged = .FALSE.
RETURN
END IF
InletAvgMdot = SUM(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%InletNode%MassFlowRateHistory) / &
SIZE(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%InletNode%MassFlowRateHistory)
IF(ANY(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%InletNode%MassFlowRateHistory .NE. InletAvgMdot)) THEN
Converged = .FALSE.
RETURN
END IF
OutletAvgTemp = SUM(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%OutletNode%TemperatureHistory) / &
SIZE(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%OutletNode%TemperatureHistory)
IF(ANY(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%OutletNode%TemperatureHistory .NE. OutletAvgTemp)) THEN
Converged = .FALSE.
RETURN
END IF
OutletAvgMdot = SUM(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%OutletNode%MassFlowRateHistory) / &
SIZE(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%OutletNode%MassFlowRateHistory)
IF(ANY(PlantLoop(ThisLoopNum)%LoopSide(ThisLoopSide)%OutletNode%MassFlowRateHistory .NE. OutletAvgMdot)) THEN
Converged = .FALSE.
RETURN
END IF
!If we made it this far, we're good!
Converged = .TRUE.
RETURN
END FUNCTION CheckPlantConvergence