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) | :: | HPNum | |||
integer | :: | CyclingScheme | ||||
logical, | intent(in) | :: | FirstHVACIteration | |||
real(kind=r64), | intent(in) | :: | RuntimeFrac | |||
logical, | intent(in) | :: | InitFlag | |||
real(kind=r64), | intent(in) | :: | SensDemand | |||
integer, | intent(in) | :: | CompOp | |||
real(kind=r64), | intent(in) | :: | PartLoadRatio |
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 CalcWatertoAirHPHeating(HPNum,CyclingScheme,FirstHVACIteration,RuntimeFrac,InitFlag, SensDemand, CompOp, PartLoadRatio)
! SUBROUTINE INFORMATION:
! AUTHOR Hui Jin
! DATE WRITTEN Oct 2000
! MODIFIED R. Raustad (Oct 2006) Revised iteration technique
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Simulates a parameter estimation based water to air heat pump model
! USE STATEMENTS:
! na
USE FluidProperties
USE Psychrometrics, ONLY:PsyCpAirFnWTdb,PsyTdbFnHW,PsyWFnTdbH !,PsyHFnTdbRhPb,PsyWFnTdpPb
! USE DataZoneEnergyDemands
USE General, ONLY: RoundSigDigits, SolveRegulaFalsi
USE InputProcessor, ONLY: SameString
USE DataPlant, ONLY: PlantLoop
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: HPNum !heat pump number
REAL(r64) , INTENT(IN) :: RuntimeFrac
REAL(r64) , INTENT(IN) :: SensDemand
INTEGER :: CyclingScheme !fan/compressor cycling scheme indicator
LOGICAL, INTENT(IN) :: FirstHVACIteration !first iteration flag
LOGICAL, INTENT(IN) :: InitFlag !first iteration flag
INTEGER, INTENT(IN) :: CompOp
REAL(r64), INTENT(IN) :: PartLoadRatio
! SUBROUTINE PARAMETER DEFINITIONS:
REAL(r64), PARAMETER :: CpWater=4210.d0 ! Specific heat of water J/kg_C
REAL(r64), PARAMETER :: DegreeofSuperheat=80.d0 ! Initial guess of degree of superheat
REAL(r64), PARAMETER :: gamma= 1.114d0 ! Expnasion Coefficient
REAL(r64), PARAMETER :: RelaxParam = .5d0 ! Relaxation Parameter
REAL(r64), PARAMETER :: ERR=0.01d0 ! Error Value
REAL(r64), PARAMETER :: ERR1=0.01d0 ! Error Value
REAL(r64), PARAMETER :: PB=1.013d5 ! Barometric Pressure (Pa)
INTEGER, PARAMETER :: STOP1=10000 ! Iteration stopper1
INTEGER, PARAMETER :: STOP2=100000 ! Iteration stopper2
INTEGER, PARAMETER :: STOP3=100000 ! Iteration stopper3
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
! INTEGER :: NumIteration1 ! Number of Iteration1
INTEGER :: NumIteration2 ! Number of Iteration2
INTEGER :: NumIteration3 ! Number of Iteration3
INTEGER :: SourceSideFluidIndex ! Source Side Fluid Index
INTEGER :: CompressorType ! Type of Compressor ie. Reciprocating,Rotary or Scroll
CHARACTER(len=MaxNameLength) :: SourceSideFluidName ! Name of source side fluid
CHARACTER(len=MaxNameLength) :: Refrigerant ! Name of refrigerant
! CHARACTER(len=25) :: CErrCount
REAL(r64) :: NominalHeatingCapacity ! Nominal Heating Capacity(W)
REAL(r64) :: LoadSideUA ! Load Side Heat Transfer coefficient [W/C]
REAL(r64) :: SourceSideUA ! Source Side Heat Transfer coefficient [W/C]
REAL(r64) :: PressureDrop ! Suction or Discharge Pressure Drop [Pa]
REAL(r64) :: ClearanceFactor ! Compressor Clearance Factor
REAL(r64) :: PistonDisp ! Compressor Piston Displacement [m3/s]
REAL(r64) :: ShTemp ! Superheat Temperature [C]
REAL(r64) :: LosFac ! Compressor Power Loss Factor
REAL(r64) :: PowerLos ! Constant Part of Power Losses [kW]
REAL(r64) :: RefVolFlowRate ! Refrigerant Volume Flow rate at the beginning
REAL(r64) :: VolumeRatio ! Built-in-volume ratio [~]
REAL(r64) :: LeakRateCoeff ! Coefficient for the relationship between
! Pressure Ratio and Leakage Rate [~]
REAL(r64) :: SourceSideHTRes1 ! Source Side Heat Transfer Resistance coefficient 1 [~]
REAL(r64) :: SourceSideHTRes2 ! Source Side Heat Transfer Resistance coefficient 2 [K/kW]
REAL(r64) :: HighPressCutOff ! High Pressure Cut-off [Pa]
REAL(r64) :: LowPressCutOff ! Low Pressure Cut-off [Pa]
REAL(r64) :: Quality
REAL(r64) :: SourceSideMassFlowRate ! Source Side Mass Flow Rate [kg/s]
REAL(r64) :: SourceSideInletTemp ! Source Side Inlet Temperature [C]
REAL(r64) :: SourceSideWaterInletEnth ! Source Side Inlet Water Enthalpy [J/kg]
REAL(r64) :: SourceSideoutletTemp ! Source Side Outlet Temperature [C]
REAL(r64) :: SourceSideVolFlowRate ! Source Side Volumetric Flow Rate [m3/s]
REAL(r64) :: CpFluid ! Specific heat of source side fluid(J/kg)
REAL(r64) :: LoadSideMassFlowRate ! Load Side Mass Flow Rate [kg/s]
REAL(r64) :: LoadSideInletDBTemp ! Load Side Inlet Dry Bulb Temp [C]
REAL(r64) :: LoadSideInletHumRat ! Load Side Inlet Humidity Ratio [kg/kg]
REAL(r64) :: LoadSideoutletDBTemp ! Load Side Outlet Dry Bulb Temperature [C]
REAL(r64) :: LoadsideOutletHumRat ! Load Side Outlet Humidity Ratio [kg/kg]
REAL(r64) :: LoadSideAirInletEnth ! Load Side Inlet Enthalpy [J/kg]
REAL(r64) :: LoadSideAirOutletEnth ! Load Side Outlet Enthalpy [J/kg]
REAL(r64) :: CpAir ! Specific Heat of Air [J/kg_C]
REAL(r64) :: DegradFactor ! Degradation Factor [~]
REAL(r64) :: QSource ! Source Side Heat Transfer Rate [W]
REAL(r64) :: QLoadTotal ! Load Side Heat Transfer Rate [W]
REAL(r64) :: Power ! Power Consumption [W]
REAL(r64) :: SourceSideEffect ! Source Side Heat Exchanger Effectiveness
REAL(r64) :: LoadSideEffect ! Load Side Effectiveness based on Outside Heat Transfer Coefficient
REAL(r64) :: SourceSideTemp ! Source Side Saturated Refrigerant Temperature [C]
REAL(r64) :: LoadSideTemp ! Load Side Saturated Refrigerant Temperature [C]
REAL(r64) :: SourceSidePressure ! Source Side Saturated Refrigerant Pressure [Pa]
REAL(r64) :: LoadSidePressure ! Load Side Saturated Refrigerant Pressure [Pa]
REAL(r64) :: SuctionPr ! Compressor Suction Pressure [Pa]
REAL(r64) :: DischargePr ! Compressor Discharge Pressure [Pa]
REAL(r64) :: CompressInletTemp ! Temperature of the Refrigerant Entering the Compressor [C]
REAL(r64) :: MassRef ! Mass Flow Rate of Refrigerant [kg/s]
REAL(r64) :: SourceSideOutletEnth ! Enthalpy of Refrigerant leaving the Source Side Heat Exchanger [J/kg]
REAL(r64) :: LoadSideOutletEnth ! Enthalpy of Refrigerant leaving the Load Side Heat Exchanger [J/kg]
REAL(r64),SAVE :: initialQSource ! Guess Source Side Heat Transfer Rate [W]
REAL(r64),SAVE :: initialQLoad ! Guess Load Side Heat Transfer rate [W]
REAL(r64) :: SuperHeatEnth ! Enthalpy of the Superheated Refrigerant [J/kg]
REAL(r64) :: CompSuctionTemp1 ! Guess of the Temperature of the Refrigerant Entering the
! Compressor #1 [C]
REAL(r64) :: CompSuctionTemp2 ! Guess of the Temperature of the Refrigerant Entering the
! Compressor #2 [C]
REAL(r64) :: CompSuctionTemp ! Temperature of the Refrigerant Entering the Compressor [C]
REAL(r64) :: CompSuctionEnth ! Enthalpy of the Refrigerant Entering the Compressor [J/kg]
REAL(r64) :: CompSuctionDensity ! Density of the Refrigerant Entering the Compressorkg/m3
REAL(r64) :: CompSuctionSatTemp ! Temperature of Saturated Refrigerant at Compressor Suction Pressure [C]
LOGICAL :: FinalSimFlag ! Final Simulation Flag
LOGICAL :: Converged ! Overall convergence Flag
REAL(r64) :: Par(4) ! Parameter array passed to RegulaFalsi function
INTEGER :: SolFlag ! Solution flag returned from RegulaFalsi function
! LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
NominalHeatingCapacity = WatertoAirHP(HPNum)%HeatingCapacity
CompressorType = WatertoAirHP(HPNum)%CompressorType
Refrigerant = WatertoAirHP(HPNum)%Refrigerant
LoadSideUA = WatertoAirHP(HPNum)%LoadSideTotalUACoeff
PistonDisp = WatertoAirHP(HPNum)%CompPistonDisp
ClearanceFactor = WatertoAirHP(HPNum)%CompClearanceFactor
PressureDrop = WatertoAirHP(HPNum)%CompSucPressDrop
ShTemp = WatertoAirHP(HPNum)%SuperheatTemp
PowerLos = WatertoAirHP(HPNum)%PowerLosses
LosFac = WatertoAirHP(HPNum)%LossFactor
RefVolFlowRate = WatertoAirHP(HPNum)%RefVolFlowRate
VolumeRatio = WatertoAirHP(HPNum)%VolumeRatio
LeakRateCoeff = WatertoAirHP(HPNum)%LeakRateCoeff
HighPressCutOff = WatertoAirHP(HPNum)%HighPressCutOff
LowPressCutOff = WatertoAirHP(HPNum)%LowPressCutOff
SourceSideUA = WatertoAirHP(HPNum)%SourceSideUACoeff
SourceSideHTRes1 = WatertoAirHP(HPNum)%SourceSideHTR1
SourceSideHTRes2 = WatertoAirHP(HPNum)%SourceSideHTR2
LoadSideMassFlowRate = WatertoAirHP(HPNum)%InletAirMassFlowRate
LoadsideInletDBTemp = WatertoAirHP(HPNum)%InletAirDBTemp
LoadsideInletHumRat = WatertoAirHP(HPNum)%InletAirHumRat
cpair = PsyCpAirFnWTdb(LoadSideInletHumRat,LoadSideInletDBTemp)
SourceSideInletTemp = WatertoAirHP(HPNum)%InletWaterTemp
SourceSideWaterInletEnth = WatertoAirHP(HPNum)%InletWaterEnthalpy
SourceSideFluidName = PlantLoop(WatertoAirHP(HPNum)%LoopNum)%FluidName
SourceSideFluidIndex = PlantLoop(WatertoAirHP(HPNum)%LoopNum)%FluidIndex
SourceSideMassFlowRate = WatertoAirHP(HPNum)%InletWaterMassFlowRate
SourceSideVolFlowRate = WatertoAirHP(HPNum)%InletWaterMassFlowRate / GetDensityGlycol(SourceSideFluidName, &
SourceSideInletTemp,SourceSideFluidIndex, &
'CalcWatertoAirHPHeating:SourceSideInletTemp')
! Load Side Inlet Air Enthalpy
LoadSideAirInletEnth=WatertoAirHP(HPNum)%InletAirEnthalpy
! If heat pump is not operating, return
IF (SensDemand == 0.0d0 .OR. LoadSideMassFlowRate <= 0.0d0 .OR. SourceSideMassFlowRate <= 0.0d0)THEN
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
ELSE
WatertoAirHP(HPNum)%SimFlag = .TRUE.
ENDIF
IF (CompOp .EQ. 0) THEN
WaterToAirHP(HPNum)%SimFlag = .FALSE.
RETURN
ENDIF
IF(FirstHVACIteration) THEN
initialQLoad = NominalHeatingCapacity
initialQSource = NominalHeatingCapacity
END IF
IF(initialQLoad==0.0d0) initialQLoad = NominalHeatingCapacity
IF(initialQSource==0.0d0) initialQSource = NominalHeatingCapacity
!Outerloop: calculate load side heat transfer
NumIteration3=0
Converged = .FALSE.
FinalSimFlag = .FALSE.
LOOPLoadEnth: DO
IF (Converged) FinalSimFlag = .TRUE.
NumIteration3=NumIteration3+1
IF (NumIteration3.GT.STOP3) THEN
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
!Innerloop: calculate load side heat transfer
NumIteration2=0
LOOPSourceEnth: DO
NumIteration2=NumIteration2+1
IF (NumIteration2.GT.STOP2) THEN
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
! Determine Effectiveness of Source Side
CpFluid=GetSpecificHeatGlycol(SourceSideFluidName,SourceSideInletTemp,SourceSideFluidIndex, &
'CalcWatertoAirHPHeating:SourceSideInletTemp')
! IF (SourceSideFluidName=='WATER') THEN
IF (SourceSideFluidIndex== WaterIndex) THEN
SourceSideEffect = 1.0d0- EXP( -SourceSideUA / (CpFluid * SourceSideMassFlowRate)) ! SourceSideFluidName=='Water'
ELSE
DegradFactor=DegradF(SourceSideFluidName,SourceSideInletTemp,SourceSideFluidIndex)
SourceSideEffect = 1 / ((SourceSideHTRes1 * SourceSideVolFlowRate**(-0.8d0)) / DegradFactor + SourceSideHTRes2)
END IF
! Determine Load Side Effectiveness
LoadSideEffect = 1.0d0- EXP( -LoadSideUA / (CpAir * LoadSideMassFlowRate))
! Determine Source Side Tempertaure (Evap. Temp for this mode)
SourceSideTemp = SourceSideInletTemp - initialQSource/(SourceSideEffect * CpFluid * SourceSideMassFlowRate)
! Determine Load Side Tempertaure (Condensing Temp for this mode)
LoadSideTemp = LoadSideInletDBTemp + initialQLoad/(LoadSideEffect * CpAir * LoadSideMassFlowRate)
! Determine the Load Side and Source Side Saturated Temp (evaporating and condensing pressures)
SourceSidePressure = GetSatPressureRefrig(Refrigerant,SourceSideTemp,RefrigIndex,'CalcWatertoAirHPHeating:SourceSideTemp')
LoadSidePressure = GetSatPressureRefrig(Refrigerant,LoadSideTemp,RefrigIndex,'CalcWatertoAirHPHeating:LoadSideTemp')
IF (SourceSidePressure < LowPressCutOff.AND. .NOT. FirstHVACIteration) THEN
IF (.not. WarmupFlag) THEN
CALL ShowRecurringWarningErrorAtEnd('WaterToAir Heat pump:heating ['//TRIM(WaterToAirHP(HPNum)%Name)// &
'] shut off on low pressure < '//TRIM(RoundSigDigits(LowPressCutoff,0)), &
WaterToAirHP(HPNum)%LowPressHtgError,SourceSidePressure,SourceSidePressure, &
ReportMinUnits='[Pa]',ReportMaxUnits='[Pa]' )
ENDIF
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
IF (LoadSidePressure > HighPressCutOff.AND. .NOT. FirstHVACIteration)THEN
IF (.not. WarmUpFlag) THEN
CALL ShowRecurringWarningErrorAtEnd('WaterToAir Heat pump:heating ['//TRIM(WaterToAirHP(HPNum)%Name)// &
'] shut off on high pressure > '//TRIM(RoundSigDigits(HighPressCutOff,0)), &
WaterToAirHP(HPNum)%HighPressHtgError,SourceSideInletTemp,SourceSideInletTemp, &
ReportMinUnits='SourceSideInletTemp[C]',ReportMaxUnits='SourceSideInletTemp[C]')
ENDIF
! CALL ShowWarningError('Heat pump:heating shut off on high pressure')
! WRITE(CErrCount,*) SourceSideInletTemp
! CErrCount=ADJUSTL(CErrCount)
! CALL ShowContinueError('Source side inlet temperature too low, T='//TRIM(CErrCount))
! CALL ShowContinueError('Heat pump heating demand not met by plant side')
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
! Determine Suction Pressure at Compressor Entrance & Discharge Pressure at Compressor Exit
SELECT CASE (CompressorType)
CASE (CompressorType_Reciprocating) ! RECIPROCATING
SuctionPr = SourceSidePressure - PressureDrop
DischargePr = LoadSidePressure + PressureDrop
CASE (CompressorType_Rotary) ! ROTARY
SuctionPr = SourceSidePressure
DischargePr = LoadSidePressure + PressureDrop
CASE (CompressorType_Scroll) ! SCROLL
SuctionPr = SourceSidePressure
DischargePr = LoadSidePressure
END SELECT
! Determine the Source Side Outlet Enthalpy
! Quality of the refrigerant leaving the evaporator is saturated gas
Quality = 1.0d0
SourceSideOutletEnth = GetSatEnthalpyRefrig(Refrigerant, SourceSideTemp, Quality, &
RefrigIndex,'CalcWatertoAirHPHeating:SourceSideTemp')
! Determine Load Side Outlet Enthalpy
! Quality of the refrigerant leaving the condenser is saturated liguid
Quality = 0.0d0
LoadSideOutletEnth = GetSatEnthalpyRefrig(Refrigerant, LoadSideTemp, Quality, &
RefrigIndex,'CalcWatertoAirHPHeating:LoadSideTemp')
! Determine Superheated Temperature of the Source Side outlet/compressor Inlet
CompressInletTemp = SourceSideTemp + ShTemp
! Determine the Enathalpy of the Superheated Fluid at Source Side Outlet/Compressor Inlet
SuperHeatEnth = GetSupHeatEnthalpyRefrig(Refrigerant, CompressInletTemp, SourceSidePressure, &
RefrigIndex,'CalcWatertoAirHPHeating:CompressInletTemp')
! Determining the suction state of the fluid from inlet state involves interation
! Method employed...
! Determine the saturated temp at suction pressure, shoot out into the superheated region find the enthalpy
! check that with the inlet enthalpy ( as suction loss is isenthalpic). Iterate till desired accuracy is reached
IF(.NOT. converged)THEN
CompSuctionSatTemp = GetSatTemperatureRefrig(Refrigerant, SuctionPr, RefrigIndex,'CalcWatertoAirHPHeating:SuctionPr')
CompSuctionTemp1 = CompSuctionSatTemp
! Shoot into the Superheated Region
CompSuctionTemp2 = CompSuctionSatTemp + DegreeofSuperheat
END IF
! ! Iterate to find the Suction State
! NumIteration1=0
!
! LOOP: DO
!
! NumIteration1=NumIteration1+1
!
! IF (NumIteration1.GT.STOP1) THEN
! WatertoAirHP(HPNum)%SimFlag = .FALSE.
! RETURN
! END IF
!
! CompSuctionTemp = 0.5d0 * ( CompSuctionTemp1 + CompSuctionTemp2 )
! CompSuctionEnth = GetSupHeatEnthalpyRefrig(Refrigerant, CompSuctionTemp, SuctionPr, RefrigIndex)
! CompSuctionDensity = GetSupHeatDensityRefrig(Refrigerant, CompSuctionTemp, SuctionPr, RefrigIndex)
!
! IF (ABS(CompsuctionEnth-SuperHeatEnth)/SuperHeatEnth < ERR) THEN
! EXIT LOOP
! END IF
!
! IF ( CompsuctionEnth < SuperHeatEnth ) THEN
! CompSuctionTemp1 = CompSuctionTemp
! ELSE
! CompSuctionTemp2 = CompSuctionTemp
! END IF
! END DO LOOP
! Do not need the name of the refrigerant if we already have the index (from above CALLs)
Par(1) = SuctionPr
Par(2) = REAL(RefrigIndex,r64)
Par(3) = SuperHeatEnth
CALL SolveRegulaFalsi(ERR, STOP1, SolFlag, CompSuctionTemp, CalcCompSuctionTempResidual, &
CompSuctionTemp1, CompSuctionTemp2, Par)
IF(SolFlag == -1)THEN
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
CompSuctionEnth = GetSupHeatEnthalpyRefrig(Refrigerant, CompSuctionTemp, SuctionPr, &
RefrigIndex,'CalcWatertoAirHPHeating:CompSuctionTemp')
CompSuctionDensity = GetSupHeatDensityRefrig(Refrigerant, CompSuctionTemp, SuctionPr, &
RefrigIndex,'CalcWatertoAirHPHeating:CompSuctionTemp')
! Find Refrigerant Flow Rate
SELECT CASE (CompressorType)
CASE (CompressorType_Reciprocating) ! RECIPROCATING
MassRef = PistonDisp * CompSuctionDensity * &
(1+ClearanceFactor-ClearanceFactor*((DischargePr/SuctionPr)**(1/gamma)))
CASE (CompressorType_Rotary) ! ROTARY
MassRef = PistonDisp * CompSuctionDensity
CASE (CompressorType_Scroll) ! SCROLL
MassRef = RefVolFlowRate * CompSuctionDensity - LeakRateCoeff * (DischargePr/SuctionPr)
END SELECT
! Find the Source Side Heat Transfer
QSource = MassRef * ( SourceSideOutletEnth - LoadSideOutletEnth )
IF(ABS(QSource - initialQSource)/initialQSource.LT. ERR) THEN
EXIT LOOPSourceEnth
ELSE
initialQSource= initialQSource+ RelaxParam*(QSource-initialQSource)
END IF
END DO LOOPSourceEnth
! Determine the Power Consumption
SELECT CASE (CompressorType)
CASE (CompressorType_Reciprocating) ! RECIPROCATING
Power = PowerLos+(1/LosFac)*(MassRef*gamma/(gamma-1) * &
SuctionPr /CompSuctionDensity &
*(((DischargePr/SuctionPr)**((gamma-1)/gamma)) - 1))
CASE (CompressorType_Rotary) ! ROTARY
Power = PowerLos+(1/LosFac)*(MassRef*gamma/(gamma-1) * &
SuctionPr /CompSuctionDensity &
*(((DischargePr/SuctionPr)**((gamma-1)/gamma)) - 1))
CASE (CompressorType_Scroll) ! SCROLL
Power = PowerLos+(1/LosFac)*(gamma/(gamma-1)) * SuctionPr * &
RefVolFlowRate * (((gamma - 1) / gamma) * &
((DischargePr / SuctionPr) / VolumeRatio) + ((1 / gamma) * &
VolumeRatio **(gamma - 1)) - 1)
END SELECT
! Determine the Load Side Heat Rate
QLoadTotal = Power + QSource
IF(ABS(QLoadTotal - initialQLoad)/initialQLoad.LT. ERR) THEN
Converged = .TRUE.
ELSE
initialQLoad= initialQLoad+ RelaxParam*(QLoadTotal-initialQLoad)
END IF
IF (FinalSimFlag) EXIT LOOPLoadEnth
END DO LOOPLoadEnth
IF (SuctionPr < LowPressCutOff.AND. .NOT. FirstHVACIteration) THEN
CALL ShowWarningError('Heat pump:heating shut down on low pressure')
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
IF (DischargePr > HighPressCutOff.AND. .NOT. FirstHVACIteration)THEN
CALL ShowWarningError('Heat pump:heating shut down on high pressure')
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
!calculate coil outlet state variables
LoadSideAirOutletEnth= LoadSideAirInletEnth + QLoadTotal/LoadSideMassFlowRate
LoadSideOutletDBTemp = LoadSideInletDBTemp + QLoadTotal/(LoadSideMassFlowRate * CpAir)
LoadsideOutletHumRat = PsyWFnTdbH(LoadSideOutletDBTemp,LoadSideAirOutletEnth)
SourceSideOutletTemp = SourceSideInletTemp - QSource/(SourceSideMassFlowRate * CpWater)
! Calculate actual outlet conditions for the run time fraction
! Actual outlet conditions are "average" for time step
IF (CyclingScheme .EQ. ContFanCycCoil) THEN
! continuous fan, cycling compressor
WatertoAirHP(HPNum)%OutletAirEnthalpy = PartLoadRatio*LoadSideAirOutletEnth + &
(1.0d0-PartLoadRatio)*LoadSideAirInletEnth
WatertoAirHP(HPNum)%OutletAirHumRat = PartLoadRatio*LoadsideOutletHumRat + &
(1.0d0-PartLoadRatio)*LoadsideInletHumRat
WatertoAirHP(HPNum)%OutletAirDBTemp = PsyTdbFnHW(WatertoAirHP(HPNum)%OutletAirEnthalpy,WatertoAirHP(HPNum)%OutletAirHumRat)
ELSE
! default to cycling fan, cycling compressor
WatertoAirHP(HPNum)%OutletAirEnthalpy = LoadSideAirOutletEnth
WatertoAirHP(HPNum)%OutletAirHumRat = LoadsideOutletHumRat
WatertoAirHP(HPNum)%OutletAirDBTemp = LoadSideOutletDBTemp
END IF
!scale heat transfer rates and power to run time
QLoadTotal= QLoadTotal*PartLoadRatio
Power = Power*RuntimeFrac
QSource = QSource*PartLoadRatio
!Update heat pump data structure
WatertoAirHP(HPNum)%Power=Power
WatertoAirHP(HPNum)%QLoadTotal=QLoadTotal
WatertoAirHP(HPNum)%QSensible=QLoadTotal
WatertoAirHP(HPNum)%QSource=QSource
WatertoAirHP(HPNum)%RunFrac = RuntimeFrac
WatertoAirHP(HPNum)%PartLoadRatio = PartLoadRatio
! Air-side outlet conditions are already calculated above
! WatertoAirHP(HPNum)%OutletAirDBTemp=LoadSideOutletDBTemp
! WatertoAirHP(HPNum)%OutletAirHumRat=LoadsideOutletHumRat
! WatertoAirHP(HPNum)%OutletAirEnthalpy = LoadSideAirOutletEnth
WatertoAirHP(HPNum)%OutletAirMassFlowRate=LoadSideMassFlowRate
WatertoAirHP(HPNum)%OutletWaterTemp=SourceSideOutletTemp
WatertoAirHP(HPNum)%OutletWaterMassFlowRate=SourceSideMassFlowRate
WatertoAirHP(HPNum)%OutletWaterEnthalpy = SourceSideWaterInletEnth- &
QSource/SourceSideMassFlowRate
RETURN
END SUBROUTINE CalcWatertoAirHPHeating