SUBROUTINE CalcWatertoAirHPCooling(HPNum,CyclingScheme,FirstHVACIteration,RuntimeFrac,initflag,SensDemand,CompOp,PartLoadRatio)
! SUBROUTINE INFORMATION:
! AUTHOR Hui Jin
! DATE WRITTEN Oct 2000
! MODIFIED Dan Fisher, Kenneth Tang (Jan 2004), 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 DataZoneEnergyDemands
USE CurveManager, ONLY: CurveValue,GetCurveIndex
USE Psychrometrics, ONLY: PsyHFnTdbW,PsyTdbFnHW,PsyWFnTdbH,PsyTwbFnTdbWPb, & !,PsyHFnTdbRhPb,PsyWFnTdpPb
PsyCpAirFnWTdb, PsyTsatFnHPb
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, INTENT(IN) :: CyclingScheme !fan/compressor cycling scheme indicator
LOGICAL, INTENT (IN):: FirstHVACIteration !first iteration flag
LOGICAL, INTENT (IN):: initflag !suppress property errors if true
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 ! Expansion Coefficient
REAL(r64), PARAMETER :: RelaxParam = .5d0 ! Relaxation Parameter
REAL(r64), PARAMETER :: ERR=0.01d0 ! Error Value
REAL(r64), PARAMETER :: ERR1=0.001d0 ! Error Value
REAL(r64), PARAMETER :: PB=1.013d5 ! Barometric Pressure (Pa)
INTEGER, PARAMETER :: STOP1=100000 ! 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 :: NumIteration4 ! Number of Iteration4 (use of latent degradation model ONLY)
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) :: NominalCoolingCapacity ! Nominal Cooling Capacity (W)
REAL(r64) :: LoadSideTotalUA ! Load Side Total Heat Transfer coefficient [W/C]
REAL(r64) :: LoadSideoutsideUA ! Load Side Outside 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 ! Quality of Refrigerant
REAL(r64) :: SourceSideMassFlowRate ! Source Side Mass Flow Rate [kg/s]
REAL(r64) :: SourceSideInletTemp ! Source Side Inlet Temperature [C]
REAL(r64) :: SourceSideWaterInletEnth ! Source Side Outlet Enthalpy [J/kg]
REAL(r64) :: SourceSideoutletTemp ! Source Side Outlet Temperature [C]
REAL(r64) :: SourceSideVolFlowRate ! Source Side Volumetric Flow Rate [m3/s]
REAL(r64) :: DegradFactor ! Degradation Factor [~]
REAL(r64) :: CpFluid ! Specific heat of source side fluid(J/kg)
REAL(r64) :: LoadSideMassFlowRate ! Load Side Mass Flow Rate [kg/s]
REAL(r64) :: LoadSideInletWBTemp ! Wet-bulb temperature of indoor inlet air [C]
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) :: EffectiveSurfaceTemp1 ! Effective Surface Temperature Guess #1 [C]
! REAL(r64) :: EffectiveSurfaceTemp2 ! Effective Surface Temperature Guess #2 [C]
REAL(r64), SAVE :: EffectiveSurfaceTemp ! Effective Surface Temperature [C]
REAL(r64) :: EffectiveSatEnth ! Saturated Enthalpy of Air Corresponding to the Effective Surface
! Temperature [J/kg]
! REAL(r64) :: EffectiveSatEnth1 ! Guess of the Saturated Enthalpy of Air Corresponding to the
! ! Effective Surface Temperature [J/kg]
REAL(r64) :: QSource ! Source Side Heat Transfer Rate [W]
REAL(r64) :: QLoadTotal ! Load Side Total Heat Transfer Rate [W]
REAL(r64) :: QSensible ! Load Side Sensible Heat Transfer Rate [W]
REAL(r64) :: Power ! Power Consumption [W]
! REAL(r64) :: EvapTemp1 ! Evaporating Temperature Guess #1 [C]
! REAL(r64) :: EvapTemp2 ! Evaporating Temperature Guess #2 [C]
REAL(r64) ,SAVE :: EvapTemp ! Evaporating Temperature [C]
REAL(r64) :: ANTUWET ! Number of Transfer Unit for Wet Condition
REAL(r64) :: EffectWET ! Load Side Heat Exchanger Effectiveness
REAL(r64) :: EvapSatEnth ! Saturated Enthalpy of Air Corresponding to the Evaporating
! Temperature [J/kg]
! REAL(r64) :: EvapSatEnth1 ! Guess of the Saturated Enthalpy of Air Corresponding to the
! ! Evaporating Temperature [J/kg]
REAL(r64) :: SourceSideEffect ! Source Side Heat Exchanger Effectiveness
REAL(r64) :: LoadSideEffec ! 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) :: CpAir ! Specific Heat of Air [J/kg_C]
REAL(r64), SAVE :: initialQSource ! Guess Source Side Heat Transfer Rate [W]
REAL(r64), SAVE :: initialQLoadTotal ! 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), SAVE :: 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]
REAL(r64) :: Twet_rated ! Twet at rated conditions (coil air flow rate and air temperatures), sec
REAL(r64) :: Gamma_rated ! Gamma at rated conditions (coil air flow rate and air temperatures)
LOGICAL :: LatDegradModelSimFlag ! Latent degradation model simulation flag
LOGICAL :: FinalSimFlag ! Final Simulation Flag
LOGICAL :: Converged ! overall convergence Flag
REAL(r64) :: QLatRated ! Qlatent at rated conditions of indoor(TDB,TWB)=(26.7C,19.4C)
REAL(r64) :: QLatActual ! Qlatent at actual operating conditions
REAL(r64) :: SHRss ! Sensible heat ratio at steady state
REAL(r64) :: SHReff ! Effective sensible heat ratio at part-load condition
REAL(r64) :: Par(4) ! Parameter array passed to RegulaFalsi function
INTEGER :: SolFlag ! Solution flag returned from RegulaFalsi function
LOGICAL :: ErrorsFound = .FALSE.
LOGICAL, SAVE :: FirstTime = .true.
REAL(r64), SAVE :: LoadSideInletDBTemp_Init ! rated conditions
REAL(r64), SAVE :: LoadSideInletHumRat_Init ! rated conditions
REAL(r64), SAVE :: LoadSideAirInletEnth_Init ! rated conditions
REAL(r64) :: LoadSideInletDBTemp_Unit ! calc conditions for unit
REAL(r64) :: LoadSideInletHumRat_Unit ! calc conditions for unit
REAL(r64) :: LoadSideAirInletEnth_Unit ! calc conditions for unit
IF (FirstTime) THEN
!Set indoor air conditions to the rated condition
LoadSideInletDBTemp_Init = 26.7d0
LoadSideInletHumRat_Init = 0.0111d0
LoadSideAirInletEnth_Init = PsyHFnTdbW(LoadSideInletDBTemp_Init,LoadSideInletHumRat_Init)
FirstTime=.false.
ENDIF
! LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
NominalCoolingCapacity = WatertoAirHP(HPNum)%CoolingCapacity
CompressorType = WatertoAirHP(HPNum)%CompressorType
Refrigerant = WatertoAirHP(HPNum)%Refrigerant
LoadSideTotalUA = WatertoAirHP(HPNum)%LoadSideTotalUACoeff
LoadSideoutsideUA = WatertoAirHP(HPNum)%LoadSideOutsideUACoeff
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
SourceSideUA = WatertoAirHP(HPNum)%SourceSideUACoeff
SourceSideHTRes1 = WatertoAirHP(HPNum)%SourceSideHTR1
SourceSideHTRes2 = WatertoAirHP(HPNum)%SourceSideHTR2
HighPressCutOff = WatertoAirHP(HPNum)%HighPressCutOff
LowPressCutOff = WatertoAirHP(HPNum)%LowPressCutOff
LoadSideMassFlowRate = WatertoAirHP(HPNum)%InletAirMassFlowRate
!Set indoor air conditions to the actual condition
LoadSideInletDBTemp_Unit= WatertoAirHP(HPNum)%InletAirDBTemp
LoadSideInletHumRat_Unit= WatertoAirHP(HPNum)%InletAirHumRat
cpair = PsyCpAirFnWTdb(LoadSideInletHumRat_Unit,LoadSideInletDBTemp_Unit)
LoadSideAirInletEnth_Unit = PsyHFnTdbW(LoadSideInletDBTemp_Unit,LoadSideInletHumRat_Unit)
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 = SourceSideMassFlowRate / GetDensityGlycol(SourceSideFluidName, &
SourceSideInletTemp,SourceSideFluidIndex, &
'CalcWatertoAirHPCooling:SourceSideInletTemp')
Twet_rated = WatertoAirHP(HPNum)%Twet_Rated
Gamma_rated = WatertoAirHP(HPNum)%Gamma_Rated
FinalSimFlag= .FALSE.
! 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
initialQSource = NominalCoolingCapacity
initialQLoadTotal = NominalCoolingCapacity
ENDIF
IF(initialQLoadTotal==0.0d0) initialQLoadTotal = NominalCoolingCapacity
IF(initialQSource==0.0d0) initialQSource = NominalCoolingCapacity
!Loop the calculation at least twice depending whether the latent degradation model
!is enabled. 1st iteration to calculate the QLatent(rated) at (TDB,TWB)indoorair=(26.7C,19.4C)
!and 2nd iteration to calculate the QLatent(actual)
QLatRated=0.0d0
QLatActual=0.0d0
!IF((RuntimeFrac .GE. 1.0) .OR. (Twet_rated .LE. 0.0) .OR. (Gamma_rated .LE. 0.0)) THEN
! Cycling fan does not required latent degradation model, only the constant fan case
IF((RuntimeFrac .GE. 1.0d0) .OR. (Twet_rated .LE. 0.0d0) .OR. (Gamma_rated .LE. 0.0d0) .OR. (CyclingScheme .EQ. CycFanCycCoil)) THEN
LatDegradModelSimFlag = .FALSE.
!Set NumIteration4=1 so that latent model would quit after 1 simulation with the actual condition
NumIteration4=1
ELSE
LatDegradModelSimFlag = .TRUE.
!Set NumIteration4=0 so that latent model would simulate twice with rated and actual condition
NumIteration4=0
END IF
LOOPLatentDegradationModel: DO
NumIteration4=NumIteration4+1
IF (NumIteration4.EQ.1) THEN
!Set indoor air conditions to the rated condition
LoadSideInletDBTemp = LoadSideInletDBTemp_Init
LoadSideInletHumRat = LoadSideInletHumRat_Init
LoadSideAirInletEnth = LoadSideAirInletEnth_Init
ELSE
!Set indoor air conditions to the actual condition
LoadSideInletDBTemp = LoadSideInletDBTemp_Unit
LoadSideInletHumRat = LoadSideInletHumRat_Unit
LoadSideAirInletEnth = LoadSideAirInletEnth_Unit
END IF
!Outerloop: Calculate source side heat transfer
NumIteration2=0
Converged = .FALSE.
FinalSimFlag = .FALSE.
LOOPSourceEnth: DO
IF (Converged) FinalSimFlag = .TRUE.
NumIteration2=NumIteration2+1
IF (NumIteration2.GT.STOP2) THEN
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
!Innerloop: Calculate load side heat transfer
NumIteration3=0
LOOPLoadEnth: DO
NumIteration3=NumIteration3+1
IF (NumIteration3.GT.STOP3) THEN
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
! Determine Effectiveness of Source Side
CpFluid=GetSpecificHeatGlycol(SourceSideFluidName,SourceSideInletTemp,SourceSideFluidIndex, &
'CalcWatertoAirHPCooling:SourceSideInletTemp')
! IF (SourceSideFluidName=='WATER') THEN
IF (SourceSideFluidIndex == WaterIndex) THEN ! SourceSideFluidName=='Water'
SourceSideEffect = 1.0d0 - EXP( -SourceSideUA / (CpFluid * SourceSideMassFlowRate))
ELSE
DegradFactor=DegradF(SourceSideFluidName,SourceSideInletTemp,SourceSideFluidIndex)
SourceSideEffect = 1.0d0 / ((SourceSideHTRes1 * SourceSideVolFlowRate**(-0.8d0)) / DegradFactor + SourceSideHTRes2)
END IF
! Determine Source Side Tempertaure (Condensing Temp in this case)
SourceSideTemp = SourceSideInletTemp +initialQSource/(SourceSideEffect * CpFluid * SourceSideMassFlowRate)
! Compute the Effective Surface Temperature
LoadSideEffec=1.0d0-EXP(-LoadSideoutsideUA/(LoadSideMassFlowRate*CpAir))
EffectiveSatEnth=LoadSideAirInletEnth-initialQloadTotal/(LoadSideEffec*LoadSideMassFlowRate)
! ! Set up the Initial Range of Effective Surface Temperature
! IF(.NOT. Converged)THEN
! EffectiveSurfaceTemp1=-100.
! EffectiveSurfaceTemp2=200.
! END IF
!
! ! Iterate to calculate the effective surface temp from the corresponding enthalpy
! NumIteration1=0
! LOOP1: DO
!
! NumIteration1=NumIteration1+1
! IF (NumIteration1.GT.STOP1) THEN
! WatertoAirHP(HPNum)%SimFlag = .FALSE.
! RETURN
! END IF
!
! EffectiveSurfaceTemp=0.5d0*(EffectiveSurfaceTemp1+EffectiveSurfaceTemp2)
! EffectiveSatEnth1=PsyHFnTdbRhPb(EffectiveSurfaceTemp,1.0,PB)
!
! IF(ABS(EffectiveSatEnth-EffectiveSatEnth1).LT.0.01 .OR. &
! ABS(EffectiveSurfaceTemp1-EffectiveSurfaceTemp2).LT.0.001) THEN
! EXIT LOOP1
! END IF
!
! IF(EffectiveSatEnth1.LT.EffectiveSatEnth) THEN
! EffectiveSurfaceTemp1=EffectiveSurfaceTemp
! ELSE
! EffectiveSurfaceTemp2=EffectiveSurfaceTemp
! END IF
! END DO LOOP1
EffectiveSurfaceTemp = PsyTsatFnHPb(EffectiveSatEnth,PB)
QSensible=LoadSideMassFlowRate*CpAir*(LoadSideInletDBTemp-EffectiveSurfaceTemp)*LoadSideEffec
ANTUWET=LoadSideTotalUA/(LoadSideMassFlowRate*CpAir)
EffectWET = 1.0d0 - EXP(-ANTUWET)
EvapSatEnth=LoadsideAirInletEnth-initialQloadTotal/(EffectWET*LoadSideMassFlowRate)
! ! Iterate to compute Evaporating Temperature
! IF(.NOT. Converged)THEN
! EvapTemp1=-150
! EvapTemp2=100
! END IF
! NumIteration1=0
! LOOP2: DO
! NumIteration1=NumIteration1+1
!
! IF (NumIteration1.GT.STOP1) THEN
! WatertoAirHP(HPNum)%SimFlag = .FALSE.
! RETURN
! END IF
! EvapTemp=0.5d0*(EvapTemp1+EvapTemp2)
! EvapSatEnth1=PsyHFnTdbRhPb(EvapTemp,1.0,PB)
! IF(ABS((EvapSatEnth-EvapSatEnth1)/EvapSatEnth).LT.ERR1) THEN
! EXIT LOOP2
! END IF
! IF(EvapSatEnth1.LT.EvapSatEnth) THEN
! EvapTemp1=EvapTemp
! ELSE
! EvapTemp2=EvapTemp
! END IF
! END DO LOOP2
EvapTemp = PsyTsatFnHPb(EvapSatEnth,PB)
! Load Side Saturated Temperature (Evaporating Temp in this case)
LoadSideTemp=EvapTemp
! Determine the Load Side and Source Side Saturated Temp (evaporating and condensing pressures)
SourceSidePressure = GetSatPressureRefrig(Refrigerant,SourceSideTemp,RefrigIndex,'CalcWatertoAirHPCooling:SourceSideTemp')
LoadSidePressure = GetSatPressureRefrig(Refrigerant,LoadSideTemp,RefrigIndex,'CalcWatertoAirHPCooling:LoadSideTemp')
IF (LoadSidePressure < LowPressCutOff.AND. .NOT. FirstHVACIteration) THEN
IF (.not. WarmupFlag) THEN
CALL ShowRecurringWarningErrorAtEnd('WaterToAir Heat pump:cooling ['//TRIM(WaterToAirHP(HPNum)%Name)// &
'] shut off on low pressure < '//TRIM(RoundSigDigits(LowPressCutoff,0)), &
WaterToAirHP(HPNum)%LowPressClgError,LoadSidePressure,LoadSidePressure, &
ReportMinUnits='[Pa]',ReportMaxUnits='[Pa]')
ENDIF
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
IF (SourceSidePressure > HighPressCutOff .AND. .NOT. FirstHVACIteration)THEN
IF (.not. WarmUpFlag) THEN
CALL ShowRecurringWarningErrorAtEnd('WaterToAir Heat pump:cooling ['//TRIM(WaterToAirHP(HPNum)%Name)// &
'] shut off on high pressure > '//TRIM(RoundSigDigits(HighPressCutOff,0)), &
WaterToAirHP(HPNum)%HighPressClgError,SourceSideInletTemp,SourceSideInletTemp, &
ReportMinUnits='SourceSideInletTemp[C]',ReportMaxUnits='SourceSideInletTemp[C]')
ENDIF
WatertoAirHP(HPNum)%SimFlag = .FALSE.
RETURN
END IF
! Determine Suction Pressure & Discharge Pressure at Compressor Exit
SELECT CASE (CompressorType)
CASE (CompressorType_Reciprocating) ! RECIPROCATING
SuctionPr = LoadSidePressure - PressureDrop
DischargePr = SourceSidePressure + PressureDrop
CASE (CompressorType_Rotary) ! ROTARY
SuctionPr = LoadSidePressure
DischargePr = SourceSidePressure + PressureDrop
CASE (CompressorType_Scroll) ! SCROLL
SuctionPr = LoadSidePressure
DischargePr = SourceSidePressure
END SELECT
! Determine the Load Side Outlet Enthalpy (Saturated Gas)
Quality = 1.0d0
LoadSideOutletEnth = GetSatEnthalpyRefrig(Refrigerant, LoadSideTemp, Quality, &
RefrigIndex,'CalcWatertoAirHPCooling:LoadSideTemp')
! Determine Source Side Outlet Enthalpy (Saturated Liquid)
Quality=0.0d0
SourceSideOutletEnth = GetSatEnthalpyRefrig(Refrigerant, SourceSideTemp, Quality, &
RefrigIndex,'CalcWatertoAirHPCooling:SourceSideTemp')
! Determine Superheated Temperature of the Load Side outlet/compressor Inlet
CompressInletTemp = LoadSideTemp + ShTemp
! Determine the Enthalpy of the Superheated Fluid at Load Side Outlet/Compressor Inlet
SuperHeatEnth = GetSupHeatEnthalpyRefrig(Refrigerant, CompressInletTemp, LoadSidePressure, &
RefrigIndex,'CalcWatertoAirHPCooling: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,'CalcWatertoAirHPCooling: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,'CalcWatertoAirHPCooling:CompSuctionTemp')
CompSuctionDensity = GetSupHeatDensityRefrig(Refrigerant, CompSuctionTemp, SuctionPr, &
RefrigIndex,'CalcWatertoAirHPCooling:CompSuctionTemp')
! Find Refrigerant Flow Rate
SELECT CASE (CompressorType)
CASE (CompressorType_Reciprocating) ! RECIPROCATING
MassRef = PistonDisp * CompSuctionDensity * &
(1.0d0+ClearanceFactor-ClearanceFactor*((DischargePr/SuctionPr)**(1.0d0/gamma)))
CASE (CompressorType_Rotary) ! ROTARY
MassRef = PistonDisp * CompSuctionDensity
CASE (CompressorType_Scroll) ! SCROLL
MassRef = RefVolFlowRate * CompSuctionDensity - LeakRateCoeff * (DischargePr/SuctionPr)
END SELECT
! Find the Load Side Heat Transfer
QloadTotal = MassRef * ( LoadSideOutletEnth - SourceSideOutletEnth )
IF(ABS(QloadTotal - initialQloadTotal)/initialQloadTotal.LT. ERR ) THEN
EXIT LOOPLoadEnth
ELSE
initialQLoadTotal = initialQLoadTotal+ RelaxParam*(QloadTotal-initialQLoadTotal)
END IF
END DO LOOPLoadEnth
! Determine the Power Consumption
SELECT CASE (CompressorType)
CASE (CompressorType_Reciprocating) ! RECIPROCATING
Power = PowerLos+(1.0d0/LosFac)*(MassRef*gamma/(gamma-1.0d0) * &
SuctionPr /CompSuctionDensity &
*(((DischargePr/SuctionPr)**((gamma-1.0d0)/gamma)) - 1.0d0))
CASE (CompressorType_Rotary) ! ROTARY
Power = PowerLos+(1.0d0/LosFac)*(MassRef*gamma/(gamma-1.0d0) * &
SuctionPr /CompSuctionDensity &
*(((DischargePr/SuctionPr)**((gamma-1.0d0)/gamma)) - 1.0d0))
CASE (CompressorType_Scroll) ! SCROLL
Power = PowerLos+(1.0d0/LosFac)*(gamma/(gamma-1.0d0)) * SuctionPr * &
RefVolFlowRate * (((gamma-1.0d0) / gamma) * &
((DischargePr / SuctionPr) / VolumeRatio) + ((1.0d0/gamma) * &
VolumeRatio **(gamma-1.0d0)) - 1.0d0)
END SELECT
! Determine the Sourceside Heat Rate
QSource = Power + QLoadTotal
IF(ABS(QSource - initialQSource)/initialQSource.LT. ERR) THEN
Converged = .TRUE.
ELSE
initialQSource= initialQSource+ RelaxParam*(QSource-initialQSource)
END IF
IF (FinalSimFlag) EXIT LOOPSourceEnth
END DO LOOPSourceEnth
IF (SuctionPr < LowPressCutOff) THEN
CALL ShowWarningError('Heat pump:cooling shut down on low pressure')
WatertoAirHP(HPNum)%SimFlag = .FALSE.
END IF
IF (DischargePr > HighPressCutOff.AND. .NOT. FirstHVACIteration)THEN
CALL ShowWarningError('Heat pump:cooling shut down on high pressure')
WatertoAirHP(HPNum)%SimFlag = .FALSE.
END IF
IF(QSensible.GT.QLoadTotal) THEN
QSensible = QLoadTotal
END IF
IF(LatDegradModelSimFlag) THEN
IF(NumIteration4.EQ.1) THEN
QLatRated=QLoadTotal-QSensible
ELSEIF(NumIteration4.EQ.2) THEN
QLatActual=QLoadTotal-QSensible
SHRss=QSensible/QLoadTotal
LoadSideInletWBTemp=PsyTwbFnTdbWPb(LoadSideInletDBTemp,LoadSideInletHumRat,PB)
SHReff = CalcEffectiveSHR(HPNum, SHRss,CyclingScheme, RuntimeFrac, &
QLatRated, QLatActual, LoadSideInletDBTemp, LoadSideInletWBTemp)
! Update sensible capacity based on effective SHR
QSensible = QLoadTotal * SHReff
EXIT LOOPLatentDegradationModel
END IF
ELSE
SHReff = QSensible/QLoadTotal
EXIT LOOPLatentDegradationModel
END IF
END DO LOOPLatentDegradationModel
!calculate coil outlet state variables
LoadSideAirOutletEnth= LoadSideAirInletEnth - QLoadTotal/LoadSideMassFlowRate
LoadSideOutletDBTemp = LoadSideInletDBTemp - QSensible/(LoadSideMassFlowRate * CpAir)
LoadsideOutletHumRat = PsyWFnTdbH(LoadSideOutletDBTemp,LoadSideAirOutletEnth)
SourceSideOutletTemp = SourceSideInletTemp + QSource/(SourceSideMassFlowRate * CpWater)
! 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
QSensible = QSensible*PartLoadRatio
Power = Power*RuntimeFrac
QSource = QSource*PartLoadRatio
!Update heat pump data structure
WatertoAirHP(HPNum)%Power=Power
WatertoAirHP(HPNum)%QLoadTotal=QLoadTotal
WatertoAirHP(HPNum)%QSensible=QSensible
WatertoAirHP(HPNum)%QLatent=QLoadTotal - QSensible
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 CalcWatertoAirHPCooling