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 | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | TDB | |||
real(kind=r64), | intent(in) | :: | dW | |||
real(kind=r64), | intent(in) | :: | Patm | |||
character(len=*), | intent(in), | optional | :: | 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 PsyTwbFnTdbWPb_raw(TDB,dW,Patm,calledfrom) RESULT(TWB)
# 1425
! FUNCTION INFORMATION:
! AUTHOR George Shih
! DATE WRITTEN May 1976
! MODIFIED na
! RE-ENGINEERED Dec 2003; Rahul Chillar
! 2011; as time saving measure, cache some values.
! PURPOSE OF THIS FUNCTION:
! This function provides the wet-bulb temperature from dry-bulb temperature,
! humidity ratio and barometric pressure.
! METHODOLOGY EMPLOYED:
! Uses an Iterative procedure to calculate WetBulbTemperature
! REFERENCES:
! na
! USE STATEMENTS:
USE General, ONLY: Iterate
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
REAL(r64), intent(in) :: TDB ! dry-bulb temperature {C}
REAL(r64), intent(in) :: dW ! humidity ratio
REAL(r64), intent(in) :: Patm ! barometric pressure {Pascals}
character(len=*), intent(in), optional :: calledfrom ! routine this function was called from (error messages)
REAL(r64) :: TWB ! result=> Temperature Wet-Bulb {C}
! FUNCTION PARAMETER DEFINITIONS:
Integer, Parameter :: itmax=100 ! Maximum No of Iterations
REAL(r64) :: convTol=0.0001d0
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
REAL(r64):: tBoil ! Boiling temperature of water at given pressure
REAL(r64), SAVE :: last_Patm=-99999.d0 ! barometric pressure {Pascals} (last)
REAL(r64), SAVE :: last_tBoil=-99999.d0 ! Boiling temperature of water at given pressure (last)
REAL(r64):: newW ! Humidity ratio calculated with wet bulb guess
REAL(r64):: W ! Humidity ratio entered and corrected as necessary
REAL(r64):: ResultX ! ResultX is the final Iteration result passed back to the calling routine
REAL(r64):: WBT ! Current Value of WetBulbTemperature
REAL(r64):: error ! Deviation of dependent variable in iteration
REAL(r64):: X1 ! Independent variable in ITERATE
REAL(r64):: Y1 ! Dependent variable in ITERATE
REAL(r64):: Wstar !Humidity ratio as a function of Sat Press of Wet Bulb
REAL(r64):: PSatstar !Saturation pressure at wet bulb temperature
Integer:: iter ! Iteration counter
Integer:: icvg ! Iteration convergence flag
LOGICAL FlagError ! set when errors should be flagged
# 1485
! CHECK TDB IN RANGE.
FlagError=.false.
IF (TDB <= -100.0d0 .or. TDB >= 200.0d0) THEN
IF (.not. WarmupFlag) THEN
IF (iPsyErrIndex(iPsyTwbFnTdbWPb) == 0) THEN
CALL ShowWarningMessage('Temperature out of range [-100. to 200.] (PsyTwbFnTdbWPb)')
if (present(calledfrom)) then
CALL ShowContinueErrorTimeStamp(' Routine='//trim(calledfrom)//',')
else
CALL ShowContinueErrorTimeStamp(' Routine=Unknown,')
endif
CALL ShowContinueError(' Input Temperature='//TRIM(TrimSigDigits(TDB,2)))
FlagError=.true.
ENDIF
CALL ShowRecurringWarningErrorAtEnd('Temperature out of range [-100. to 200.] (PsyTwbFnTdbWPb)', &
iPsyErrIndex(iPsyTwbFnTdbWPb),ReportMinOf=TDB,ReportMaxOf=TDB,ReportMinUnits='C',ReportMaxUnits='C')
ENDIF
ENDIF
W=dW
IF (W < 0.0d0) THEN
IF (W <= -.0001d0) THEN
IF (.not. WarmupFlag) THEN
IF (iPsyErrIndex(iPsyTwbFnTdbWPb2) == 0) THEN
String=' Dry-Bulb= '//TRIM(TrimSigDigits(TDB,2))//' Humidity Ratio= '//TRIM(TrimSigDigits(W,3))// &
' Pressure= '//TRIM(TrimSigDigits(Patm,2))
CALL ShowWarningMessage('Entered Humidity Ratio invalid (PsyTwbFnTdbWPb)')
if (present(calledfrom)) then
CALL ShowContinueErrorTimeStamp(' Routine='//trim(calledfrom)//',')
else
CALL ShowContinueErrorTimeStamp(' Routine=Unknown,')
endif
CALL ShowContinueError(TRIM(String))
String='Humidity Ratio= '//TRIM(TrimSigDigits(W,4))
CALL ShowContinueError(TRIM(String)//' ... Humidity Ratio set to .00001')
ENDIF
CALL ShowRecurringWarningErrorAtEnd('Entered Humidity Ratio invalid (PsyTwbFnTdbWPb)', &
iPsyErrIndex(iPsyTwbFnTdbWPb2),ReportMinOf=W,ReportMaxOf=W,ReportMinUnits='[]',ReportMaxUnits='[]')
ENDIF
ENDIF
W=1.d-5
ENDIF
! Initial temperature guess at atmospheric pressure
IF (PRESENT(calledfrom)) THEN
IF (Patm /= last_Patm) THEN
tBoil = PsyTsatFnPb(Patm,calledfrom)
last_Patm=Patm
last_tBoil=tBoil
ELSE
tBoil = last_tBoil
ENDIF
ELSE
IF (Patm /= last_Patm) THEN
tBoil = PsyTsatFnPb(Patm,'PsyTwbFnTdbWPb')
last_Patm=Patm
last_tBoil=tBoil
ELSE
tBoil = last_tBoil
ENDIF
ENDIF
! Set initial guess of WetBulbTemp=Entering Dry Bulb Temperature
WBT = TDB
! Initializing value for iter
iter=0
! Begin iteration loop
DO iter = 1,itmax
! Assigning a value to WBT
IF (WBT .GE. (tBoil-0.09d0) ) WBT = tBoil-0.1d0
! Determine the saturation pressure for wet bulb temperature
IF (PRESENT(calledfrom)) THEN
PSatstar=PsyPsatFnTemp(WBT,calledfrom)
ELSE
PSatstar=PsyPsatFnTemp(WBT,'PsyTwbFnTdbWPb')
ENDIF
! Determine humidity ratio for given saturation pressure
Wstar=0.62198d0*PSatstar/(Patm-PSatstar)
! Calculate new humidity ratio and determine difference from known
! humidity ratio which is wStar calculated earlier
newW=((2501.0d0-2.381d0*WBT)*Wstar-(TDB-WBT)) / &
(2501.0d0+1.805d0*TDB-4.186d0*WBT)
! Check error, if not satisfied, calculate new guess and iterate
error = W-newW
! Using Iterative Procedure to Calculate WetBulb
Call ITERATE(ResultX,convTol,WBT,error,X1,Y1,iter,icvg)
WBT=ResultX
! If converged, leave iteration loop.
IF (icvg .EQ. 1) Exit
! Error Trap for the Discontinious nature of PsyPsatFnTemp function (Sat Press Curve) at ~0 Deg C.
IF((PSatstar > 611.000d0) .and. (PSatstar < 611.25d0) .and. (abs(error) <= 0.0001d0) .and. (iter > 4)) Exit
End Do ! End of Iteration Loop
# 1597
! Wet bulb temperature has not converged after maximum specified
! iterations. Print error message, set return error flag, and RETURN
IF (iter > itmax) THEN
IF (.not. WarmupFlag) THEN
IF (iPsyErrIndex(iPsyTwbFnTdbWPb3) == 0) THEN
CALL ShowWarningMessage('WetBulb not converged after '//TRIM(TrimSigDigits(iter))// ' iterations(PsyTwbFnTdbWPb)')
if (present(calledfrom)) then
CALL ShowContinueErrorTimeStamp(' Routine='//trim(calledfrom)//',')
else
CALL ShowContinueErrorTimeStamp(' Routine=Unknown,')
endif
CALL ShowContinueError(' Input Temperature = '//TRIM(TrimSigDigits(TDB,2)))
CALL ShowContinueError(' Input Humidity Ratio= '//TRIM(TrimSigDigits(W,6)))
CALL ShowContinueError(' Input Pressure = '//TRIM(TrimSigDigits(Patm,2)))
FlagError=.true.
ENDIF
CALL ShowRecurringWarningErrorAtEnd('WetBulb not converged after max iterations(PsyTwbFnTdbWPb)', &
iPsyErrIndex(iPsyTwbFnTdbWPb3))
ENDIF
ENDIF
!Result is Temperature Wet Bulb
TWB=WBT
IF (FlagError) THEN
CALL ShowContinueError(' Resultant Temperature= '//TRIM(TrimSigDigits(WBT,2)))
ENDIF
! If (TempWetBulb)>(Dry Bulb Temp) , Setting (TempWetBulb)=(DryBulbTemp).
IF (TWB .GT. TDB) Then
TWB = TDB
End IF
# 1638
RETURN
END FUNCTION PsyTwbFnTdbWPb_raw