Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | Refrigerant | |||
real(kind=r64), | intent(in) | :: | Pressure | |||
integer, | intent(inout) | :: | RefrigIndex | |||
character(len=*), | intent(in) | :: | calledfrom |
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.
FUNCTION GetSatTemperatureRefrig(Refrigerant, Pressure, RefrigIndex,calledfrom) RESULT(ReturnValue)
! SUBROUTINE INFORMATION:
! AUTHOR Simon Rees
! DATE WRITTEN 24 May 2002
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This finds the saturation temperature for given pressure.
! METHODOLOGY EMPLOYED:
! Calls FindArrayIndex to find indices either side of requested pressure
! and linearly interpolates the corresponding saturation temperature values.
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
CHARACTER(len=*), INTENT(IN) :: Refrigerant ! carries in substance name
REAL(r64), INTENT(IN) :: Pressure ! actual temperature given as input
INTEGER, INTENT(INOUT) :: RefrigIndex ! Index to Refrigerant Properties
character(len=*), intent(in) :: calledfrom ! routine this function was called from (error messages)
REAL(r64) :: ReturnValue
! FUNCTION PARAMETER DEFINITIONS:
CHARACTER(len=*), PARAMETER :: RoutineName='GetSatTemperatureRefrig: '
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
INTEGER :: HiPresIndex ! index value of next highest Temperature from table
INTEGER :: LoPresIndex ! index value of next lowest Temperature from table
INTEGER :: RefrigNum ! index for refrigerant under consideration
REAL(r64) :: PresInterpRatio ! ratio to interpolate in temperature domain
! error counters and dummy string
LOGICAL :: ErrorFlag ! error flag for current call
INTEGER,SAVE :: PresRangeErrCount=0 ! cumulative error counter
INTEGER,SAVE :: PresRangeErrIndex=0
! FLOW:
IF (GetInput) THEN
CALL GetFluidPropertiesData
GetInput = .FALSE.
END IF
RefrigNum=0
IF (NumOfRefrigerants == 0) THEN
CALL ReportFatalRefrigerantErrors(NumOfRefrigerants,RefrigNum,.true.,Refrigerant, &
'GetSatTemperatureRefrig','properties',calledfrom)
ENDIF
ErrorFlag = .False.
IF (RefrigIndex > 0) THEN
RefrigNum=RefrigIndex
ELSE
! Find which refrigerant (index) is being requested
RefrigNum = FindRefrigerant(Refrigerant)
IF (RefrigNum == 0) THEN
CALL ReportFatalRefrigerantErrors(NumOfRefrigerants,RefrigNum,.true.,Refrigerant, &
'GetSatTemperatureRefrig','properties',calledfrom)
ENDIF
RefrigIndex=RefrigNum
ENDIF
! get the array indices
LoPresIndex = FindArrayIndex(Pressure, RefrigData(RefrigNum)%PsValues, &
RefrigData(RefrigNum)%PsLowPresIndex,RefrigData(RefrigNum)%PsHighPresIndex)
HiPresIndex = LoPresIndex + 1
! check for out of data bounds problems
IF (LoPresIndex == 0) THEN
ReturnValue = RefrigData(RefrigNum)%PsTemps(RefrigData(RefrigNum)%PsLowPresIndex)
ErrorFlag = .True.
ELSE IF(HiPresIndex > RefrigData(RefrigNum)%PsHighPresIndex) THEN
ReturnValue = RefrigData(RefrigNum)%PsTemps(RefrigData(RefrigNum)%PsHighPresIndex)
ErrorFlag = .True.
ELSE
! find interpolation ratio w.r.t temperature
PresInterpRatio = (Pressure - RefrigData(RefrigNum)%PsValues(LoPresIndex)) / &
(RefrigData(RefrigNum)%PsValues(HiPresIndex) - RefrigData(RefrigNum)%PsValues(LoPresIndex))
! apply final linear interpolation
ReturnValue = RefrigData(RefrigNum)%PsTemps(LoPresIndex) + PresInterpRatio * &
(RefrigData(RefrigNum)%PsTemps(HiPresIndex) - &
RefrigData(RefrigNum)%PsTemps(LoPresIndex))
ENDIF
IF(.NOT. WarmupFlag .and. ErrorFlag)THEN
RefrigErrorTracking(RefrigNum)%SatPressErrCount = RefrigErrorTracking(RefrigNum)%SatPressErrCount + 1
! send warning
IF (RefrigErrorTracking(RefrigNum)%SatPressErrCount <= RefrigerantErrorLimitTest) THEN
CALL ShowSevereMessage(RoutineName//'Saturation pressure is out of range for refrigerant ['// &
trim(RefrigErrorTracking(RefrigNum)%Name)//'] supplied data: **')
CALL ShowContinueError('...Called From:'//trim(calledfrom)//', supplied data range=['// &
trim(RoundSigDigits(RefrigData(RefrigNum)%PsValues(RefrigData(RefrigNum)%PsLowPresIndex),0))//','// &
trim(RoundSigDigits(RefrigData(RefrigNum)%PsValues(RefrigData(RefrigNum)%PsHighPresIndex),0))//']')
CALL ShowContinueError('...Supplied Refrigerant Pressure='//TRIM(RoundSigDigits(Pressure,0))// &
' Returned saturated temperature value ='//TRIM(RoundSigDigits(ReturnValue,2)))
CALL ShowContinueErrorTimeStamp(' ')
ENDIF
CALL ShowRecurringSevereErrorAtEnd(RoutineName//'Saturation pressure is out of range for refrigerant ['// &
trim(RefrigErrorTracking(RefrigNum)%Name)//'] supplied data: **', &
RefrigErrorTracking(RefrigNum)%SatPressErrIndex, &
ReportMaxOf=Pressure,ReportMinOf=Pressure, &
ReportMaxUnits='{Pa}',ReportMinUnits='{Pa}')
END IF
RETURN
END FUNCTION GetSatTemperatureRefrig