Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | Temperature | |||
real(kind=r64), | intent(in), | DIMENSION(:) | :: | PropTemps | ||
real(kind=r64), | intent(in), | DIMENSION(:) | :: | LiqProp | ||
real(kind=r64), | intent(in), | DIMENSION(:) | :: | VapProp | ||
real(kind=r64), | intent(in) | :: | Quality | |||
character(len=*), | intent(in) | :: | calledfrom | |||
integer, | intent(in) | :: | LowBound | |||
integer, | intent(in) | :: | UpperBound |
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 GetInterpolatedSatProp(Temperature, PropTemps, LiqProp, VapProp, Quality, calledfrom, LowBound, UpperBound) &
RESULT(ReturnValue)
! FUNCTION INFORMATION:
! AUTHOR Simon Rees
! DATE WRITTEN May 2002
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This generic function performs an interpolation on the supplied saturated
! liquid and vapor data to find the saturated property value at a given
! temperature and quality. This function is used by all the functions that
! get saturated property values.
! METHODOLOGY EMPLOYED:
! Index of arrays either side of given temperature is found using FindArrayIndex.
! Double linear interpolation is used to first find property values at the given
! quality bounding the required temperature. These values are interpolated in the
! temperature domain to find the final value.
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
REAL(r64), INTENT(IN) :: Temperature ! Saturation Temp.
REAL(r64), INTENT(IN), DIMENSION(:) :: PropTemps ! Array of temperature at which props are available
REAL(r64), INTENT(IN), DIMENSION(:) :: LiqProp ! Array of saturated liquid properties
REAL(r64), INTENT(IN), DIMENSION(:) :: VapProp ! Array of saturatedvapour properties
REAL(r64), INTENT(IN) :: Quality ! Quality
character(len=*), intent(in) :: calledfrom ! routine this function was called from (error messages)
INTEGER, INTENT(IN) :: LowBound ! Valid values lower bound (set by calling program)
INTEGER, INTENT(IN) :: UpperBound ! Valid values upper bound (set by calling program)
REAL(r64) :: ReturnValue
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
INTEGER :: HiTempIndex ! array index for temp above input temp
INTEGER :: LoTempIndex ! array index for temp below input temp
REAL(r64) :: LoSatProp ! Sat. prop. at lower temp & given quality
REAL(r64) :: HiSatProp ! Sat. prop. at higher temp & given quality
REAL(r64) :: TempInterpRatio ! ratio to interpolate in temperature domain
! error counters and dummy string
LOGICAL :: ErrorFlag ! error flag for current call
INTEGER,SAVE :: TempRangeErrCount=0 ! cumulative error counter
INTEGER,SAVE :: TempRangeErrIndex=0
ErrorFlag = .False.
LoTempIndex = FindArrayIndex(Temperature, PropTemps, LowBound, UpperBound)
HiTempIndex = LoTempIndex + 1
IF (LoTempIndex == 0) THEN
LoTempIndex = LowBound ! MAX(1, LoTempIndex)
ReturnValue = LiqProp(LoTempIndex) + &
Quality*(VapProp(LoTempIndex) - LiqProp(LoTempIndex))
ErrorFlag = .True.
ELSE IF(HiTempIndex > UpperBound) THEN
HiTempIndex = UpperBound
ReturnValue = LiqProp(HiTempIndex) + &
Quality*(VapProp(HiTempIndex) - LiqProp(HiTempIndex))
ErrorFlag = .True.
ELSE
! find adjacent property values at the given quality
LoSatProp = LiqProp(LoTempIndex) + &
Quality*(VapProp(LoTempIndex) - LiqProp(LoTempIndex))
HiSatProp = LiqProp(HiTempIndex) + &
Quality*(VapProp(HiTempIndex) - LiqProp(HiTempIndex))
! find interpolation ratio in temperature direction
TempInterpRatio = (Temperature - PropTemps(LoTempIndex)) / &
(PropTemps(HiTempIndex) - PropTemps(LoTempIndex))
! apply final linear interpolation
ReturnValue = LoSatProp + TempInterpRatio*(HiSatProp - LoSatProp)
ENDIF
IF(ErrorFlag .and. .not. calledfrom == 'ReportAndTestRefrigerants' )THEN
TempRangeErrCount = TempRangeErrCount + 1
! send warning
IF (TempRangeErrCount <= RefrigerantErrorLimitTest) THEN
CALL ShowSevereError('GetInterpolatedSatProp: Saturation temperature for interpolation is out of range '// &
'of data supplied: **')
CALL ShowContinueErrorTimeStamp(' Called from:'//trim(calledfrom))
CALL ShowContinueError('Refrigerant temperature = '//TRIM(RoundSigDigits(Temperature,2)))
CALL ShowContinueError('Returned saturated property value = '//TRIM(RoundSigDigits(ReturnValue,3)))
ELSE
CALL ShowRecurringSevereErrorAtEnd( &
'GetInterpolatedSatProp: Refrigerant temperature for interpolation out of range error',TempRangeErrIndex, &
ReportMinOf=Temperature,ReportMaxOf=Temperature,ReportMinUnits='{C}',ReportMaxUnits='{C}')
ENDIF
END IF
RETURN
END FUNCTION GetInterpolatedSatProp