!LKL Discrepancy with < 0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | MSHeatPumpNum | |||
logical, | intent(in) | :: | FirstHVACIteration | |||
integer, | intent(in) | :: | AirLoopNum | |||
real(kind=r64), | intent(inout) | :: | QZnReq | |||
real(kind=r64), | intent(inout) | :: | OnOffAirFlowRatio |
SUBROUTINE InitMSHeatPump(MSHeatPumpNum,FirstHVACIteration,AirLoopNum,QZnReq,OnOffAirFlowRatio)
! SUBROUTINE INFORMATION:
! AUTHOR: Lixing Gu, FSEC
! DATE WRITTEN: July 2007
! MODIFIED Bereket Nigusse, June 2010 - added a procedure to calculate supply air flow fraction
! through controlled zone
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine is for initializations of the multispeed heat pump (MSHP) components.
! METHODOLOGY EMPLOYED:
! Uses the status flags to trigger initializations. The MSHP 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.
! METHODOLOGY EMPLOYED:
!
! REFERENCES: na
! USE STATEMENTS:
USE Fans, ONLY: GetFanIndex, GetFanVolFlow
USE General, ONLY: TrimSigDigits, RoundSigDigits
USE ReportSizingManager, ONLY: ReportSizingOutput
USE DataSizing, ONLY: AutoSize
USE DataEnvironment, ONLY: StdBaroPress
USE Psychrometrics, ONLY: PsyRhoAirFnPbTdbW
USE ScheduleManager, ONLY: GetCurrentScheduleValue
USE DataZoneEnergyDemands, ONLY: ZoneSysEnergyDemand, CurDeadbandOrSetback
USE DataBranchNodeConnections, ONLY: NodeConnections, NumOfNodeConnections
USE InputProcessor, ONLY : SameString, MakeUPPERCase
USE DataAirLoop, ONLY: AirLoopControlInfo
USE DataZoneEquipment, ONLY: ZoneEquipConfig, ZONEEQUIPLIST, AirDistUnit_Num, DirectAir_Num
USE DataAirLoop , ONLY: AirToZoneNodeInfo
USE DataPlant, ONLY: ScanPlantLoopsForObject, TypeOf_MultiSpeedHeatPumpRecovery, &
PlantLoop, TypeOf_CoilSteamAirHeating, TypeOf_CoilWaterSimpleHeating
USE PlantUtilities, ONLY: InitComponentNodes, SetComponentFlowRate
USE DataGlobals, ONLY: AnyPlantInModel
USE FluidProperties, ONLY: GetDensityGlycol, GetSatDensityRefrig
USE SteamCoils, ONLY: SimulateSteamCoilComponents, GetCoilMaxSteamFlowRate=>GetCoilMaxSteamFlowRate, &
GetSteamCoilCapacity=>GetCoilCapacity
USE WaterCoils, ONLY: GetCoilMaxWaterFlowRate, SimulateWaterCoilComponents
USE DataZoneControls, ONLY: StageZoneLogic
USE DXCoils, ONLY: GetDXCoilAvailSchPtr
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT (IN) :: MSHeatPumpNum ! Engine driven heat pump number
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 served zones
REAL(r64), INTENT (INOUT) :: OnOffAirFlowRatio ! Ratio of compressor ON airflow to average airflow over timestep
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: InNode ! Inlet node number in MSHP loop
INTEGER :: OutNode ! Outlet node number in MSHP loop
INTEGER :: ZoneInNode ! Zone inlet node number in the controlled zone for MSHP
INTEGER :: HeatRecInNode ! Inlet node number of heat recovery
INTEGER :: HeatRecOutNode ! Outlet node number of heat recovery
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 MSHP inputs one time
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyCheckFlag ! Used to obtain the zone inlet node number in the controlled zone
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyFlowFracFlag ! Used for calculatig flow fraction once
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyPlantScantFlag ! used for finding on heat recovery plant loop
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyStagedFlag ! used for finding on staged thermostat
REAL(r64) :: QSensUnitOut ! Output of MSHP system with coils off
REAL(r64) :: PartLoadFrac ! Part-load ratio
INTEGER :: ZoneNum
INTEGER :: i ! Index to speed
INTEGER :: NumOfSpeedCooling ! Number of speeds for cooling
INTEGER :: NumOfSpeedHeating ! Number of speeds for heating
INTEGER :: j,k
REAL(r64) :: MinHumRat ! Minimum humidity ratio for sensible capacity calculation (kg/kg)
REAL(r64) :: DeltaMassRate ! Difference of mass flow rate between inlet node and system outlet node
INTEGER :: ZoneInSysIndex = 0 ! number of zone inlet nodes counter in an airloop
INTEGER :: NumAirLoopZones = 0 ! number of zone inlet nodes in an air loop
INTEGER :: ZoneInletNodeNum = 0 ! zone inlet nodes node number
LOGICAL :: FlowFracFlagReady = .TRUE. ! one time flag for calculating flow fraction through controlled zone
REAL(r64) :: SumOfMassFlowRateMax = 0.0d0 ! the sum of mass flow rates at inlet to zones in an airloop
REAL(r64) :: CntrlZoneTerminalUnitMassFlowRateMax = 0.0d0 ! Maximum mass flow rate through controlled zone terminal unit
LOGICAL :: errFlag
REAL(r64) :: rho ! local fluid density
REAL(r64) :: MdotHR ! local temporary for heat recovery fluid mass flow rate (kg/s)
REAL(r64) :: ZoneLoadToCoolSPSequenced
REAL(r64) :: ZoneLoadToHeatSPSequenced
INTEGER :: EquipNum = 0 ! local do loop index for equipment listed for a zone
LOGICAL :: ErrorsFound =.FALSE. ! flag returned from mining call
INTEGER :: SteamIndex =0 ! index of steam quality for steam heating coil
REAL(r64) :: mdot =0.0d0 ! local temporary for mass flow rate (kg/s)
REAL(r64) :: SteamDensity =0.0d0 ! density of steam at 100C, used for steam heating coils
REAL(r64) :: CoilMaxVolFlowRate =0.0d0 ! coil fluid maximum volume flow rate
REAL(r64) :: QACTUAL =0.0d0 ! coil actual capacity
INTEGER :: CoilAvailSchPtr =0 ! DX coil availability schedule pointer
! FLOW
InNode = MSHeatPump(MSHeatPumpNum)%AirInletNodeNum
OutNode = MSHeatPump(MSHeatPumpNum)%AirOutletNodeNum
NumOfSpeedCooling = MSHeatPump(MSHeatPumpNum)%NumOfSpeedCooling
NumOfSpeedHeating = MSHeatPump(MSHeatPumpNum)%NumOfSpeedHeating
AirLoopPass = AirLoopPass + 1
If (AirLoopPass > 2) AirLoopPass = 1
! Do the one time initializations
IF (MyOneTimeFlag) THEN
ALLOCATE(MyEnvrnFlag(NumMSHeatPumps))
ALLOCATE(MySizeFlag(NumMSHeatPumps))
ALLOCATE(MyCheckFlag(NumMSHeatPumps))
ALLOCATE(MyFlowFracFlag(NumMSHeatPumps))
ALLOCATE(MyPlantScantFlag(NumMSHeatPumps))
ALLOCATE(MyStagedFlag(NumMSHeatPumps))
MyEnvrnFlag = .TRUE.
MySizeFlag = .TRUE.
MyOneTimeFlag = .FALSE.
MyCheckFlag = .TRUE.
MyFlowFracFlag = .TRUE.
MyPlantScantFlag = .TRUE.
MyStagedFlag = .TRUE.
END IF
IF (MyPlantScantFlag(MSHeatPumpNum) .AND. ALLOCATED(PlantLoop)) THEN
IF (MSHeatPump(MSHeatPumpNum)%HeatRecActive) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject(MSHeatPump(MSHeatPumpNum)%Name, &
TypeOf_MultiSpeedHeatPumpRecovery, &
MSHeatPump(MSHeatPumpNum)%HRLoopNum, &
MSHeatPump(MSHeatPumpNum)%HRLoopSideNum, &
MSHeatPump(MSHeatPumpNum)%HRBranchNum, &
MSHeatPump(MSHeatPumpNum)%HRCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitMSHeatPump: Program terminated for previous conditions.')
ENDIF
MyPlantScantFlag(MSHeatPumpNum) = .FALSE.
ELSE
MyPlantScantFlag(MSHeatPumpNum) = .FALSE.
ENDIF
IF (MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingWater) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject( MSHeatPump(MSHeatPumpNum)%HeatCoilName, &
TypeOf_CoilWaterSimpleHeating , &
MSHeatPump(MSHeatPumpNum)%LoopNum, &
MSHeatPump(MSHeatPumpNum)%LoopSide, &
MSHeatPump(MSHeatPumpNum)%BranchNum, &
MSHeatPump(MSHeatPumpNum)%CompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitMSHeatPump: Program terminated for previous conditions.')
ENDIF
MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
MSHeatPump(MSHeatPumpNum)%HeatCoilName,ErrorsFound)
IF(MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow .GT. 0.0d0)THEN
rho = GetDensityGlycol(PlantLoop(MSHeatPump(MSHeatPumpNum)%LoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(MSHeatPump(MSHeatPumpNum)%LoopNum)%FluidIndex, &
'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
MSHeatPump(MSHeatPumpNum)%HeatCoilName,ErrorsFound) * rho
END IF
! fill outlet node for coil
MSHeatPump(MSHeatPumpNum)%CoilOutletNode = &
PlantLoop(MSHeatPump(MSHeatPumpNum)%LoopNum)%LoopSide(MSHeatPump(MSHeatPumpNum)%LoopSide) &
%Branch(MSHeatPump(MSHeatPumpNum)%BranchNum)%Comp(MSHeatPump(MSHeatPumpNum)%CompNum)%NodeNumOut
MyPlantScantFlag(MSHeatPumpNum) = .FALSE.
ELSEIF (MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingSteam) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject(MSHeatPump(MSHeatPumpNum)%HeatCoilName, &
TypeOf_CoilSteamAirHeating , &
MSHeatPump(MSHeatPumpNum)%LoopNum, &
MSHeatPump(MSHeatPumpNum)%LoopSide, &
MSHeatPump(MSHeatPumpNum)%BranchNum, &
MSHeatPump(MSHeatPumpNum)%CompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitMSHeatPump: Program terminated for previous conditions.')
ENDIF
MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow = &
GetCoilMaxSteamFlowRate(MSHeatPump(MSHeatPumpNum)%HeatCoilNum,ErrorsFound)
IF(MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow .GT. 0.0d0)THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow = MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow * SteamDensity
END IF
! fill outlet node for coil
MSHeatPump(MSHeatPumpNum)%CoilOutletNode = &
PlantLoop(MSHeatPump(MSHeatPumpNum)%LoopNum)%LoopSide(MSHeatPump(MSHeatPumpNum)%LoopSide) &
%Branch(MSHeatPump(MSHeatPumpNum)%BranchNum)%Comp(MSHeatPump(MSHeatPumpNum)%CompNum)%NodeNumOut
MyPlantScantFlag(MSHeatPumpNum) = .FALSE.
ENDIF
IF (MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingWater) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject( MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName, &
TypeOf_CoilWaterSimpleHeating , &
MSHeatPump(MSHeatPumpNum)%SuppLoopNum, &
MSHeatPump(MSHeatPumpNum)%SuppLoopSide, &
MSHeatPump(MSHeatPumpNum)%SuppBranchNum, &
MSHeatPump(MSHeatPumpNum)%SuppCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitMSHeatPump: Program terminated for previous conditions.')
ENDIF
MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName,ErrorsFound)
IF(MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow .GT. 0.0d0)THEN
rho = GetDensityGlycol(PlantLoop(MSHeatPump(MSHeatPumpNum)%SuppLoopNum)%FluidName, &
InitConvTemp, &
PlantLoop(MSHeatPump(MSHeatPumpNum)%SuppLoopNum)%FluidIndex, &
'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName,ErrorsFound) * rho
END IF
! fill outlet node for coil
MSHeatPump(MSHeatPumpNum)%SuppCoilOutletNode = &
PlantLoop(MSHeatPump(MSHeatPumpNum)%SuppLoopNum)%LoopSide(MSHeatPump(MSHeatPumpNum)%SuppLoopSide) &
%Branch(MSHeatPump(MSHeatPumpNum)%SuppBranchNum)%Comp(MSHeatPump(MSHeatPumpNum)%SuppCompNum)%NodeNumOut
MyPlantScantFlag(MSHeatPumpNum) = .FALSE.
ELSEIF (MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingSteam) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName, &
TypeOf_CoilSteamAirHeating , &
MSHeatPump(MSHeatPumpNum)%SuppLoopNum, &
MSHeatPump(MSHeatPumpNum)%SuppLoopSide, &
MSHeatPump(MSHeatPumpNum)%SuppBranchNum, &
MSHeatPump(MSHeatPumpNum)%SuppCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitMSHeatPump: Program terminated for previous conditions.')
ENDIF
MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow = &
GetCoilMaxSteamFlowRate(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilNum,ErrorsFound)
IF(MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow .GT. 0.0d0)THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow = MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow * SteamDensity
END IF
! fill outlet node for coil
MSHeatPump(MSHeatPumpNum)%SuppCoilOutletNode = &
PlantLoop(MSHeatPump(MSHeatPumpNum)%SuppLoopNum)%LoopSide(MSHeatPump(MSHeatPumpNum)%SuppLoopSide) &
%Branch(MSHeatPump(MSHeatPumpNum)%SuppBranchNum)%Comp(MSHeatPump(MSHeatPumpNum)%SuppCompNum)%NodeNumOut
MyPlantScantFlag(MSHeatPumpNum) = .FALSE.
ENDIF
ELSEIF (MyPlantScantFlag(MSHeatPumpNum) .AND. .NOT. AnyPlantInModel) THEN
MyPlantScantFlag(MSHeatPumpNum) = .FALSE.
ENDIF
IF ( .NOT. SysSizingCalc .AND. MySizeFlag(MSHeatPumpNum) ) THEN
CALL GetFanVolFlow(MSHeatPump(MSHeatPumpNum)%FanNum,MSHeatPump(MSHeatPumpNum)%FanVolFlow)
CALL SizeMSHeatPump(MSHeatPumpNum)
MSHeatPump(MSHeatPumpNum)%FlowFraction = 1.0d0
MySizeFlag(MSHeatPumpNum) = .FALSE.
! Pass the fan cycling schedule index up to the air loop. Set the air loop unitary system flag.
AirLoopControlInfo(AirLoopNum)%CycFanSchedPtr = MSHeatPump(MSHeatPumpNum)%FanSchedPtr
AirLoopControlInfo(AirLoopNum)%UnitarySys = .TRUE.
AirLoopControlInfo(AirLoopNum)%FanOpMode = MSHeatPump(MSHeatPumpNum)%OpMode
END IF
IF (ALLOCATED(ZoneEquipConfig) .AND. MyCheckFlag(MSHeatPumpNum)) THEN
DO i=1,NumOfZones
IF (AirLoopNum .NE. ZoneEquipConfig(i)%AirLoopNum) CYCLE
IF (MSHeatPump(MSHeatPumpNum)%ControlZoneNum .EQ. ZoneEquipConfig(i)%ActualZoneNum) Then
Do j=1, ZoneEquipConfig(i)%NumInletNodes
If (MSHeatPump(MSHeatPumpNum)%ZoneInletNode .EQ. 0) Then
Do k=1,ZoneEquipConfig(i)%NumInletNodes
If (ZoneEquipConfig(i)%InletNode(j) .EQ. ZoneEquipConfig(i)%AirDistUnitCool(k)%OutNode) Then
MSHeatPump(MSHeatPumpNum)%ZoneInletNode = ZoneEquipConfig(i)%InletNode(j)
Exit
End If
end do
End If
If (MSHeatPump(MSHeatPumpNum)%ZoneInletNode .EQ. 0) Then
Do k=1,ZoneEquipConfig(i)%NumInletNodes
If (ZoneEquipConfig(i)%InletNode(j) .EQ. ZoneEquipConfig(i)%AirDistUnitHeat(k)%OutNode) Then
MSHeatPump(MSHeatPumpNum)%ZoneInletNode = ZoneEquipConfig(i)%InletNode(j)
Exit
End If
End do
End If
End Do
!setup furnace zone equipment sequence information based on finding an air terminal
IF (ZoneEquipConfig(i)%EquipListIndex > 0) THEN
DO EquipNum = 1, ZoneEquipList(ZoneEquipConfig(i)%EquipListIndex)%NumOfEquipTypes
IF ((ZoneEquipList(ZoneEquipConfig(i)%EquipListIndex)%EquipType_Num(EquipNum) == AirDistUnit_Num) &
.OR. (ZoneEquipList(ZoneEquipConfig(i)%EquipListIndex)%EquipType_Num(EquipNum) == DirectAir_Num) ) THEN
MSHeatPump(MSHeatPumpNum)%ZoneSequenceCoolingNum = &
ZoneEquipList(ZoneEquipConfig(i)%EquipListIndex)%CoolingPriority(EquipNum)
MSHeatPump(MSHeatPumpNum)%ZoneSequenceHeatingNum = &
ZoneEquipList(ZoneEquipConfig(i)%EquipListIndex)%HeatingPriority(EquipNum)
ENDIF
ENDDO
ENDIF
END IF
END DO
MyCheckFlag(MSHeatPumpNum) = .FALSE.
If (MSHeatPump(MSHeatPumpNum)%ZoneInletNode .EQ. 0) Then
CALL ShowSevereError('AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed'//', "'//TRIM(MSHeatPump(MSHeatPumpNum)%Name)// &
'", The zone inlet node in the controlled zone (' &
//Trim(MSHeatPump(MSHeatPumpNum)%ControlZoneName) //') is not found.')
CALL ShowFatalError('Subroutine InitMSHeatPump: Errors found in getting '// &
'AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed'//' input. '//'Preceding condition(s) causes termination.')
End If
END IF
! Find the number of zones (zone Inlet Nodes) attached to an air loop from the air loop number
NumAirLoopZones = AirToZoneNodeInfo(AirLoopNum)%NumZonesCooled + AirToZoneNodeInfo(AirLoopNum)%NumZonesHeated
IF (ALLOCATED(AirToZoneNodeInfo) .AND. MyFlowFracFlag(MSHeatPumpNum)) THEN
FlowFracFlagReady = .TRUE.
ZonesLoop: DO ZoneInSysIndex = 1, NumAirLoopZones
! zone inlet nodes for cooling
IF (AirToZoneNodeInfo(AirLoopNum)%NumZonesCooled > 0) THEN
IF( AirToZoneNodeInfo(AirLoopNum)%TermUnitCoolInletNodes(ZoneInSysIndex) == -999 )THEN
! the data structure for the zones inlet nodes has not been filled
FlowFracFlagReady = .FALSE.
ENDIF
ENDIF
! zone inlet nodes for heating
IF (AirToZoneNodeInfo(AirLoopNum)%NumZonesHeated > 0) THEN
IF( AirToZoneNodeInfo(AirLoopNum)%TermUnitHeatInletNodes(ZoneInSysIndex) == -999 ) THEN
! the data structure for the zones inlet nodes has not been filled
FlowFracFlagReady = .FALSE.
ENDIF
ENDIF
END DO ZonesLoop
ENDIF
IF (ALLOCATED(AirToZoneNodeInfo) .AND. FlowFracFlagReady ) THEN
SumOfMassFlowRateMax = 0.0d0 ! initialize the sum of the maximum flows
DO ZoneInSysIndex = 1, NumAirLoopZones
ZoneInletNodeNum = AirToZoneNodeInfo(AirLoopNum)%TermUnitCoolInletNodes(ZoneInSysIndex)
SumOfMassFlowRateMax = SumOfMassFlowRateMax + Node(ZoneInletNodeNum)%MassFlowRateMax
IF(AirToZoneNodeInfo(AirLoopNum)%CoolCtrlZoneNums(ZoneInSysIndex) == MSHeatPump(MSHeatPumpNum)%ControlZoneNum )THEN
CntrlZoneTerminalUnitMassFlowRateMax = Node(ZoneInletNodeNum)%MassFlowRateMax
ENDIF
END DO
IF (SumOfMassFlowRateMax /= 0.0d0 .AND. MyFlowFracFlag(MSHeatPumpNum)) THEN
IF (CntrlZoneTerminalUnitMassFlowRateMax >= SmallAirVolFlow ) THEN
MSHeatPump(MSHeatPumpNum)%FlowFraction = CntrlZoneTerminalUnitMassFlowRateMax/SumOfMassFlowRateMax
ELSE
CALL ShowSevereError(TRIM(CurrentModuleObject)//' = '//TRIM(MSHeatPump(MSHeatPumpNum)%Name))
CALL ShowContinueError(' The Fraction of Supply Air Flow That Goes Through the Controlling Zone is set to 1.')
END IF
CALL ReportSizingOutput(TRIM(CurrentModuleObject), MSHeatPump(MSHeatPumpNum)%Name, &
'Fraction of Supply Air Flow That Goes Through the Controlling Zone', &
MSHeatPump(MSHeatPumpNum)%FlowFraction)
MyFlowFracFlag(MSHeatPumpNum) = .FALSE.
ENDIF
ENDIF
! Do the Begin Environment initializations
IF (BeginEnvrnFlag .and. MyEnvrnFlag(MSHeatPumpNum)) THEN
RhoAir = StdRhoAir
! set the mass flow rates from the input volume flow rates
Do i=1,NumOfSpeedCooling
MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(i) = RhoAir*MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(i)
End Do
Do i=1,NumOfSpeedHeating
MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(i) = RhoAir*MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(i)
End Do
MSHeatPump(MSHeatPumpNum)%IdleMassFlowRate = RhoAir*MSHeatPump(MSHeatPumpNum)%IdleVolumeAirRate
! set the node max and min mass flow rates
Node(InNode)%MassFlowRateMax = MAX(MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(NumOfSpeedCooling), &
MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(NumOfSpeedHeating))
Node(InNode)%MassFlowRateMaxAvail = MAX(MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(NumOfSpeedCooling), &
MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(NumOfSpeedHeating))
Node(InNode)%MassFlowRateMin = 0.0d0
Node(InNode)%MassFlowRateMinAvail = 0.0d0
Node(OutNode) = Node(InNode)
MSHeatPump(MSHeatPumpNum)%LoadLoss = 0.0d0
IF ((MSHeatPump(MSHeatPumpNum)%HeatRecActive) .AND. (.NOT. MyPlantScantFlag(MSHeatPumpNum)) ) THEN
rho = GetDensityGlycol(PlantLoop(MSHeatPump(MSHeatPumpNum)%HRLoopNum)%FluidName, &
60.d0, &
PlantLoop(MSHeatPump(MSHeatPumpNum)%HRLoopNum)%FluidIndex, &
'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%DesignHeatRecMassFlowRate = MSHeatPump(MSHeatPumpNum)%DesignHeatRecFlowRate * rho
CALL InitComponentNodes(0.d0, MSHeatPump(MSHeatPumpNum)%DesignHeatRecMassFlowRate, &
MSHeatPump(MSHeatPumpNum)%HeatRecInletNodeNum, &
MSHeatPump(MSHeatPumpNum)%HeatRecOutletNodeNum, &
MSHeatPump(MSHeatPumpNum)%HRLoopNum, &
MSHeatPump(MSHeatPumpNum)%HRLoopSideNum, &
MSHeatPump(MSHeatPumpNum)%HRBranchNum, &
MSHeatPump(MSHeatPumpNum)%HRCompNum )
ENDIF
IF(MSHeatPump(MSHeatPumpNum)%CoilControlNode .GT. 0)THEN
IF(MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow .EQ. Autosize)THEN
IF (MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingWater) THEN
CALL SimulateWaterCoilComponents(MSHeatPump(MSHeatPumpNum)%HeatCoilName,FirstHVACIteration, &
MSHeatPump(MSHeatPumpNum)%HeatCoilNum)
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
MSHeatPump(MSHeatPumpNum)%HeatCoilName,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
rho = GetDensityGlycol(PlantLoop(MSHeatPump(MSHeatPumpNum)%LoopNum)%fluidName, &
InitConvTemp, &
PlantLoop(MSHeatPump(MSHeatPumpNum)%LoopNum)%fluidIndex, &
'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow = CoilMaxVolFlowRate * rho
ENDIF
Call InitComponentNodes(0.d0, MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow, &
MSHeatPump(MSHeatPumpNum)%CoilControlNode, &
MSHeatPump(MSHeatPumpNum)%CoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%LoopNum, &
MSHeatPump(MSHeatPumpNum)%LoopSide, &
MSHeatPump(MSHeatPumpNum)%BranchNum, &
MSHeatPump(MSHeatPumpNum)%CompNum )
ENDIF
IF (MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingSteam) THEN
CALL SimulateSteamCoilComponents(MSHeatPump(MSHeatPumpNum)%HeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
MSHeatPump(MSHeatPumpNum)%HeatCoilNum, QActual)
CoilMaxVolFlowRate = GetCoilMaxSteamFlowRate(MSHeatPump(MSHeatPumpNum)%HeatCoilNum,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity
ENDIF
CALL InitComponentNodes(0.d0, MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow, &
MSHeatPump(MSHeatPumpNum)%CoilControlNode, &
MSHeatPump(MSHeatPumpNum)%CoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%LoopNum, &
MSHeatPump(MSHeatPumpNum)%LoopSide, &
MSHeatPump(MSHeatPumpNum)%BranchNum, &
MSHeatPump(MSHeatPumpNum)%CompNum )
ENDIF
ENDIF
ENDIF
IF(MSHeatPump(MSHeatPumpNum)%SuppCoilControlNode .GT. 0)THEN
IF(MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow .EQ. Autosize)THEN
IF (MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingWater) THEN
CALL SimulateWaterCoilComponents(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName,FirstHVACIteration, &
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilNum)
CoilMaxVolFlowRate = GetCoilMaxWaterFlowRate('Coil:Heating:Water', &
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
rho = GetDensityGlycol(PlantLoop(MSHeatPump(MSHeatPumpNum)%SuppLoopNum)%fluidName, &
InitConvTemp, &
PlantLoop(MSHeatPump(MSHeatPumpNum)%SuppLoopNum)%fluidIndex, &
'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow = CoilMaxVolFlowRate * rho
ENDIF
Call InitComponentNodes(0.d0, MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow, &
MSHeatPump(MSHeatPumpNum)%SuppCoilControlNode, &
MSHeatPump(MSHeatPumpNum)%SuppCoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%SuppLoopNum, &
MSHeatPump(MSHeatPumpNum)%SuppLoopSide, &
MSHeatPump(MSHeatPumpNum)%SuppBranchNum, &
MSHeatPump(MSHeatPumpNum)%SuppCompNum )
ENDIF
IF (MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingSteam) THEN
CALL SimulateSteamCoilComponents(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilNum, QActual)
CoilMaxVolFlowRate = GetCoilMaxSteamFlowRate(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilNum,ErrorsFound)
IF(CoilMaxVolFlowRate .NE. Autosize) THEN
SteamIndex = 0 ! Function GetSatDensityRefrig will look up steam index if 0 is passed
SteamDensity=GetSatDensityRefrig('STEAM',TempSteamIn,1.0d0,SteamIndex,'InitMSHeatPump')
MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity
ENDIF
CALL InitComponentNodes(0.d0, MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow, &
MSHeatPump(MSHeatPumpNum)%SuppCoilControlNode, &
MSHeatPump(MSHeatPumpNum)%SuppCoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%SuppLoopNum, &
MSHeatPump(MSHeatPumpNum)%SuppLoopSide, &
MSHeatPump(MSHeatPumpNum)%SuppBranchNum, &
MSHeatPump(MSHeatPumpNum)%SuppCompNum )
ENDIF
ENDIF
ENDIF
MyEnvrnFlag(MSHeatPumpNum) = .FALSE.
END IF ! end one time inits
IF (.NOT. BeginEnvrnFlag) THEN
MyEnvrnFlag(MSHeatPumpNum) = .TRUE.
END IF
! IF MSHP system was not autosized and the fan is autosized, check that fan volumetric flow rate is greater than MSHP flow rates
IF(.NOT. DoingSizing .AND. MSHeatPump(MSHeatPumpNum)%CheckFanFlow)THEN
CurrentModuleObject = 'AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed'
CALL GetFanVolFlow(MSHeatPump(MSHeatPumpNum)%FanNum,MSHeatPump(MSHeatPumpNum)%FanVolFlow)
IF(MSHeatPump(MSHeatPumpNum)%FanVolFlow .NE. AutoSize)THEN
! Check fan versus system supply air flow rates
IF(MSHeatPump(MSHeatPumpNum)%FanVolFlow .LT. &
MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(NumOfSpeedCooling))THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(MSHeatPump(MSHeatPumpNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(MSHeatPump(MSHeatPumpNum)%FanName)//' is less than the MSHP system air flow rate' &
//' when cooling is required ('// &
TRIM(TrimSigDigits(MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(NumOfSpeedCooling),7))//').')
CALL ShowContinueError(' The MSHP system flow rate when cooling is required is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in '//TRIM(CurrentModuleObject)//' = '//TRIM(MSHeatPump(MSHeatPumpNum)%Name))
MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(NumOfSpeedCooling) = MSHeatPump(MSHeatPumpNum)%FanVolFlow
! Check flow rates in other speeds and ensure flow rates are not above the max flow rate
Do i=NumOfSpeedCooling-1,1,-1
If (MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(i) .GT. MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(i+1)) Then
CALL ShowContinueError(' The MSHP system flow rate when cooling is required is reset to the' &
//' flow rate at higher speed and the simulation continues at Speed'//TrimSigDigits(i,0)//'.')
CALL ShowContinueError(' Occurs in '//TRIM(CurrentModuleObject)//' = '//TRIM(MSHeatPump(MSHeatPumpNum)%Name))
MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(i) = MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(i+1)
End If
End Do
END IF
IF(MSHeatPump(MSHeatPumpNum)%FanVolFlow .LT. &
MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(NumOfSpeedHeating))THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(MSHeatPump(MSHeatPumpNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(MSHeatPump(MSHeatPumpNum)%FanName)//' is less than the MSHP system air flow rate' &
//' when heating is required ('// &
TRIM(TrimSigDigits(MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(NumOfSpeedHeating),7))//').')
CALL ShowContinueError(' The MSHP system flow rate when heating is required is reset to the' &
//' fan flow rate and the simulation continues.')
CALL ShowContinueError(' Occurs in '//TRIM(CurrentModuleObject)//' = '//TRIM(MSHeatPump(MSHeatPumpNum)%Name))
MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(NumOfSpeedHeating) = MSHeatPump(MSHeatPumpNum)%FanVolFlow
Do i=NumOfSpeedHeating-1,1,-1
If (MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(i) .GT. MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(i+1)) Then
CALL ShowContinueError(' The MSHP system flow rate when heating is required is reset to the' &
//' flow rate at higher speed and the simulation continues at Speed'//TrimSigDigits(i,0)//'.')
CALL ShowContinueError(' Occurs in '//TRIM(CurrentModuleObject)//' system = '//TRIM(MSHeatPump(MSHeatPumpNum)%Name))
MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(i) = MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(i+1)
End If
End Do
END IF
IF(MSHeatPump(MSHeatPumpNum)%FanVolFlow .LT. MSHeatPump(MSHeatPumpNum)%IdleVolumeAirRate .AND. &
MSHeatPump(MSHeatPumpNum)%IdleVolumeAirRate .NE. 0.0d0)THEN
CALL ShowWarningError(TRIM(CurrentModuleObject)//' - air flow rate = ' &
//TRIM(TrimSigDigits(MSHeatPump(MSHeatPumpNum)%FanVolFlow,7))//' in fan object ' &
//TRIM(MSHeatPump(MSHeatPumpNum)%FanName)//' is less than the MSHP system air flow rate when no ' &
//'heating or cooling is needed ('//TRIM(TrimSigDigits(MSHeatPump(MSHeatPumpNum)%IdleVolumeAirRate,7))//').')
CALL ShowContinueError(' The MSHP 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 '//TRIM(CurrentModuleObject)//' = '//TRIM(MSHeatPump(MSHeatPumpNum)%Name))
MSHeatPump(MSHeatPumpNum)%IdleVolumeAirRate = MSHeatPump(MSHeatPumpNum)%FanVolFlow
END IF
RhoAir = StdRhoAir
! set the mass flow rates from the reset volume flow rates
Do I=1,NumOfSpeedCooling
MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(i) = RhoAir*MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(i)
IF(MSHeatPump(MSHeatPumpNum)%FanVolFlow .GT. 0.0d0)THEN
MSHeatPump(MSHeatPumpNum)%CoolingSpeedRatio(i) = &
MSHeatPump(MSHeatPumpNum)%CoolVolumeFlowRate(i)/MSHeatPump(MSHeatPumpNum)%FanVolFlow
END IF
End Do
Do I=1,NumOfSpeedHeating
MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(i) = RhoAir*MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(i)
IF(MSHeatPump(MSHeatPumpNum)%FanVolFlow .GT. 0.0d0)THEN
MSHeatPump(MSHeatPumpNum)%HeatingSpeedRatio(i) = &
MSHeatPump(MSHeatPumpNum)%HeatVolumeFlowRate(i)/MSHeatPump(MSHeatPumpNum)%FanVolFlow
END IF
End Do
MSHeatPump(MSHeatPumpNum)%IdleMassFlowRate = RhoAir*MSHeatPump(MSHeatPumpNum)%IdleVolumeAirRate
IF(MSHeatPump(MSHeatPumpNum)%FanVolFlow .GT. 0.0d0)THEN
MSHeatPump(MSHeatPumpNum)%IdleSpeedRatio = &
MSHeatPump(MSHeatPumpNum)%IdleVolumeAirRate / MSHeatPump(MSHeatPumpNum)%FanVolFlow
END IF
! set the node max and min mass flow rates based on reset volume flow rates
Node(InNode)%MassFlowRateMax = MAX(MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(NumOfSpeedCooling), &
MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(NumOfSpeedHeating))
Node(InNode)%MassFlowRateMaxAvail = MAX(MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(NumOfSpeedCooling), &
MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(NumOfSpeedHeating))
Node(InNode)%MassFlowRateMin = 0.0d0
Node(InNode)%MassFlowRateMinAvail = 0.0d0
Node(OutNode) = Node(InNode)
MSHeatPump(MSHeatPumpNum)%CheckFanFlow = .FALSE.
END IF
END IF
IF(MSHeatPump(MSHeatPumpNum)%FanSchedPtr .GT. 0)THEN
IF(GetCurrentScheduleValue(MSHeatPump(MSHeatPumpNum)%FanSchedPtr) .EQ. 0.0d0)THEN
MSHeatPump(MSHeatPumpNum)%OpMode = CycFanCycCoil
ELSE
MSHeatPump(MSHeatPumpNum)%OpMode = ContFanCycCoil
END IF
END IF
! Calcuate air distribution losses
IF (.NOT. FirstHVACIteration .AND. AirLoopPass .eq. 1) Then
ZoneInNode = MSHeatPump(MSHeatPumpNum)%ZoneInletNode
MinHumRat = Node(ZoneInNode)%HumRat
IF(Node(OutNode)%Temp .LT. Node(MSHeatPump(MSHeatPumpNum)%NodeNumofControlledZone)%Temp ) &
MinHumRat = Node(OutNode)%HumRat
DeltaMassRate = Node(OutNode)%MassFlowrate-Node(ZoneInNode)%MassFlowrate/MSHeatPump(MSHeatPumpNum)%FlowFraction
If (DeltaMassRate .LT. 0.0d0) DeltaMassRate = 0.0d0
MSHeatPump(MSHeatPumpNum)%LoadLoss = Node(ZoneInNode)%MassFlowrate/MSHeatPump(MSHeatPumpNum)%FlowFraction * &
(PsyHFnTdbW(Node(OutNode)%Temp,MinHumRat) - PsyHFnTdbW(Node(ZoneInNode)%Temp,MinHumRat)) + DeltaMassRate * &
(PsyHFnTdbW(Node(OutNode)%Temp,MinHumRat) - &
PsyHFnTdbW(Node(MSHeatPump(MSHeatPumpNum)%NodeNumofControlledZone)%Temp,MinHumRat))
If (ABS(MSHeatPump(MSHeatPumpNum)%LoadLoss) .LT. 1.0d-6) MSHeatPump(MSHeatPumpNum)%LoadLoss = 0.0d0
End If
! Returns load only for zones requesting cooling (heating). If in deadband, Qzoneload = 0.
ZoneNum = MSHeatPump(MSHeatPumpNum)%ControlZoneNum
IF ((MSHeatPump(MSHeatPumpNum)%ZoneSequenceCoolingNum > 0) .and. (MSHeatPump(MSHeatPumpNum)%ZoneSequenceHeatingNum > 0)) THEN
ZoneLoadToCoolSPSequenced = ZoneSysEnergyDemand(MSHeatPump(MSHeatPumpNum)%ControlZoneNum)%&
SequencedOutputRequiredToCoolingSP(MSHeatPump(MSHeatPumpNum)%ZoneSequenceCoolingNum)
ZoneLoadToHeatSPSequenced = ZoneSysEnergyDemand(MSHeatPump(MSHeatPumpNum)%ControlZoneNum)%&
SequencedOutputRequiredToHeatingSP(MSHeatPump(MSHeatPumpNum)%ZoneSequenceHeatingNum)
IF (ZoneLoadToHeatSPSequenced > SmallLoad .AND. ZoneLoadToCoolSPSequenced > SmallLoad) THEN
QZnReq = ZoneLoadToHeatSPSequenced
ELSEIF (ZoneLoadToHeatSPSequenced < (-1.d0*SmallLoad) .AND. ZoneLoadToCoolSPSequenced < (-1.d0*SmallLoad)) THEN
QZnReq = ZoneLoadToCoolSPSequenced
ELSEIF (ZoneLoadToHeatSPSequenced <= (-1.d0*SmallLoad) .AND. ZoneLoadToCoolSPSequenced >= SmallLoad) THEN
QZnReq = 0.d0
ENDIF
QZnReq = QZnReq/MSHeatPump(MSHeatPumpNum)%FlowFraction
ELSE
QZnReq = ZoneSysEnergyDemand(ZoneNum)%RemainingOutputRequired/MSHeatPump(MSHeatPumpNum)%FlowFraction
ENDIF
If (CurDeadbandOrSetback(ZoneNum)) QZnReq = 0.0d0
If (QZnReq > SmallLoad) then
MSHeatPump(MSHeatPumpNum)%HeatCoolMode = HeatingMode
Else If (QZnReq < (-1.d0*SmallLoad)) then
MSHeatPump(MSHeatPumpNum)%HeatCoolMode = CoolingMode
Else
MSHeatPump(MSHeatPumpNum)%HeatCoolMode = 0
End If
! Determine the staged status
If (ALLOCATED(StageZoneLogic)) Then
If (StageZoneLogic(ZoneNum)) Then
MSHeatPump(MSHeatPumpNum)%Staged = .TRUE.
MSHeatPump(MSHeatPumpNum)%StageNum = ZoneSysEnergyDemand(ZoneNum)%StageNum
Else
If (MyStagedFlag(MSHeatPumpNum)) Then
CALL ShowWarningError('ZoneControl:Thermostat:StagedDualSetpoint is found, but is not applied to '// &
'this AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed object = ')
CALL ShowContinueError(Trim(MSHeatPump(MSHeatPumpNum)%Name) //'. Please make correction. Simulation continues...')
MyStagedFlag(MSHeatPumpNum) = .FALSE.
End If
End If
End If
! Set the inlet node mass flow rate
IF (MSHeatPump(MSHeatPumpNum)%OpMode .EQ. ContFanCycCoil) THEN
! constant fan mode
IF (QZnReq > SmallLoad .AND. .NOT. CurDeadbandOrSetback(ZoneNum)) THEN
CompOnMassFlow = MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(1)
CompOnFlowRatio = MSHeatPump(MSHeatPumpNum)%HeatingSpeedRatio(1)
MSHeatPump(MSHeatPumpNum)%LastMode = HeatingMode
ELSE IF (QZnReq < (-1.d0*SmallLoad) .AND. .NOT. CurDeadbandOrSetback(ZoneNum)) THEN
CompOnMassFlow = MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(1)
CompOnFlowRatio = MSHeatPump(MSHeatPumpNum)%CoolingSpeedRatio(1)
MSHeatPump(MSHeatPumpNum)%LastMode = CoolingMode
ELSE
CompOnMassFlow = MSHeatPump(MSHeatPumpNum)%IdleMassFlowRate
CompOnFlowRatio = MSHeatPump(MSHeatPumpNum)%IdleSpeedRatio
END IF
CompOffMassFlow = MSHeatPump(MSHeatPumpNum)%IdleMassFlowRate
CompOffFlowRatio = MSHeatPump(MSHeatPumpNum)%IdleSpeedRatio
ELSE
! cycling fan mode
IF (QZnReq > SmallLoad .AND. .NOT. CurDeadbandOrSetback(ZoneNum)) THEN
CompOnMassFlow = MSHeatPump(MSHeatPumpNum)%HeatMassFlowRate(1)
CompOnFlowRatio = MSHeatPump(MSHeatPumpNum)%HeatingSpeedRatio(1)
ELSE IF (QZnReq < (-1.d0*SmallLoad) .AND. .NOT. CurDeadbandOrSetback(ZoneNum)) THEN
CompOnMassFlow = MSHeatPump(MSHeatPumpNum)%CoolMassFlowRate(1)
CompOnFlowRatio = MSHeatPump(MSHeatPumpNum)%CoolingSpeedRatio(1)
ELSE
CompOnMassFlow = 0.0d0
CompOnFlowRatio = 0.0d0
END IF
CompOffMassFlow = 0.0d0
CompOffFlowRatio = 0.0d0
END IF
! Set the inlet node mass flow rate
IF (GetCurrentScheduleValue(MSHeatPump(MSHeatPumpNum)%AvaiSchedPtr) .gt. 0.0d0 .AND. CompOnMassFlow .NE. 0.0d0) THEN
OnOffAirFlowRatio = 1.0d0
IF(FirstHVACIteration)THEN
Node(MSHeatPump(MSHeatPumpNum)%AirInletNodeNum)%MassFlowRate = CompOnMassFlow
PartLoadFrac = 0.0d0
ELSE
IF (MSHeatPump(MSHeatPumpNum)%HeatCoolMode /= 0) THEN
PartLoadFrac = 1.0d0
ELSE
PartLoadFrac = 0.0d0
END IF
END IF
ELSE
PartLoadFrac = 0.0d0
Node(InNode)%MassFlowRate = 0.0d0
Node(OutNode)%MassFlowRate = 0.0d0
Node(OutNode)%MassFlowRateMaxAvail = 0.0d0
OnOffAirFlowRatio = 1.0d0
END IF
! Check availability of DX coils
IF (GetCurrentScheduleValue(MSHeatPump(MSHeatPumpNum)%AvaiSchedPtr) .gt. 0.0d0) Then
If (MSHeatPump(MSHeatPumpNum)%HeatCoolMode == CoolingMode) Then
CoilAvailSchPtr=GetDXCoilAvailSchPtr('Coil:Cooling:DX:MultiSpeed',MSHeatPump(MSHeatPumpNum)%DXCoolCoilName, &
ErrorsFound,MSHeatPump(MSHeatPumpNum)%DXCoolCoilIndex)
If (ErrorsFound) Then
CALL ShowFatalError('InitMSHeatPump, The previous error causes termination.')
End If
IF (GetCurrentScheduleValue(CoilAvailSchPtr) .EQ. 0.d0) Then
If (MSHeatPump(MSHeatPumpNum)%CoolCountAvail .eq. 0) THEN
MSHeatPump(MSHeatPumpNum)%CoolCountAvail = MSHeatPump(MSHeatPumpNum)%CoolCountAvail+1
CALL ShowWarningError(Trim(MSHeatPump(MSHeatPumpNum)%Name) //' is ready to perform cooling, but its DX cooling coil = ' &
//TRIM(MSHeatPump(MSHeatPumpNum)%DXCoolCoilName)//' is not available at Available Schedule = ' &
//Trim(GetScheduleName(CoilAvailSchPtr))//'.')
CALL ShowContinueErrorTimeStamp('Availability schedule returned=' &
//RoundSigDigits(GetCurrentScheduleValue(CoilAvailSchPtr),1))
Else
MSHeatPump(MSHeatPumpNum)%CoolCountAvail = MSHeatPump(MSHeatPumpNum)%CoolCountAvail+1
CALL ShowRecurringWarningErrorAtEnd(TRIM(MSHeatPump(MSHeatPumpNum)%Name)//':'//&
' Cooling coil is still not available ...',MSHeatPump(MSHeatPumpNum)%CoolIndexAvail &
, GetCurrentScheduleValue(CoilAvailSchPtr), GetCurrentScheduleValue(CoilAvailSchPtr))
End If
End If
End If
If (MSHeatPump(MSHeatPumpNum)%HeatCoolMode == HeatingMode .AND. &
MSHeatPump(MSHeatPumpNum)%HeatCoilType == MultiSpeedHeatingCoil) Then
CoilAvailSchPtr=GetDXCoilAvailSchPtr('Coil:Heating:DX:MultiSpeed',MSHeatPump(MSHeatPumpNum)%DXHeatCoilName, &
ErrorsFound,MSHeatPump(MSHeatPumpNum)%DXHeatCoilIndex)
If (ErrorsFound) Then
CALL ShowFatalError('InitMSHeatPump, The previous error causes termination.')
End If
IF (GetCurrentScheduleValue(CoilAvailSchPtr) .EQ. 0.d0) Then
IF (MSHeatPump(MSHeatPumpNum)%HeatCountAvail .eq. 0) THEN
MSHeatPump(MSHeatPumpNum)%HeatCountAvail = MSHeatPump(MSHeatPumpNum)%HeatCountAvail+1
CALL ShowWarningError(Trim(MSHeatPump(MSHeatPumpNum)%Name) //' is ready to perform heating, but its DX heating coil = ' &
//TRIM(MSHeatPump(MSHeatPumpNum)%DXCoolCoilName)//' is not available at Available Schedule = ' &
//Trim(GetScheduleName(CoilAvailSchPtr))//'.')
CALL ShowContinueErrorTimeStamp('Availability schedule returned=' &
//RoundSigDigits(GetCurrentScheduleValue(CoilAvailSchPtr),1))
Else
MSHeatPump(MSHeatPumpNum)%HeatCountAvail = MSHeatPump(MSHeatPumpNum)%HeatCountAvail+1
CALL ShowRecurringWarningErrorAtEnd(TRIM(MSHeatPump(MSHeatPumpNum)%Name)//':'//&
' Heating coil is still not available ...',MSHeatPump(MSHeatPumpNum)%HeatIndexAvail &
, GetCurrentScheduleValue(CoilAvailSchPtr), GetCurrentScheduleValue(CoilAvailSchPtr))
End If
End If
End If
End If
MSHeatPumpReport(MSHeatPumpNum)%CycRatio = 0.0d0
MSHeatPumpReport(MSHeatPumpNum)%SpeedRatio = 0.0d0
MSHeatPumpReport(MSHeatPumpNum)%SpeedNum = 0
CALL CalcMSHeatPump(MSHeatPumpNum,FirstHVACIteration,On,1,0.0d0,PartLoadFrac,QSensUnitOut, &
QZnReq,OnOffAirFlowRatio,SupHeaterLoad)
! If unit is scheduled OFF, setpoint is equal to inlet node temperature.
MSHeatPump%TotHeatEnergyRate = 0.0d0
MSHeatPump%SensHeatEnergyRate = 0.0d0
MSHeatPump%LatHeatEnergyRate = 0.0d0
MSHeatPump%TotCoolEnergyRate = 0.0d0
MSHeatPump%SensCoolEnergyRate = 0.0d0
MSHeatPump%LatCoolEnergyRate = 0.0d0
!!!LKL Discrepancy with < 0
IF (GetCurrentScheduleValue(MSHeatPump(MSHeatPumpNum)%AvaiSchedPtr) .EQ. 0.0d0) THEN
Node(OutNode)%Temp = Node(InNode)%Temp
RETURN
END IF
IF(MSHeatPump(MSHeatPumpNum)%HeatCoolMode == 0 .AND. MSHeatPump(MSHeatPumpNum)%OpMode == CycFanCycCoil .OR. &
CompOnMassFlow .EQ. 0.0d0)THEN
QZnReq = 0.0d0
PartLoadFrac = 0.0d0
Node(InNode)%MassFlowRate = 0.0d0
Node(OutNode)%MassFlowRateMaxAvail = 0.0d0
END IF
MSHeatPump(MSHeatPumpNum)%LoadMet = 0.0d0
CALL SetAverageAirFlow(MSHeatPumpNum, PartLoadFrac, OnOffAirFlowRatio)
!Init maximum available Heat Recovery flow rate
IF ((MSHeatPump(MSHeatPumpNum)%HeatRecActive) .AND. (.NOT. MyPlantScantFlag(MSHeatPumpNum)) ) THEN
IF (PartLoadFrac > 0.d0) THEN
IF (FirstHVACIteration) THEN
MdotHR = MSHeatPump(MSHeatPumpNum)%DesignHeatRecMassFlowRate
ELSE
IF (MSHeatPump(MSHeatPumpNum)%HeatRecoveryMassFlowRate > 0.d0) THEN
MdotHR = MSHeatPump(MSHeatPumpNum)%HeatRecoveryMassFlowRate
ELSE
MdotHR = MSHeatPump(MSHeatPumpNum)%DesignHeatRecMassFlowRate
ENDIF
ENDIF
ELSE
MdotHR = 0.d0
ENDIF
CALL SetComponentFlowRate(MdotHR, &
MSHeatPump(MSHeatPumpNum)%HeatRecInletNodeNum, &
MSHeatPump(MSHeatPumpNum)%HeatRecOutletNodeNum, &
MSHeatPump(MSHeatPumpNum)%HRLoopNum, &
MSHeatPump(MSHeatPumpNum)%HRLoopSideNum, &
MSHeatPump(MSHeatPumpNum)%HRBranchNum, &
MSHeatPump(MSHeatPumpNum)%HRCompNum )
ENDIF
! get operating capacity of water and steam coil
IF(FirstHVACIteration) THEN
IF(MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingWater) THEN
! set air-side and steam-side mass flow rates
Node(MSHeatPump(MSHeatPumpNum)%CoilAirInletNode)%MassFlowRate = CompOnMassFlow
mdot = MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow
CALL SetComponentFlowRate(mdot, &
MSHeatPump(MSHeatPumpNum)%CoilControlNode, &
MSHeatPump(MSHeatPumpNum)%CoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%LoopNum, &
MSHeatPump(MSHeatPumpNum)%LoopSide, &
MSHeatPump(MSHeatPumpNum)%BranchNum, &
MSHeatPump(MSHeatPumpNum)%CompNum )
! simulate water coil to find operating capacity
CALL SimulateWaterCoilComponents(MSHeatPump(MSHeatPumpNum)%HeatCoilName,FirstHVACIteration, &
MSHeatPump(MSHeatPumpNum)%HeatCoilNum, QActual)
END IF ! from IF(MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingWater) THEN
IF(MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingSteam) THEN
! set air-side and steam-side mass flow rates
Node(MSHeatPump(MSHeatPumpNum)%CoilAirInletNode)%MassFlowRate = CompOnMassFlow
mdot = MSHeatPump(MSHeatPumpNum)%MaxCoilFluidFlow
CALL SetComponentFlowRate(mdot, &
MSHeatPump(MSHeatPumpNum)%CoilControlNode, &
MSHeatPump(MSHeatPumpNum)%CoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%LoopNum, &
MSHeatPump(MSHeatPumpNum)%LoopSide, &
MSHeatPump(MSHeatPumpNum)%BranchNum, &
MSHeatPump(MSHeatPumpNum)%CompNum )
! simulate steam coil to find operating capacity
CALL SimulateSteamCoilComponents(MSHeatPump(MSHeatPumpNum)%HeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
MSHeatPump(MSHeatPumpNum)%HeatCoilNum, QActual)
END IF ! from IF(MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingSteam) THEN
IF(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingWater) THEN
! set air-side and steam-side mass flow rates
Node(MSHeatPump(MSHeatPumpNum)%SuppCoilAirInletNode)%MassFlowRate = CompOnMassFlow
mdot = MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow
CALL SetComponentFlowRate(mdot, &
MSHeatPump(MSHeatPumpNum)%SuppCoilControlNode, &
MSHeatPump(MSHeatPumpNum)%SuppCoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%SuppLoopNum, &
MSHeatPump(MSHeatPumpNum)%SuppLoopSide, &
MSHeatPump(MSHeatPumpNum)%SuppBranchNum, &
MSHeatPump(MSHeatPumpNum)%SuppCompNum )
! simulate water coil to find operating capacity
CALL SimulateWaterCoilComponents(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName,FirstHVACIteration, &
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilNum, QActual)
MSHeatPump(MSHeatPumpNum)%DesignSuppHeatingCapacity = QActual
END IF ! from IF(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingWater) THEN
IF(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingSteam) THEN
! set air-side and steam-side mass flow rates
Node(MSHeatPump(MSHeatPumpNum)%SuppCoilAirInletNode)%MassFlowRate = CompOnMassFlow
mdot = MSHeatPump(MSHeatPumpNum)%MaxSuppCoilFluidFlow
CALL SetComponentFlowRate(mdot, &
MSHeatPump(MSHeatPumpNum)%SuppCoilControlNode, &
MSHeatPump(MSHeatPumpNum)%SuppCoilOutletNode, &
MSHeatPump(MSHeatPumpNum)%SuppLoopNum, &
MSHeatPump(MSHeatPumpNum)%SuppLoopSide, &
MSHeatPump(MSHeatPumpNum)%SuppBranchNum, &
MSHeatPump(MSHeatPumpNum)%SuppCompNum )
! simulate steam coil to find operating capacity
CALL SimulateSteamCoilComponents(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName, &
FirstHVACIteration, &
1.0d0, & !QCoilReq, simulate any load > 0 to get max capacity of steam coil
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilNum, QActual)
MSHeatPump(MSHeatPumpNum)%DesignSuppHeatingCapacity = GetSteamCoilCapacity('Coil:Heating:Steam', &
MSHeatPump(MSHeatPumpNum)%SuppHeatCoilName,ErrorsFound)
END IF ! from IF(MSHeatPump(MSHeatPumpNum)%SuppHeatCoilType == Coil_HeatingSteam) THEN
END IF ! from IF( FirstHVACIteration ) THEN
RETURN
END SUBROUTINE InitMSHeatPump