Hello All,

I am new in writing code in VBA for excel and I am writing a code to get wet bulb temperature (WBT) from dry bulb (DBT) and relative humidity, but when I run my simulation I am getting an answer which would have been the next step in iterative calculation. For example if my initial guess for DBT=98F, Relative Humidity= 40% (.4 as input)and an initial guess for WBT = 98F then my iteration stops at 97.9F. I will appreciate if anybody could help me correct the iterative coding if I am wrong.


'-------------------------------------------------------------------------------
'Calculate wet bulb temp given dry bulb temp and relative humidity
'
Function psychro_WBT(DBT, RH)

Dim DBR As Double
Dim Pws As Double
Dim Ws As Double
Dim Pw As Double
Dim Wact As Double

DBR = DBT + 459.67

Pws = Exp(-10440.397 / DBR + -11.29465 + -0.027022355 * DBR + 0.00001289036 * DBR ^ 2 + -2.4780681E-09 * DBR ^ 3 + 6.5459673 * Log(DBR))

Ws = 0.621945 * Pws / (14.7 - Pws)

Pw = RH * Pws

Wact = 0.621945 * (Pw / (14.7 - Pw))

Do
WBT = DBR
Wnew = ((1093 - 0.556 * WBT) * Ws - 0.24 * (DBR - WBT)) / (1093 + 0.444 * DBR - WBT)
WBT = WBT - 0.1
Diff = (Wact - Wnew) / ((Wnew + Wact) / 2)
Loop Until (Diff < 0.1)

psychro_WBT = WBT

End Function