SUBROUTINE InitCBVAV(CBVAVNum, FirstHVACIteration, AirLoopNum, QZnReq, OnOffAirFlowRatio, HXUnitOn)
! SUBROUTINE INFORMATION:
! AUTHOR Richard Raustad
! DATE WRITTEN July 2006
! MODIFIED B. Griffith, May 2009, EMS setpoint check
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine is for initializations of the changeover-bypass VAV system components.
! METHODOLOGY EMPLOYED:
! Uses the status flags to trigger initializations. The CBVAV system is simulated with no load (coils off) to
! determine the outlet temperature. A setpoint temperature is calculated on FirstHVACIteration = TRUE.
! Once the setpoint is calculated, the inlet mass flow rate on FirstHVACIteration = FALSE is used to
! determine the bypass fraction. The simulation converges quickly on mass flow rate. If the zone
! temperatures float in the deadband, additional iterations are required to converge on mass flow rate.
! REFERENCES:
! na
! USE STATEMENTS:
USE Fans, ONLY: GetFanIndex, GetFanVolFlow
USE General, ONLY: TrimSigDigits
USE DataSizing, ONLY: AutoSize
USE Psychrometrics, ONLY: PsyRhoAirFnPbTdbW
USE ScheduleManager, ONLY: GetCurrentScheduleValue
USE DataAirLoop, ONLY: AirLoopControlInfo
USE DataGlobals, ONLY: AnyEnergyManagementSystemInModel
USE EMSManager, ONLY: CheckIfNodeSetpointManagedByEMS, iHumidityRatioMaxSetpoint
USE SteamCoils, ONLY: SimulateSteamCoilComponents, GetCoilMaxSteamFlowRate=>GetCoilMaxSteamFlowRate, &
GetSteamCoilCapacity=>GetCoilCapacity
USE WaterCoils, ONLY: GetCoilMaxWaterFlowRate, SimulateWaterCoilComponents
USE DataPlant, ONLY: TypeOf_CoilSteamAirHeating, ScanPlantLoopsForObject, TypeOf_CoilWaterSimpleHeating, &
PlantLoop
USE FluidProperties, ONLY: GetDensityGlycol, GetSatDensityRefrig
USE PlantUtilities, ONLY: SetComponentFlowRate, InitComponentNodes
USE DataGlobals, ONLY: InitConvTemp, AnyPlantInModel
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT (IN) :: CBVAVNum ! Index of the current CBVAV unit being simulated
LOGICAL, INTENT (IN) :: FirstHVACIteration ! TRUE if first HVAC iteration
INTEGER, INTENT (IN) :: AirLoopNum ! air loop index
REAL(r64), INTENT (INOUT) :: QZnReq ! Heating/Cooling load for all zones
REAL(r64), INTENT (INOUT) :: OnOffAirFlowRatio ! Ratio of compressor ON airflow to average airflow over timestep
LOGICAL, INTENT (INOUT) :: HXUnitOn ! flag to enable heat exchanger
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: InNode ! Inlet node number in CBVAV loop
INTEGER :: OutNode ! Outlet node number in CBVAV loop
INTEGER :: MixerOutsideAirNode ! Outside air node number in CBVAV loop
REAL(r64) :: RhoAir ! Air density at InNode
LOGICAL,SAVE :: MyOneTimeFlag = .TRUE. ! Initialization flag
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyEnvrnFlag ! Used for initializations each begin environment flag
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MySizeFlag ! Used for sizing CBVAV inputs one time
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyPlantScanFlag ! Used for initializations plant component for heating coils
REAL(r64) :: QSensUnitOut ! Output of CBVAV system with coils off
REAL(r64) :: OutsideAirMultiplier ! Outside air multiplier schedule (= 1.0 if no schedule)
LOGICAL :: FanErrFlag = .FALSE. ! Error flag returned during CALL to GetFanType
INTEGER :: FanIndex ! Index to CBVAV's supply air fan
CHARACTER(len=MaxNameLength) :: CurrentModuleObject ! Object type for error messages
LOGICAL :: EMSSetpointCheck = .FALSE. ! local temporary
LOGICAL :: ErrorsFound=.false. ! Set to true if errors in input, fatal at end of routine
INTEGER :: SteamIndex ! steam coil index
REAL(r64) :: FluidDensity ! steam or water coil fluid density
REAL(r64) :: CoilMaxVolFlowRate ! water or steam max volumetric water flow rate
REAL(r64) :: QCoilActual ! actual CBVAV steam heating coil load met (W)
LOGICAL :: ErrorFlag ! local error flag returned from data mining
REAL(r64) :: mdot ! heating coil fluid mass flow rate, kg/s
InNode = CBVAV(CBVAVNum)%AirInNode
OutNode = CBVAV(CBVAVNum)%AirOutNode
! Do the one time initializations
IF (MyOneTimeFlag) THEN
ALLOCATE(MyEnvrnFlag(NumCBVAV))
ALLOCATE(MySizeFlag(NumCBVAV))
ALLOCATE(MyPlantScanFlag(NumCBVAV))
MyEnvrnFlag = .TRUE.
MySizeFlag = .TRUE.
MyPlantScanFlag = .TRUE.
MyOneTimeFlag = .FALSE.
END IF
IF (MyPlantScanFlag(CBVAVNum) .AND. ALLOCATED(PlantLoop)) THEN
IF ( (CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingWater) .OR. &
(CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingSteam) ) THEN
IF (CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingWater) THEN
ErrorFlag=.false.
CALL ScanPlantLoopsForObject( CBVAV(CBVAVNum)%HeatCoilName, &
TypeOf_CoilWaterSimpleHeating , &
CBVAV(CBVAVNum)%LoopNum, &
CBVAV(CBVAVNum)%LoopSide, &
CBVAV(CBVAVNum)%BranchNum, &
CBVAV(CBVAVNum)%CompNum, &
ErrFlag=ErrorFlag)
IF (ErrorFlag) THEN
CALL ShowFatalError('InitCBVAV: Program terminated for previous conditions.')
ENDIF
CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
CBVAV(CBVAVNum)%HeatCoilName,ErrorsFound)
IF(CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow .GT. 0.0d0)THEN
FluidDensity = GetDensityGlycol(PlantLoop(CBVAV(CBVAVNum)%LoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(CBVAV(CBVAVNum)%LoopNum)%FluidIndex, &
'InitCBVAV')
CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
CBVAV(CBVAVNum)%HeatCoilName,ErrorsFound) * FluidDensity
END IF
ELSEIF (CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingSteam) THEN
ErrorFlag=.false.
CALL ScanPlantLoopsForObject( CBVAV(CBVAVNum)%HeatCoilName, &
TypeOf_CoilSteamAirHeating , &
CBVAV(CBVAVNum)%LoopNum, &
CBVAV(CBVAVNum)%LoopSide, &
CBVAV(CBVAVNum)%BranchNum, &
CBVAV(CBVAVNum)%CompNum, &
ErrFlag=ErrorFlag)
IF (ErrorFlag) THEN
CALL ShowFatalError('InitCBVAV: Program terminated for previous conditions.')
ENDIF
CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow = GetCoilMaxSteamFlowRate(CBVAV(CBVAVNum)%HeatCoilIndex,ErrorsFound)
IF(CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow .GT. 0.0d0)THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
FluidDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitCBVAV')
CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow = &
GetCoilMaxSteamFlowRate(CBVAV(CBVAVNum)%HeatCoilIndex,ErrorsFound) * FluidDensity
END IF
ENDIF
!fill outlet node for heating coil
CBVAV(CBVAVNum)%CoilOutletNode = &
PlantLoop(CBVAV(CBVAVNum)%LoopNum)%LoopSide(CBVAV(CBVAVNum)%LoopSide) &
%Branch(CBVAV(CBVAVNum)%BranchNum)%Comp(CBVAV(CBVAVNum)%CompNum)%NodeNumOut
MyPlantScanFlag(CBVAVNum) = .FALSE.
ELSE ! CBVAV is not connected to plant
MyPlantScanFlag(CBVAVNum) = .FALSE.
ENDIF
ELSEIF (MyPlantScanFlag(CBVAVNum) .AND. .NOT. AnyPlantInModel) THEN
MyPlantScanFlag(CBVAVNum) = .FALSE.
ENDIF
IF ( .NOT. SysSizingCalc .AND. MySizeFlag(CBVAVNum) ) THEN
CALL SizeCBVAV(CBVAVNum)
! Pass the fan cycling schedule index up to the air loop. Set the air loop unitary system flag.
AirLoopControlInfo(AirLoopNum)%CycFanSchedPtr = CBVAV(CBVAVNum)%FanOpModeSchedPtr
! Set UnitarySys flag to FALSE and let the heating coil autosize independently of the cooling coil
AirLoopControlInfo(AirLoopNum)%UnitarySys = .FALSE.
AirLoopControlInfo(AirLoopNum)%FanOpMode = CBVAV(CBVAVNum)%OpMode
MySizeFlag(CBVAVNum) = .FALSE.
END IF
! Do the Begin Environment initializations
IF (BeginEnvrnFlag .and. MyEnvrnFlag(CBVAVNum)) THEN
MixerOutsideAirNode = CBVAV(CBVAVNum)%MixerOutsideAirNode
RhoAir = StdRhoAir
! set the mass flow rates from the input volume flow rates
CBVAV(CBVAVNum)%MaxCoolAirMassFlow = RhoAir*CBVAV(CBVAVNum)%MaxCoolAirVolFlow
CBVAV(CBVAVNum)%CoolOutAirMassFlow = RhoAir*CBVAV(CBVAVNum)%CoolOutAirVolFlow
CBVAV(CBVAVNum)%MaxHeatAirMassFlow = RhoAir*CBVAV(CBVAVNum)%MaxHeatAirVolFlow
CBVAV(CBVAVNum)%HeatOutAirMassFlow = RhoAir*CBVAV(CBVAVNum)%HeatOutAirVolFlow
CBVAV(CBVAVNum)%MaxNoCoolHeatAirMassFlow = RhoAir*CBVAV(CBVAVNum)%MaxNoCoolHeatAirVolFlow
CBVAV(CBVAVNum)%NoCoolHeatOutAirMassFlow = RhoAir*CBVAV(CBVAVNum)%NoCoolHeatOutAirVolFlow
! set the node max and min mass flow rates
Node(MixerOutsideAirNode)%MassFlowRateMax = MAX(CBVAV(CBVAVNum)%CoolOutAirMassFlow,CBVAV(CBVAVNum)%HeatOutAirMassFlow)
Node(MixerOutsideAirNode)%MassFlowRateMaxAvail = MAX(CBVAV(CBVAVNum)%CoolOutAirMassFlow,CBVAV(CBVAVNum)%HeatOutAirMassFlow)
Node(MixerOutsideAirNode)%MassFlowRateMin = 0.0d0
Node(MixerOutsideAirNode)%MassFlowRateMinAvail = 0.0d0
Node(InNode)%MassFlowRateMax = MAX(CBVAV(CBVAVNum)%MaxCoolAirMassFlow,CBVAV(CBVAVNum)%MaxHeatAirMassFlow)
Node(InNode)%MassFlowRateMaxAvail = MAX(CBVAV(CBVAVNum)%MaxCoolAirMassFlow,CBVAV(CBVAVNum)%MaxHeatAirMassFlow)
Node(InNode)%MassFlowRateMin = 0.0d0
Node(InNode)%MassFlowRateMinAvail = 0.0d0
Node(OutNode)%Temp = Node(InNode)%Temp
Node(OutNode)%HumRat = Node(InNode)%HumRat
Node(OutNode)%Enthalpy = Node(InNode)%Enthalpy
Node(CBVAV(CBVAVNum)%MixerReliefAirNode) = Node(MixerOutsideAirNode)
MyEnvrnFlag(CBVAVNum) = .FALSE.
CBVAV(CBVAVNum)%LastMode = HeatingMode
! set fluid-side hardware limits
IF(CBVAV(CBVAVNum)%CoilControlNode .GT. 0)THEN
! If water coil max water flow rate is autosized, simulate once in order to mine max water flow rate
IF(CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow .EQ. Autosize)THEN
IF (CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingWater) THEN
CALL SimulateWaterCoilComponents(CBVAV(CBVAVNum)%HeatCoilName,FirstHVACIteration, &
CBVAV(CBVAVNum)%HeatCoilIndex)
ErrorFlag = .FALSE.
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
CBVAV(CBVAVNum)%HeatCoilName,ErrorFlag)
IF (ErrorFlag) Then
ErrorsFound = .TRUE.
ENDIF
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
FluidDensity = GetDensityGlycol(PlantLoop(CBVAV(CBVAVNum)%LoopNum)%fluidName, &
InitConvTemp, &
PlantLoop(CBVAV(CBVAVNum)%LoopNum)%fluidIndex, &
'InitCBVAV')
CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow = CoilMaxVolFlowRate * FluidDensity
ENDIF
ENDIF
IF (CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingSteam) THEN
CALL SimulateSteamCoilComponents(CBVAV(CBVAVNum)%HeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
CBVAV(CBVAVNum)%HeatCoilIndex, QCoilActual)
ErrorFlag = .FALSE.
CoilMaxVolFlowRate = GetCoilMaxSteamFlowRate(CBVAV(CBVAVNum)%HeatCoilIndex,ErrorFlag)
IF (ErrorFlag) Then
ErrorsFound = .TRUE.
ENDIF
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
FluidDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitCBVAV')
CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow = CoilMaxVolFlowRate * FluidDensity
ENDIF
ENDIF
ENDIF ! end of IF(CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow .EQ. Autosize)THEN
Call InitComponentNodes(0.d0, CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow, &
CBVAV(CBVAVNum)%CoilControlNode, &
CBVAV(CBVAVNum)%CoilOutletNode, &
CBVAV(CBVAVNum)%LoopNum, &
CBVAV(CBVAVNum)%LoopSide, &
CBVAV(CBVAVNum)%BranchNum, &
CBVAV(CBVAVNum)%CompNum )
END IF ! end of IF(CBVAV(CBVAVNum)%CoilControlNode .GT. 0)THEN
END IF ! end one time inits
IF (.NOT. BeginEnvrnFlag) THEN
MyEnvrnFlag(CBVAVNum) = .TRUE.
END IF
! IF CBVAV system was not autosized and the fan is autosized, check that fan volumetric flow rate is greater than CBVAV flow rates
IF(.NOT. DoingSizing .AND. CBVAV(CBVAVNum)%CheckFanFlow)THEN
CurrentModuleObject = 'AirLoopHVAC:UnitaryHeatCool:VAVChangeoverBypass'
FanErrFlag = .FALSE.
CALL GetFanIndex(CBVAV(CBVAVNum)%FanName,FanIndex,FanErrFlag)
IF (FanErrFlag) THEN
CALL ShowContinueError('...Fan occurs in '//TRIM(CurrentModuleObject)// &
' ='//TRIM(CBVAV(CBVAVNum)%Name))
ELSE
! Only get the fan volumetric flow rate if the fan is valid, otherwise GetFanVolFlow returns a 0 and
! the following warnings are written to the error file.
CALL GetFanVolFlow(FanIndex,CBVAV(CBVAVNum)%FanVolFlow)
ENDIF
IF(CBVAV(CBVAVNum)%FanVolFlow .NE. AutoSize)THEN
! Check fan versus system supply air flow rates
IF(CBVAV(CBVAVNum)%FanVolFlow .LT. CBVAV(CBVAVNum)%MaxCoolAirVolFlow)THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(CBVAV(CBVAVNum)%FanName)//' is less than the maximum CBVAV system air flow rate' &
//' when cooling is required ('//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%MaxCoolAirVolFlow,7))//').')
CALL ShowContinueError(' The CBVAV system flow rate when cooling is required is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in Changeover-bypass VAV system = '//TRIM(CBVAV(CBVAVNum)%Name))
CBVAV(CBVAVNum)%MaxCoolAirVolFlow = CBVAV(CBVAVNum)%FanVolFlow
END IF
IF(CBVAV(CBVAVNum)%FanVolFlow .LT. CBVAV(CBVAVNum)%MaxHeatAirVolFlow)THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(CBVAV(CBVAVNum)%FanName)//' is less than the maximum CBVAV system air flow rate' &
//' when heating is required ('//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%MaxHeatAirVolFlow,7))//').')
CALL ShowContinueError(' The CBVAV system flow rate when heating is required is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in Changeover-bypass VAV system = '//TRIM(CBVAV(CBVAVNum)%Name))
CBVAV(CBVAVNum)%MaxHeatAirVolFlow = CBVAV(CBVAVNum)%FanVolFlow
END IF
IF(CBVAV(CBVAVNum)%FanVolFlow .LT. CBVAV(CBVAVNum)%MaxNoCoolHeatAirVolFlow .AND. &
CBVAV(CBVAVNum)%MaxNoCoolHeatAirVolFlow .NE. 0.0d0)THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(CBVAV(CBVAVNum)%FanName)//' is less than the maximum CBVAV system air flow rate when no ' &
//'heating or cooling is needed ('//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%MaxNoCoolHeatAirVolFlow,7))//').')
CALL ShowContinueError(' The CBVAV system flow rate when no heating or cooling is needed is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in Changeover-bypass VAV system = '//TRIM(CBVAV(CBVAVNum)%Name))
CBVAV(CBVAVNum)%MaxNoCoolHeatAirVolFlow = CBVAV(CBVAVNum)%FanVolFlow
END IF
! Check fan versus outdoor air flow rates
IF(CBVAV(CBVAVNum)%FanVolFlow .LT. CBVAV(CBVAVNum)%CoolOutAirVolFlow)THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(CBVAV(CBVAVNum)%FanName)//' is less than the maximum CBVAV outdoor air flow rate' &
//' when cooling is required ('//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%CoolOutAirVolFlow,7))//').')
CALL ShowContinueError(' The CBVAV outdoor flow rate when cooling is required is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in Changeover-bypass VAV system = '//TRIM(CBVAV(CBVAVNum)%Name))
CBVAV(CBVAVNum)%CoolOutAirVolFlow = CBVAV(CBVAVNum)%FanVolFlow
END IF
IF(CBVAV(CBVAVNum)%FanVolFlow .LT. CBVAV(CBVAVNum)%HeatOutAirVolFlow)THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(CBVAV(CBVAVNum)%FanName)//' is less than the maximum CBVAV outdoor air flow rate' &
//' when heating is required ('//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%HeatOutAirVolFlow,7))//').')
CALL ShowContinueError(' The CBVAV outdoor flow rate when heating is required is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in Changeover-bypass VAV system = '//TRIM(CBVAV(CBVAVNum)%Name))
CBVAV(CBVAVNum)%HeatOutAirVolFlow = CBVAV(CBVAVNum)%FanVolFlow
END IF
IF(CBVAV(CBVAVNum)%FanVolFlow .LT. CBVAV(CBVAVNum)%NoCoolHeatOutAirVolFlow)THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(CBVAV(CBVAVNum)%FanName)//' is less than the maximum CBVAV outdoor air flow rate when no ' &
//'heating or cooling is needed ('//TRIM(TrimSigDigits(CBVAV(CBVAVNum)%NoCoolHeatOutAirVolFlow,7))//').')
CALL ShowContinueError(' The CBVAV outdoor flow rate when no heating or cooling is needed is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in Changeover-bypass VAV system = '//TRIM(CBVAV(CBVAVNum)%Name))
CBVAV(CBVAVNum)%NoCoolHeatOutAirVolFlow = CBVAV(CBVAVNum)%FanVolFlow
END IF
MixerOutsideAirNode = CBVAV(CBVAVNum)%MixerOutsideAirNode
RhoAir = StdRhoAir
! set the mass flow rates from the reset volume flow rates
CBVAV(CBVAVNum)%MaxCoolAirMassFlow = RhoAir*CBVAV(CBVAVNum)%MaxCoolAirVolFlow
CBVAV(CBVAVNum)%CoolOutAirMassFlow = RhoAir*CBVAV(CBVAVNum)%CoolOutAirVolFlow
CBVAV(CBVAVNum)%MaxHeatAirMassFlow = RhoAir*CBVAV(CBVAVNum)%MaxHeatAirVolFlow
CBVAV(CBVAVNum)%HeatOutAirMassFlow = RhoAir*CBVAV(CBVAVNum)%HeatOutAirVolFlow
CBVAV(CBVAVNum)%MaxNoCoolHeatAirMassFlow = RhoAir*CBVAV(CBVAVNum)%MaxNoCoolHeatAirVolFlow
CBVAV(CBVAVNum)%NoCoolHeatOutAirMassFlow = RhoAir*CBVAV(CBVAVNum)%NoCoolHeatOutAirVolFlow
! set the node max and min mass flow rates based on reset volume flow rates
Node(MixerOutsideAirNode)%MassFlowRateMax = MAX(CBVAV(CBVAVNum)%CoolOutAirMassFlow,CBVAV(CBVAVNum)%HeatOutAirMassFlow)
Node(MixerOutsideAirNode)%MassFlowRateMaxAvail = MAX(CBVAV(CBVAVNum)%CoolOutAirMassFlow,CBVAV(CBVAVNum)%HeatOutAirMassFlow)
Node(MixerOutsideAirNode)%MassFlowRateMin = 0.0d0
Node(MixerOutsideAirNode)%MassFlowRateMinAvail = 0.0d0
Node(InNode)%MassFlowRateMax = MAX(CBVAV(CBVAVNum)%MaxCoolAirMassFlow,CBVAV(CBVAVNum)%MaxHeatAirMassFlow)
Node(InNode)%MassFlowRateMaxAvail = MAX(CBVAV(CBVAVNum)%MaxCoolAirMassFlow,CBVAV(CBVAVNum)%MaxHeatAirMassFlow)
Node(InNode)%MassFlowRateMin = 0.0d0
Node(InNode)%MassFlowRateMinAvail = 0.0d0
Node(OutNode)%Temp = Node(InNode)%Temp
Node(OutNode)%HumRat = Node(InNode)%HumRat
Node(OutNode)%Enthalpy = Node(InNode)%Enthalpy
Node(CBVAV(CBVAVNum)%MixerReliefAirNode) = Node(MixerOutsideAirNode)
CBVAV(CBVAVNum)%CheckFanFlow = .FALSE.
IF(CBVAV(CBVAVNum)%FanVolFlow .GT. 0.0d0)THEN
CBVAV(CBVAVNum)%HeatingSpeedRatio = CBVAV(CBVAVNum)%MaxHeatAirVolFlow/CBVAV(CBVAVNum)%FanVolFlow
CBVAV(CBVAVNum)%CoolingSpeedRatio = CBVAV(CBVAVNum)%MaxCoolAirVolFlow/CBVAV(CBVAVNum)%FanVolFlow
CBVAV(CBVAVNum)%NoHeatCoolSpeedRatio = &
CBVAV(CBVAVNum)%MaxNoCoolHeatAirVolFlow/CBVAV(CBVAVNum)%FanVolFlow
END IF
END IF
END IF
IF(CBVAV(CBVAVNum)%FanOpModeSchedPtr .GT. 0)THEN
IF(GetCurrentScheduleValue(CBVAV(CBVAVNum)%FanOpModeSchedPtr) .EQ. 0.0d0)THEN
CBVAV(CBVAVNum)%OpMode = CycFanCycCoil
ELSE
CBVAV(CBVAVNum)%OpMode = ContFanCycCoil
END IF
END IF
! Returns load only for zones requesting cooling (heating). If in deadband, Qzoneload = 0.
CALL GetZoneLoads(CBVAVNum, QZnReq)
IF(CBVAV(CBVAVNum)%OutAirSchPtr .GT. 0)THEN
OutsideAirMultiplier = GetCurrentScheduleValue(CBVAV(CBVAVNum)%OutAirSchPtr)
ELSE
OutsideAirMultiplier = 1.0d0
END IF
! Set the inlet node mass flow rate
IF (CBVAV(CBVAVNum)%OpMode .EQ. ContFanCycCoil) THEN
! constant fan mode
IF (CBVAV(CBVAVNum)%HeatCoolMode == HeatingMode) THEN
CompOnMassFlow = CBVAV(CBVAVNum)%MaxHeatAirMassFlow
CompOnFlowRatio = CBVAV(CBVAVNum)%HeatingSpeedRatio
OACompOnMassFlow = CBVAV(CBVAVNum)%HeatOutAirMassFlow * OutsideAirMultiplier
CBVAV(CBVAVNum)%LastMode = HeatingMode
ELSE IF (CBVAV(CBVAVNum)%HeatCoolMode == CoolingMode) THEN
CompOnMassFlow = CBVAV(CBVAVNum)%MaxCoolAirMassFlow
CompOnFlowRatio = CBVAV(CBVAVNum)%CoolingSpeedRatio
OACompOnMassFlow = CBVAV(CBVAVNum)%CoolOutAirMassFlow * OutsideAirMultiplier
CBVAV(CBVAVNum)%LastMode = CoolingMode
ELSE
CompOnMassFlow = CBVAV(CBVAVNum)%MaxNoCoolHeatAirMassFlow
CompOnFlowRatio = CBVAV(CBVAVNum)%NoHeatCoolSpeedRatio
OACompOnMassFlow = CBVAV(CBVAVNum)%NoCoolHeatOutAirMassFlow * OutsideAirMultiplier
END IF
IF (CBVAV(CBVAVNum)%AirFlowControl .EQ. UseCompressorOnFlow) THEN
IF (CBVAV(CBVAVNum)%LastMode .EQ. HeatingMode) THEN
CompOffMassFlow = CBVAV(CBVAVNum)%MaxHeatAirMassFlow
CompOffFlowRatio = CBVAV(CBVAVNum)%HeatingSpeedRatio
OACompOffMassFlow = CBVAV(CBVAVNum)%HeatOutAirMassFlow * OutsideAirMultiplier
ELSE
CompOffMassFlow = CBVAV(CBVAVNum)%MaxCoolAirMassFlow
CompOffFlowRatio = CBVAV(CBVAVNum)%CoolingSpeedRatio
OACompOffMassFlow = CBVAV(CBVAVNum)%CoolOutAirMassFlow * OutsideAirMultiplier
END IF
ELSE
CompOffMassFlow = CBVAV(CBVAVNum)%MaxNoCoolHeatAirMassFlow
CompOffFlowRatio = CBVAV(CBVAVNum)%NoHeatCoolSpeedRatio
OACompOffMassFlow = CBVAV(CBVAVNum)%NoCoolHeatOutAirMassFlow * OutsideAirMultiplier
END IF
ELSE
! cycling fan mode
IF (CBVAV(CBVAVNum)%HeatCoolMode == HeatingMode) THEN
CompOnMassFlow = CBVAV(CBVAVNum)%MaxHeatAirMassFlow
CompOnFlowRatio = CBVAV(CBVAVNum)%HeatingSpeedRatio
OACompOnMassFlow = CBVAV(CBVAVNum)%HeatOutAirMassFlow * OutsideAirMultiplier
ELSE IF (CBVAV(CBVAVNum)%HeatCoolMode == CoolingMode) THEN
CompOnMassFlow = CBVAV(CBVAVNum)%MaxCoolAirMassFlow
CompOnFlowRatio = CBVAV(CBVAVNum)%CoolingSpeedRatio
OACompOnMassFlow = CBVAV(CBVAVNum)%CoolOutAirMassFlow * OutsideAirMultiplier
ELSE
CompOnMassFlow = CBVAV(CBVAVNum)%MaxCoolAirMassFlow
CompOnFlowRatio = CBVAV(CBVAVNum)%CoolingSpeedRatio
OACompOnMassFlow = CBVAV(CBVAVNum)%CoolOutAirMassFlow * OutsideAirMultiplier
END IF
CompOffMassFlow = 0.0d0
CompOffFlowRatio = 0.0d0
OACompOffMassFlow = 0.0d0
END IF
! Check for correct control node at outlet of unit
IF(CBVAV(CBVAVNum)%HumRatMaxCheck)THEN
IF (CBVAV(CBVAVNum)%DehumidControlType .GT. 0)THEN
IF(Node(OutNode)%HumRatMax .EQ. SensedNodeFlagValue)THEN
IF (.NOT. AnyEnergyManagementSystemInModel) THEN
CALL ShowWarningError('Unitary System:VAV:ChangeOverBypass = '//TRIM(CBVAV(CBVAVNum)%Name))
CALL ShowContinueError('Use SetpointManager:SingleZone:Humidity:Maximum to place a humidity setpoint at' // &
' the air outlet node of the unitary system.')
CALL ShowContinueError('Setting Dehumidification Control Type to None and simulation continues.')
CBVAV(CBVAVNum)%DehumidControlType = 0
ELSE
! need call to EMS to check node
EMSSetpointCheck = .FALSE.
CALL CheckIfNodeSetpointManagedByEMS(OutNode,iHumidityRatioMaxSetpoint, EMSSetpointCheck)
IF (EMSSetpointCheck) THEN
CALL ShowWarningError('Unitary System:VAV:ChangeOverBypass = '//TRIM(CBVAV(CBVAVNum)%Name))
CALL ShowContinueError('Use SetpointManager:SingleZone:Humidity:Maximum to place a humidity setpoint at' // &
' the air outlet node of the unitary system.')
CALL ShowContinueError('Or use an EMS Actuator to place a maximum humidity setpoint at' // &
' the air outlet node of the unitary system.')
CALL ShowContinueError('Setting Dehumidification Control Type to None and simulation continues.')
CBVAV(CBVAVNum)%DehumidControlType = 0
ENDIF
ENDIF
END IF
CBVAV(CBVAVNum)%HumRatMaxCheck = .FALSE.
ELSE
CBVAV(CBVAVNum)%HumRatMaxCheck = .FALSE.
END IF
END IF
! Set the inlet node mass flow rate
IF (GetCurrentScheduleValue(CBVAV(CBVAVNum)%SchedPtr) .gt. 0.0d0 .AND. CompOnMassFlow .NE. 0.0d0) THEN
OnOffAirFlowRatio = 1.0d0
IF(FirstHVACIteration)THEN
Node(CBVAV(CBVAVNum)%AirInNode)%MassFlowRate = CompOnMassFlow
Node(CBVAV(CBVAVNum)%MixerInletAirNode)%MassFlowRate = CompOnMassFlow
Node(CBVAV(CBVAVNum)%MixerOutsideAirNode)%MassFlowRate = OACompOnMassFlow
Node(CBVAV(CBVAVNum)%MixerReliefAirNode)%MassFlowRate = OACompOnMassFlow
ByPassDuctFlowFraction = 0.0d0
PartLoadFrac = 0.0d0
ELSE
IF (CBVAV(CBVAVNum)%HeatCoolMode /= 0) THEN
PartLoadFrac = 1.0d0
ELSE
PartLoadFrac = 0.0d0
END IF
IF(CBVAV(CBVAVNum)%OpMode .EQ. CycFanCycCoil) THEN
ByPassDuctFlowFraction = 0.0d0
ELSE
ByPassDuctFlowFraction = MAX(0.0d0,1.0d0 - (Node(CBVAV(CBVAVNum)%AirInNode)%MassFlowRate / CompOnMassFlow ))
END IF
END IF
ELSE
PartLoadFrac = 0.0d0
Node(CBVAV(CBVAVNum)%AirInNode)%MassFlowRate = 0.0d0
Node(CBVAV(CBVAVNum)%AirOutNode)%MassFlowRate = 0.0d0
Node(CBVAV(CBVAVNum)%AirOutNode)%MassFlowRateMaxAvail = 0.0d0
Node(CBVAV(CBVAVNum)%MixerInletAirNode)%MassFlowRate = 0.0d0
Node(CBVAV(CBVAVNum)%MixerOutsideAirNode)%MassFlowRate = 0.0d0
Node(CBVAV(CBVAVNum)%MixerReliefAirNode)%MassFlowRate = 0.0d0
OnOffAirFlowRatio = 1.0d0
ByPassDuctFlowFraction = 0.0d0
END IF
CALL CalcCBVAV(CBVAVNum,FirstHVACIteration,PartLoadFrac,QSensUnitOut,QZnReq,OnOffAirFlowRatio, HXUnitOn)
! If unit is scheduled OFF, setpoint is equal to inlet node temperature.
IF (GetCurrentScheduleValue(CBVAV(CBVAVNum)%SchedPtr) .EQ. 0.0d0) THEN
CBVAV(CBVAVNum)%OutletTempSetpoint = Node(InNode)%Temp
RETURN
END IF
CALL SetAverageAirFlow(CBVAVNum, OnOffAirFlowRatio, FirstHVACIteration)
IF(FirstHVACIteration)CBVAV(CBVAVNum)%OutletTempSetpoint = CalcSetpointTempTarget(CBVAVNum)
! The setpoint is used to control the DX coils at their respective outlet nodes (not the unit outlet), correct
! for fan heat for draw thru units only (fan heat is included at the outlet of each coil when blowthru is used)
CBVAV(CBVAVNum)%CoilTempSetpoint = CBVAV(CBVAVNum)%OutletTempSetpoint
IF(CBVAV(CBVAVNum)%FanPlace == DrawThru)THEN
CBVAV(CBVAVNum)%CoilTempSetpoint = CBVAV(CBVAVNum)%CoilTempSetpoint - &
(Node(CBVAV(CBVAVNum)%AirOutNode)%Temp-Node(CBVAV(CBVAVNum)%FanInletNodeNum)%Temp)
END IF
IF(FirstHVACIteration) THEN
IF (CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingWater) THEN
CALL SimulateWaterCoilComponents(CBVAV(CBVAVNum)%HeatCoilName,FirstHVACIteration, &
CBVAV(CBVAVNum)%HeatCoilIndex)
! set air-side and steam-side mass flow rates
Node(CBVAV(CBVAVNum)%HeatingCoilInletNode)%MassFlowRate = CompOnMassFlow
mdot = CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow
Call SetComponentFlowRate(mdot, &
CBVAV(CBVAVNum)%CoilControlNode, &
CBVAV(CBVAVNum)%CoilOutletNode, &
CBVAV(CBVAVNum)%LoopNum, &
CBVAV(CBVAVNum)%LoopSide, &
CBVAV(CBVAVNum)%BranchNum, &
CBVAV(CBVAVNum)%CompNum )
! simulate water coil to find operating capacity
CALL SimulateWaterCoilComponents(CBVAV(CBVAVNum)%HeatCoilName,FirstHVACIteration, &
CBVAV(CBVAVNum)%HeatCoilIndex, QCoilActual)
CBVAV(CBVAVNum)%DesignSuppHeatingCapacity = QCoilActual
END IF ! from IF(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingWater) THEN
IF(CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingSteam) THEN
! set air-side and steam-side mass flow rates
Node(CBVAV(CBVAVNum)%HeatingCoilInletNode)%MassFlowRate = CompOnMassFlow
mdot = CBVAV(CBVAVNum)%MaxHeatCoilFluidFlow
Call SetComponentFlowRate(mdot, &
CBVAV(CBVAVNum)%CoilControlNode, &
CBVAV(CBVAVNum)%CoilOutletNode, &
CBVAV(CBVAVNum)%LoopNum, &
CBVAV(CBVAVNum)%LoopSide, &
CBVAV(CBVAVNum)%BranchNum, &
CBVAV(CBVAVNum)%CompNum )
! simulate steam coil to find operating capacity
CALL SimulateSteamCoilComponents(CBVAV(CBVAVNum)%HeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
CBVAV(CBVAVNum)%HeatCoilIndex, QCoilActual)
CBVAV(CBVAVNum)%DesignSuppHeatingCapacity = QCoilActual
END IF ! from IF(CBVAV(CBVAVNum)%HeatCoilType_Num == Coil_HeatingSteam) THEN
END IF ! from IF( FirstHVACIteration ) THEN
IF(CBVAV(CBVAVNum)%HeatCoolMode == 0 .AND. CBVAV(CBVAVNum)%OpMode == CycFanCycCoil .OR. CompOnMassFlow .EQ. 0.0d0)THEN
QZnReq = 0.0d0
PartLoadFrac = 0.0d0
Node(CBVAV(CBVAVNum)%AirInNode)%MassFlowRate = 0.0d0
Node(CBVAV(CBVAVNum)%AirOutNode)%MassFlowRateMaxAvail = 0.0d0
Node(CBVAV(CBVAVNum)%MixerInletAirNode)%MassFlowRate = 0.0d0
Node(CBVAV(CBVAVNum)%MixerOutsideAirNode)%MassFlowRate = 0.0d0
Node(CBVAV(CBVAVNum)%MixerReliefAirNode)%MassFlowRate = 0.0d0
END IF
RETURN
END SUBROUTINE InitCBVAV