Attribute VB_Name = "Module444" Public Function CalCS(Pstart As Double, Tstart_rankine As Double, Tlast_rankine As Double, G As Double, QG_mscfd As Double, Length_feet As Double, Intervals As Integer, Angle_radians As Double, Dia_inches As Double, Roughness_inches As Double) As Double Rem Cullender and Smith Correlation VBA Function Rem For personal use only. Rem Code developed for use in Louisiana State University course PETE 4051 Rem "Reserve Evaluation and Reservoir Management" Rem Spring Semester 2002. Adapted for distribution in connection with Rem the Oklahoma Geological Survey. Rem Written By: Dr. R. G. Hughes Rem 2/1/2002 Rem After Two-Phase Flow in Pipes by Brill and Beggs Rem Dim Pave As Double Dim Pst As Double Dim Tave As Double Dim SINANG As Double Dim z As Double Dim mug As Double Dim DL As Double Dim Q_scfd As Double Dim P1, Told, Pold, Pnew1, Diff, Tnew As Double Dim I As Integer Told = Tstart_rankine Pold = Pstart Pst = Pstart SINANG = Cos(Angle_radians) DL = Length_feet / Intervals Pnew1 = Pold + 0.25 * (Pst / 100) * (DL / 100) For I = 1 To Intervals Tnew = Tstart_rankine + (Tlast_rankine - Tstart_rankine) / Length_feet * I * DL Tave = (Told + Tnew) / 2# Pave = (Pnew1 + Pold) / 2# z = zfact(Pave, Tave, G, 0#, 0#) mug = gasvis(Pave, Tave, G, z) Pnew2 = CULSTH(Pst, G, Tave, DL, QG_mscfd, -1, Dia_inches / 12#, SINANG, z, mug, Roughness_inches) Pst = Pnew2 Next I CalCS = Pnew2 End Function Public Function CULSTH(P1 As Double, SGPG As Double, T As Double, DIST As Double, Q As Double, ICONV As Integer, Dia As Double, SINANG As Double, z As Double, VISG As Double, Ed As Double) As Double Dim REN As Double Dim DIAIN As Double Dim P2 As Double Dim Pyo As Double Dim Pold As Double VD = DIST * SINANG DIAIN = Dia * 12# Rem Friction Factor Calculation If (Q > 0#) Then REN = 20011# * SGPG * Q / 1000# / DIAIN / VISG F = FrFact(REN, Ed / DIAIN) Else F = 0# End If FSQ = 0.000667 * F * Q ^ 2 / (DIAIN) ^ 5 P2 = P1 + 0.25 * (P1 / 100) * (DIST / 100) Pold = P1 Pyo = P1 ICONV = 1 25 For J = 1 To 150 If (Abs(P2 - Pold) > 0.000001) Then Pold = P2 z1 = zfact(Pyo, T, SGPG, 0, 0) z2 = zfact(P2, T, SGPG, 0, 0) P2FAC = P2 / ((T) * z2) P1FAC = Pyo / ((T) * z1) ZI2 = P2FAC / ((P2FAC ^ 2 * VD / DIST) + FSQ) ZI1 = P1FAC / ((P1FAC ^ 2 * VD / DIST) + FSQ) P2 = Pyo + (0.01875 * SGPG * DIST / (ZI2 + ZI1)) Else If (ICONV < 2) Then Pold = P2 Pyo = P2 P2 = Pyo + 0.25 * (Pyo / 100) * (DIST / 100) ICONV = 3 J = 1 Else CULSTH = P2 Exit Function End If End If Next J End Function