I am trying to calculate the temperature for the hdrogentation column that has a pressure of 515 psia. When I enter this value I get "Overflow Error 6". I defined P as Long, but I still get the same error. I know the code will work if the pressure is changed to 55 psia. I believe the problem may be due to a very long mmHg value, because 515 psia = 26632 mmHg while 55 psi = 2844 mmHg. I have checked the Antoine coefficients and they are correct.
Here is my code. Please help. Attached file also.
Sub Mole()
Dim X(10), A(10), B(10), C(10), K(10), Y(10)
Dim P As Double
'Input Data
GoSub S1
Trial = 0
P1:
Trial = Trial + 1
Told = TNew
T = Told
'Calc FT and Deriv
GoSub S2
TNew = Told - FT / Deriv
T = TNew
'Calc FT
GoSub S2
If Abs(TNew - Told) <= 0.01 Then GoTo P2
GoTo P1
P2:
Range("H28").Value = T
End
'Input Data
S1:
X(1) = Sheets("Mole").Range("F24")
X(2) = Sheets("Mole").Range("F25")
A(1) = Sheets("Mole").Range("B4")
A(2) = Sheets("Mole").Range("B5")
B(1) = Sheets("Mole").Range("C4")
B(2) = Sheets("Mole").Range("C5")
C(1) = Sheets("Mole").Range("D4")
C(2) = Sheets("Mole").Range("D5")
P = (Sheets("Mole").Range("G28")) * 51.7149
TStart = 20
Told = 20
TNew = 20
Return
'Calc FT and Deriv
S2:
SumFT = 0
SumFPT = 0
For I = 1 To 2
K(I) = 10 ^ (A(I) - B(I) / (T + C(I))) / (P)
SumFT = SumFT + K(I) * X(I)
SumFPT = SumFPT + B(I) / ((T + C(I)) ^ 2) * K(I) * X(I)
Next I
FT = 1 - SumFT
Deriv = -Log(10) * SumFPT
Return
End Sub
Bookmarks