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) | :: | SysNum | |||
logical, | intent(in) | :: | FirstHVACIteration | |||
integer, | intent(in) | :: | ZoneNum | |||
integer, | intent(in) | :: | ZoneNodeNum |
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 SimVAVVS(SysNum,FirstHVACIteration, ZoneNum, ZoneNodeNum)
! SUBROUTINE INFORMATION:
! AUTHOR Fred Buhl
! DATE WRITTEN July 2004
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine simulates a single duct VAV terminal unit with a variable-speed fan upstream
! and a reheat coil on the downstream side.
! METHODOLOGY EMPLOYED:
! Define a compound component in CalcVAVVS. Break the heating/cooling load into 4 regions based
! on equip on/off combinations. Assign the heating load to the appropriate region and iteratively
! solve for the appropriate control variable value using Regula-Falsi solver.
! REFERENCES:
! na
! USE STATEMENTS:
USE DataZoneEnergyDemands
USE DataConvergParams, ONLY: HVACFlowRateToler
USE General, ONLY: SolveRegulaFalsi
USE SteamCoils, ONLY: GetCoilCapacity
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
Integer, Intent(IN) :: SysNum
INTEGER, INTENT(IN) :: ZoneNum
INTEGER, INTENT (IN):: ZoneNodeNum
LOGICAL, INTENT (IN):: FirstHVACIteration
! SUBROUTINE PARAMETER DEFINITIONS:
REAL(r64), PARAMETER :: BigLoad = 1.0d+20
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: MassFlow ! [kg/sec] Total Mass Flow Rate from Hot & Cold Inlets
REAL(r64) :: QTotLoad ! [Watts]
!unused REAL(r64) :: QZnReq ! [Watts]
REAL(r64) :: CpAirZn
!unused REAL(r64) :: CpAirSysIn
!unused REAL(r64) :: DeltaTemp
Integer :: SysOutletNode ! The node number of the terminal unit outlet node
Integer :: SysInletNode ! the node number of the terminal unit inlet node
Integer:: WaterControlNode !This is the Actuated Reheat Control Node
Integer:: SteamControlNode
REAL(r64) :: MaxFlowWater !This is the value passed to the Controller depending if FirstHVACIteration or not
REAL(r64) :: MinFlowWater !This is the value passed to the Controller depending if FirstHVACIteration or not
REAL(r64) ::MaxFlowSteam !This is the value passed to the Controller depending if FirstHVACIteration or not
REAL(r64) ::MinFlowSteam !This is the value passed to the Controller depending if FirstHVACIteration or not
REAL(r64) :: HWFlow ! the hot water flow rate [kg/s]
REAL(r64) :: QCoolFanOnMax ! max cooling - fan at max flow; note that cooling is always < 0. [W]
REAL(r64) :: QCoolFanOnMin ! min active cooling with fan on - fan at lowest speed. [W]
REAL(r64) :: QHeatFanOnMax ! max heating - fan at heat flow max, hot water flow at max [W]
REAL(r64) :: QHeatFanOnMin ! min heating - fan at min flow, hot water at max flow [W]
REAL(r64) :: QHeatFanOffMax ! max heating - fan off, hot water flow at max [W]
REAL(r64) :: QNoHeatFanOff ! min heating - fan off, hot water at min flow [W]
Integer :: HCType ! heating coil type (as a number)
Integer :: FanType ! fan type (as a number)
REAL(r64) :: HCLoad ! load passed to a gas or electric heating coil [W]
Integer :: FanOp ! 1 if fan is on; 0 if off.
REAL(r64) :: MaxCoolMassFlow ! air flow at max cooling [kg/s]
REAL(r64) :: MaxHeatMassFlow ! air flow at max heating [kg/s]
REAL(r64) :: MinMassFlow ! minimum air flow rate [kg/s]
REAL(r64) :: UnitFlowToler ! flow rate tolerance
REAL(r64) :: QDelivered
REAL(r64) :: FracDelivered
REAL(r64), DIMENSION(11) :: Par
INTEGER :: SolFlag
REAL(r64) :: ErrTolerance
REAL(r64) :: MaxSteamCap ! steam coil capacity at full load
Logical :: ErrorsFound ! returned from mining function call
! The calculated load from the Heat Balance
QTotLoad=ZoneSysEnergyDemand(ZoneNum)%RemainingOutputRequired
SysOutletNode = Sys(SysNum)%ReheatAirOutletNode
SysInletNode = Sys(SysNum)%InletNodeNum
CpAirZn = PsyCpAirFnWTdb(Node(ZoneNodeNum)%HumRat,Node(ZoneNodeNum)%Temp)
HCType = Sys(SysNum)%ReheatComp_Num
FanType = Sys(SysNum)%Fan_Num
MaxCoolMassFlow = SysInlet(SysNum)%AirMassFlowRateMaxAvail
MaxHeatMassFlow = MIN(Sys(SysNum)%HeatAirMassFlowRateMax,SysInlet(SysNum)%AirMassFlowRateMaxAvail)
MinMassFlow = MaxCoolMassFlow * Sys(SysNum)%ZoneMinAirFrac
UnitFlowToler = 0.001D0*HVACFlowRateToler
QDelivered = 0.0D0
HWFlow = 0.0D0
IF (SysInlet(SysNum)%AirMassFlowRateMaxAvail <= 0.0D0 .OR. CurDeadbandOrSetback(ZoneNum)) THEN
MassFlow = 0.0D0
FanOp = 0
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,0.0d0,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
RETURN
END IF
IF (HCType == HCoilType_SimpleHeating) THEN
WaterControlNode = Sys(SysNum)%ReheatControlNode
HCLoad = 0.0D0
If (FirstHVACIteration) Then
MaxFlowWater = Sys(SysNum)%MaxReheatWaterFlow
MinFlowWater = Sys(SysNum)%MinReheatWaterFlow
Else
WaterControlNode = Sys(SysNum)%ReheatControlNode
MaxFlowWater = Node(WaterControlNode)%MassFlowRateMaxAvail
MinFlowWater = Node(WaterControlNode)%MassFlowRateMinAvail
EndIf
ELSE
WaterControlNode = 0
HCLoad = BigLoad
MaxFlowWater = 0.0D0
MinFlowWater = 0.0D0
END IF
IF (HCType == HCoilType_SteamAirHeating) THEN
SteamControlNode = Sys(SysNum)%ReheatControlNode
HCLoad = 0.0D0
If (FirstHVACIteration) Then
MaxFlowSteam = Sys(SysNum)%MaxReheatSteamFlow
MinFlowSteam = Sys(SysNum)%MinReheatSteamFlow
Else
SteamControlNode = Sys(SysNum)%ReheatControlNode
MaxFlowSteam = Node(SteamControlNode)%MassFlowRateMaxAvail
MinFlowSteam = Node(SteamControlNode)%MassFlowRateMinAvail
EndIf
ELSE
SteamControlNode = 0
HCLoad = BigLoad
MaxFlowSteam = 0.0D0
MinFlowSteam = 0.0D0
END IF
! define 3 load regions and assign the current load to the correct region.
! region 1: active cooling with fan on
FanOp = 1
IF (HCType == HCoilType_SteamAirHeating) THEN
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowSteam,0.0d0, &
FanType,MaxCoolMassFlow,FanOp,QCoolFanOnMax)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowSteam,0.0d0, &
FanType,MinMassFlow,FanOp,QCoolFanOnMin)
! region 2: active heating with fan on
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowSteam,BigLoad,FanType,MaxHeatMassFlow,FanOp,QHeatFanOnMax)
MaxSteamCap = GetCoilCapacity(Sys(SysNum)%ReheatComp,Sys(SysNum)%ReheatName,ErrorsFound)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowSteam,0.0d0, &
FanType,MinMassFlow,FanOp,QHeatFanOnMin)
! region 3: active heating with fan off
FanOp = 0
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowSteam,BigLoad,FanType,MinMassFlow,FanOp,QHeatFanOffMax)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowSteam,0.0d0, &
FanType,MinMassFlow,FanOp,QNoHeatFanOff)
Else
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowWater,0.0d0, &
FanType,MaxCoolMassFlow,FanOp,QCoolFanOnMax)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowWater,0.0d0, &
FanType,MinMassFlow,FanOp,QCoolFanOnMin)
! region 2: active heating with fan on
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowWater,BigLoad,FanType,MaxHeatMassFlow,FanOp,QHeatFanOnMax)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowWater,0.0d0, &
FanType,MinMassFlow,FanOp,QHeatFanOnMin)
! region 3: active heating with fan off
FanOp = 0
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowWater,BigLoad,FanType,MinMassFlow,FanOp,QHeatFanOffMax)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowWater,0.0d0, &
FanType,MinMassFlow,FanOp,QNoHeatFanOff)
EndIF
! Active cooling
IF (QTotLoad < QCoolFanOnMin - SmallLoad .AND. SysInlet(SysNum)%AirMassFlowRateMaxAvail > 0.0D0 &
.AND. .NOT. CurDeadBandOrSetback(ZoneNum)) THEN
! check that it can meet the load
FanOp = 1
IF (QCoolFanOnMax < QTotLoad - SmallLoad) THEN
Par(1) = REAL(SysNum,r64)
IF (FirstHVACIteration) THEN
Par(2) = 1.0D0
ELSE
Par(2) = 0.0D0
END IF
Par(3) = REAL(ZoneNodeNum,r64)
Par(4) = REAL(HCType,r64)
IF (HCType == HCoilType_SteamAirHeating) THEN
Par(5) = MinFlowSteam
Else
Par(5) = MinFlowWater
End If
Par(6) = REAL(FanType,r64)
Par(7) = REAL(FanOp,r64)
Par(8) = QTotLoad
CALL SolveRegulaFalsi(UnitFlowToler, 50, SolFlag, MassFlow, VAVVSCoolingResidual, &
MinMassFlow, MaxCoolMassFlow, Par)
IF (SolFlag == -1) THEN
IF(Sys(SysNum)%IterationLimit == 0)THEN
CALL ShowWarningError('Supply air flow control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Iteration limit exceeded in calculating air flow rate')
END IF
CALL ShowRecurringWarningErrorAtEnd('Supply air flow Iteration limit exceeded in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationLimit)
ELSE IF (SolFlag == -2) THEN
IF(Sys(SysNum)%IterationFailed == 0)THEN
CALL ShowWarningError('Supply air flow control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Bad air flow limits')
END IF
CALL ShowRecurringWarningErrorAtEnd('Supply air flow control failed in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationFailed)
END IF
ELSE
MassFlow = MaxCoolMassFlow
IF (HCType == HCoilType_SteamAirHeating) THEN
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowSteam,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
Else
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowWater,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
End If
END IF
! no active heating or cooling
ELSE IF ( (QTotLoad >= QCoolFanOnMin - SmallLoad .AND. QTotLoad <= QNoHeatFanOff + SmallLoad .AND. &
SysInlet(SysNum)%AirMassFlowRateMaxAvail > 0.0D0) .OR. (SysInlet(SysNum)%AirMassFlowRateMaxAvail > 0.0D0 &
.AND. CurDeadBandOrSetback(ZoneNum)) ) THEN
MassFlow = MinMassFlow
FanOp = 0
IF (HCType == HCoilType_SteamAirHeating) THEN
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowSteam,QTotLoad, &
FanType,MassFlow,FanOp,QNoHeatFanOff)
Else
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MinFlowWater,0.0d0, &
FanType,MassFlow,FanOp,QNoHeatFanOff)
End If
! active heating
ELSE IF (QTotLoad > QNoHeatFanOff + SmallLoad .AND. SysInlet(SysNum)%AirMassFlowRateMaxAvail > 0.0D0 &
.AND. .NOT. CurDeadBandOrSetback(ZoneNum)) THEN
! hot water coil
IF (HCType == HCoilType_SimpleHeating) THEN
IF (QTotLoad < QHeatFanOffMax - SmallLoad) THEN
! vary HW flow, leave air flow at minimum
MassFlow = MinMassFlow
FanOp = 0
Par(1) = REAL(SysNum,r64)
IF (FirstHVACIteration) THEN
Par(2) = 1.0D0
ELSE
Par(2) = 0.0D0
END IF
Par(3) = REAL(ZoneNodeNum,r64)
Par(4) = REAL(HCType,r64)
Par(5) = MassFlow
Par(6) = REAL(FanType,r64)
Par(7) = REAL(FanOp,r64)
Par(8) = QTotLoad
ErrTolerance=Sys(SysNum)%ControllerOffset
CALL SolveRegulaFalsi(ErrTolerance, 500, SolFlag, HWFlow, VAVVSHWNoFanResidual, &
MinFlowWater, MaxFlowWater, Par)
IF (SolFlag == -1) THEN
CALL ShowRecurringWarningErrorAtEnd('Hot Water flow control failed in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%ErrCount1)
CALL ShowRecurringContinueErrorAtEnd('...Iteration limit (500) exceeded in calculating the hot water flow rate', &
Sys(SysNum)%ErrCount1c)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,HWFlow,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
ELSE IF (SolFlag == -2) THEN
CALL ShowRecurringWarningErrorAtEnd('Hot Water flow control failed (bad air flow limits) in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%ErrCount2)
END IF
ELSE IF (QTotLoad >= QHeatFanOffMax - SmallLoad .AND. QTotLoad <= QHeatFanOnMin + SmallLoad) THEN
MassFlow = MinMassFlow
FanOp = 0
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowWater,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
ELSE IF (QTotLoad > QHeatFanOnMin + SmallLoad .AND. QTotLoad < QHeatFanOnMax - SmallLoad) THEN
! set hot water flow to max and vary the supply air flow rate
FanOp = 1
Par(1) = REAL(SysNum,r64)
IF (FirstHVACIteration) THEN
Par(2) = 1.0D0
ELSE
Par(2) = 0.0D0
END IF
Par(3) = REAL(ZoneNodeNum,r64)
Par(4) = REAL(HCType,r64)
Par(5) = MaxFlowWater
Par(6) = REAL(FanType,r64)
Par(7) = REAL(FanOp,r64)
Par(8) = QTotLoad
CALL SolveRegulaFalsi(UnitFlowToler, 50, SolFlag, MassFlow, VAVVSHWFanOnResidual, &
MinMassFlow, MaxHeatMassFlow, Par)
IF (SolFlag == -1) THEN
IF(Sys(SysNum)%IterationLimit == 0)THEN
CALL ShowWarningError('Supply air flow control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Iteration limit exceeded in calculating air flow rate')
END IF
CALL ShowRecurringWarningErrorAtEnd('Supply air flow Iteration limit exceeded in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationLimit)
ELSE IF (SolFlag == -2) THEN
IF(Sys(SysNum)%IterationFailed == 0)THEN
CALL ShowWarningError('Supply air flow control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Bad air flow limits')
END IF
CALL ShowRecurringWarningErrorAtEnd('Supply air flow control failed in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationFailed)
END IF
ELSE
MassFlow = MaxHeatMassFlow
FanOp = 1
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowWater,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
END IF
ELSE IF (HCType == HCoilType_SteamAirHeating) THEN
! IF (QTotLoad > QNoHeatFanOff + SmallLoad .AND. QTotLoad < QHeatFanOffMax - SmallLoad) THEN
IF (QTotLoad < QHeatFanOffMax - SmallLoad) THEN
! vary steam flow, leave air flow at minimum
MassFlow = MinMassFlow
FanOp = 0
Par(1) = REAL(SysNum,r64)
IF (FirstHVACIteration) THEN
Par(2) = 1.0D0
ELSE
Par(2) = 0.0D0
END IF
Par(3) = REAL(ZoneNodeNum,r64)
Par(4) = REAL(HCType,r64)
Par(5) = MassFlow
Par(6) = REAL(FanType,r64)
Par(7) = REAL(FanOp,r64)
Par(8) = QTotLoad
Par(9) = MinFlowSteam
Par(10) = MaxFlowSteam
Par(11) = MaxSteamCap
ErrTolerance=Sys(SysNum)%ControllerOffset
CALL SolveRegulaFalsi(ErrTolerance, 500, SolFlag, HWFlow, VAVVSHWNoFanResidual, &
MinFlowSteam, MaxFlowSteam, Par)
IF (SolFlag == -1) THEN
CALL ShowRecurringWarningErrorAtEnd('Steam flow control failed in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%ErrCount1)
CALL ShowRecurringContinueErrorAtEnd('...Iteration limit (500) exceeded in calculating the hot water flow rate', &
Sys(SysNum)%ErrCount1c)
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,HWFlow,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
ELSE IF (SolFlag == -2) THEN
CALL ShowRecurringWarningErrorAtEnd('Steam flow control failed (bad air flow limits) in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%ErrCount2)
END IF
ELSE IF (QTotLoad >= QHeatFanOffMax - SmallLoad .AND. QTotLoad <= QHeatFanOnMin + SmallLoad) THEN
MassFlow = MinMassFlow
FanOp = 0
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,MaxFlowWater,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
ELSE IF (QTotLoad > QHeatFanOnMin + SmallLoad .AND. QTotLoad < QHeatFanOnMax - SmallLoad) THEN
FanOp = 1
Par(1) = REAL(SysNum,r64)
IF (FirstHVACIteration) THEN
Par(2) = 1.d0
ELSE
Par(2) = 0.0d0
END IF
Par(3) = REAL(ZoneNodeNum,r64)
Par(4) = REAL(HCType,r64)
Par(5) = MaxFlowSteam
Par(6) = REAL(FanType,r64)
Par(7) = REAL(FanOp,r64)
Par(8) = QTotLoad
CALL SolveRegulaFalsi(UnitFlowToler, 50, SolFlag, MassFlow, VAVVSHWFanOnResidual, &
MinMassFlow, MaxHeatMassFlow, Par)
IF (SolFlag == -1) THEN
IF(Sys(SysNum)%IterationLimit == 0)THEN
CALL ShowWarningError('Steam heating coil control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Iteration limit exceeded in calculating air flow rate')
END IF
CALL ShowRecurringWarningErrorAtEnd('Steam heating coil iteration limit exceeded in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationLimit)
ELSE IF (SolFlag == -2) THEN
IF(Sys(SysNum)%IterationFailed == 0)THEN
CALL ShowWarningError('Steam heating coil control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Bad air flow limits')
END IF
CALL ShowRecurringWarningErrorAtEnd('Steam heating coil control failed in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationFailed)
END IF
ELSE
MassFlow = MaxHeatMassFlow
FanOp = 1
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,QTotLoad, &
QTotLoad,FanType,MassFlow,FanOp,QDelivered)
END IF
ELSE IF (HCType == HCoilType_Gas .OR. HCType == HCoilType_Electric) THEN
IF (QTotLoad <= QHeatFanOnMin + SmallLoad) THEN
! vary heating coil power, leave mass flow at minimum
MassFlow = MinMassFlow
FanOp = 0
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,0.0d0, &
QTotLoad,FanType,MassFlow,FanOp,QDelivered)
ELSE IF (QTotLoad > QHeatFanOnMin + SmallLoad .AND. QTotLoad < QHeatFanOnMax - SmallLoad) THEN
FanOp = 1
Par(1) = REAL(SysNum,r64)
IF (FirstHVACIteration) THEN
Par(2) = 1.d0
ELSE
Par(2) = 0.0d0
END IF
Par(3) = REAL(ZoneNodeNum,r64)
Par(4) = REAL(HCType,r64)
Par(5) = Sys(SysNum)%ReheatCoilMaxCapacity
Par(6) = REAL(FanType,r64)
Par(7) = REAL(FanOp,r64)
Par(8) = QTotLoad
CALL SolveRegulaFalsi(UnitFlowToler, 50, SolFlag, FracDelivered, VAVVSHCFanOnResidual, &
0.0d0, 1.0d0, Par)
IF (SolFlag == -1) THEN
IF(Sys(SysNum)%IterationLimit == 0)THEN
CALL ShowWarningError('Heating coil control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Iteration limit exceeded in calculating air flow rate')
END IF
CALL ShowRecurringWarningErrorAtEnd('Heating coil control iteration limit exceeded in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationLimit)
ELSE IF (SolFlag == -2) THEN
IF(Sys(SysNum)%IterationFailed == 0)THEN
CALL ShowWarningError('Heating coil control failed in VS VAV terminal unit '//TRIM(Sys(SysNum)%SysName))
CALL ShowContinueError(' Bad air flow limits')
END IF
CALL ShowRecurringWarningErrorAtEnd('Heating coil control failed in VS VAV terminal unit '// &
TRIM(Sys(SysNum)%SysName),Sys(SysNum)%IterationFailed)
END IF
ELSE
MassFlow = MaxHeatMassFlow
FanOp = 1
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,0.0d0, &
QTotLoad,FanType,MassFlow,FanOp,QDelivered)
END IF
ELSE
CALL ShowFatalError('Invalid Reheat Component='//TRIM(Sys(SysNum)%ReheatComp))
END IF
ELSE
MassFlow = 0.0D0
FanOp = 0
CALL CalcVAVVS(SysNum,FirstHVACIteration,ZoneNodeNum,HCType,0.0d0,0.0d0, &
FanType,MassFlow,FanOp,QDelivered)
END IF
RETURN
END SUBROUTINE SimVAVVS