Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Pressure_Distribution_VARIABLES.f90 12 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. MODULE FricPressDropVarsModule
  2. !! Record of revisions
  3. !! Date Programmer Discription of change
  4. !! ------ ------------ -----------------------
  5. !! 1396/07/26 Sheikh Original code
  6. !!
  7. IMPLICIT NONE
  8. TYPE :: FricPressDropVarsTYPE
  9. REAL :: TotFricPressLoss ! Total Frictional Pressure Loss [psi]
  10. REAL :: FlowrateNearShoe
  11. INTEGER :: NoHorizontalEl ! number of elements in horizontal pump to string line
  12. INTEGER :: NoStringEl ! number of elements in string
  13. INTEGER :: NoAnnulusEl ! number of elements in annulus space
  14. INTEGER :: NoWellToChokeEl ! number of elements in well head to choke manifold
  15. INTEGER :: NoOpenHoleEl ! number of elements in openhole
  16. INTEGER :: NumbEl ! number of flow elements in horizontal line, string, annulus and openhole
  17. INTEGER :: StringFirstEl ! number of first string element
  18. INTEGER :: StringLastEl ! number of last string element
  19. INTEGER :: AnnulusFirstEl ! number of first annulus element
  20. INTEGER :: AnnulusLastEl ! number of last annulus element
  21. INTEGER :: ChokeFirstEl ! number of first choke element
  22. INTEGER :: ChokeLastEl ! number of last choke element
  23. INTEGER :: OpenholeFirstEl ! number of first openhole element
  24. REAL :: KBOP ! DeltaPBOP = KBOP * Q**2 [psi * min^2 / gal^2]
  25. REAL :: KBit ! DeltaPBit = KBit * Q**2 [psi * min^2 / gal^2]
  26. !!!! Choke Variables
  27. REAL :: BackPressure , NewBackPressure ! back pressure at riser or choke line [psi]
  28. REAL :: Kchoke ! DeltaPchoke = Kchoke * Q**2 [psi * min^2 / gal^2]
  29. REAL :: TotalOpenChokeArea , OldTotalOpenChokeArea , ChokeBypassArea , NewTotalOpenChokeArea , AreaChange
  30. REAL :: BHPSafetyMargin , AChBHPTol ! BHP safety margin and BHP Tolerance in Auto Choke mode [psi]
  31. REAL(8) :: OnShakerDensity ! Outlet Density of well for displaying in drillwatch and data [ppg]
  32. LOGICAL :: FloatValveIn
  33. LOGICAL :: FloatValveOpen , FloatValveWasOpen
  34. LOGICAL :: BitTotallyPluged
  35. REAL :: StMudVol ! Total mud volume of Horizontal and String that may be compressed [gal]
  36. REAL :: AnnMudVol ! Total mud volume of Bottom hole, Annulus and Choke line that may be compressed [gal]
  37. REAL :: PumpToManifoldMudVol
  38. REAL :: StCompressedMudVol ! Compressed mud volume in Horizontal and String [gal]
  39. REAL :: AnnCompressedMudVol ! Compressed mud volume in Bottom hole, Annulus and Choke line [gal]
  40. REAL :: PumpToManifoldCompressedMudVol
  41. REAL :: StDeltaPDueToCompressibility ! Pressure increase due to mud compressibility in Horizontal and String [psi]
  42. REAL :: AnnDeltaPDueToCompressibility ! Pressure increase due to mud compressibility in Bottom hole, Annulus and Choke line [psi] (usually when wellhead is closed)
  43. REAL :: PumpToManifoldDeltaPDueToCompressibility
  44. REAL :: StDeltaPtoDeltaVCompressibility ! string pressure change due to compressibility [psi/gal]
  45. REAL :: AnnDeltaPtoDeltaVCompressibility ! annulus and openhole pressure change due to compressibility [psi/gal]
  46. !!!! Problem Variables (Choke and Bit)
  47. INTEGER :: ManChoke1Plug , ManChoke2Plug ! = 1 if choke is plugged , = 0 else
  48. INTEGER :: ManChoke1Washout , ManChoke2Washout ! = 1 if choke is washed out , = 0 else
  49. INTEGER :: BitJetsPlugged , BitJetsWashedOut
  50. INTEGER :: CasingPressure_DataDisplayMalF, CasingPressure_ChokeMalF
  51. !!!!!! Note that bit is not an element in these calculations
  52. END TYPE FricPressDropVarsTYPE
  53. TYPE(FricPressDropVarsTYPE) :: FricPressDropVars
  54. INTEGER :: ShoeFlowElNo ! the flow element that starts from shoe, in other word the number of upper element adjacent to shoe
  55. REAL :: ClingingFactor = 0.45 ! in calculating surge and swab pressure changes
  56. REAL :: MudCompressibility = 2.7E-6 ! Volumne change relative to Volume/1psi, for example for change of 1000 psi in pressure, volume changes 0.27% [1/psi]
  57. REAL :: FloatValveMinOpenPressure = 1.0 ! minimum pressure that opens the float valve [psi]
  58. TYPE, PUBLIC :: PressDropCalcElemInfo
  59. !! Geometrical variables
  60. REAL(8) :: Length ! Length of a Flow element [ft]
  61. REAL(8) :: DepthDiff ! Difference between depth of start and end of element [ft]
  62. REAL(8) :: StartX , EndX ! start and end point (measured depth) of flow element [ft]
  63. REAL(8) :: StartTVD , EndTVD ! Start and End point True Vertical Depth of flow element [ft]
  64. REAL :: Od , Id , Dhyd ! Outer, Inner and hydraulic diameter of flow element [in]
  65. REAL :: Area ! area of element [ft^2]
  66. INTEGER :: alpha ! geometry factor: 0 = pipe (ID=0) , 1 = annulus
  67. INTEGER :: FrictionDirection ! = 1 if flowrate is positive, so frictional pressure gradient is in direction of preassumed
  68. ! flowrate, = -1 if not above condition usually in Swab conditions
  69. !! Flow variables
  70. INTEGER :: MaterialType ! = 0 for mud , = 2 for gas
  71. REAL :: volume , vel , density , FlowRate ! volume [ft^3], velocity [ft/s], density of fluid flow [ppg], flow rate [gpm]
  72. REAL :: Gf ! geometry shear rate correction [-]
  73. !! Rheological and frictional variables
  74. REAL :: Theta600 , Theta300 ! Fann data at 600 and 300 rpm as rheological data
  75. ! REAL(8) :: VelCritBing , VelCritPow ! critical velocity in Bingham Plastic and Power law model [ft/min]
  76. REAL :: muPlastic , YieldP ! plastic viscosity [cp] and yield point [lbf/(100*ft^2)]
  77. REAL :: mueff ! Effective or apparent viscosity which is used in calculation of generalized Reynolds number
  78. REAL :: nIndex , kIndex ! n: flow behaivior index [-] and k: consistency factor [lbf*s^n/(100*ft^2)]
  79. REAL :: gammaW , tauW ! shear rate at the wall [1/s] and wall shear stress [lbf/(100*ft^2)]
  80. REAL :: GenRe ! generalized Reynolds number in power law model [-]
  81. REAL :: ReCrit = 2100.0 ! Critical Reynolds number for Newtonian model and Bingham plastic model
  82. REAL :: ReCritLam , ReCritTurb ! laminar and turbulent critical Reynolds
  83. REAL :: f ! Fanning friction factor [-]
  84. REAL :: a , b ! parameters for calculationg friction factor in turbulent regime for power law model [-]
  85. LOGICAL :: LaminarRegime ! = .TRUE. if flow regime is laminar and = .FALSE. if flowregime is not
  86. LOGICAL :: TurbulentRegime ! = .TRUE. if flow regime is turbulent and = .FALSE. if flowregime is not
  87. !! Pressure change variables
  88. REAL :: StartPress , EndPress ! Pressure at start and end of an element [psi]
  89. REAL :: dPdLFric ! frictional pressure drop gradient in each element [psi/ft]
  90. REAL :: dPdLGrav ! gravitional pressure gradient = 0.052 * Density [psi/ft]
  91. REAL :: FricPressLoss ! frictional pressure loss in each element [psi]
  92. REAL :: StaticPressDiff ! static pressure difference between top and bottom of a pocket [psi] always positive
  93. REAL :: FricToQPartialDiff ! partial differentiation of friction relative to volume flow rate
  94. END TYPE PressDropCalcElemInfo
  95. TYPE (PressDropCalcElemInfo) , ALLOCATABLE :: FlowEl(:) ! FlowEl: Pressure Drop Calculation Elements The dimension is equal to the number of flow elements
  96. TYPE, PUBLIC :: FinalPressDropCalcElemInfo
  97. !!! for use in calculationg properties of a point in 'downhole view' page
  98. REAL(8) :: StartX , EndX , StartTVD , EndTVD , Length , DepthDiff ! start and end point of flow element [ft]
  99. REAL :: density ! density of fluid flow [ppg], flow rate [gpm]
  100. REAL :: StartPress ! Pressure at start of an element [psi]
  101. REAL :: EndPress ! Pressure at end of an element [psi]
  102. REAL :: dPdLFric ! frictional pressure drop gradient in each element [psi/ft]
  103. REAL :: dPdLGrav ! gravitional pressure gradient = 0.052 * Density [psi/ft]
  104. END TYPE FinalPressDropCalcElemInfo
  105. TYPE (FinalPressDropCalcElemInfo) , ALLOCATABLE :: FinalFlowEl(:) ! FlowEl: Pressure Drop Calculation Elements The dimension is equal to the number of flow elements
  106. END MODULE FricPressDropVarsModule
  107. MODULE UTUBEVARSModule
  108. TYPE :: UTUBEVARSTYPE
  109. REAL :: QUTubeInput ! flow rate from string to annulus which caused by head difference at two sides of U-tube [gpm]
  110. REAL :: QUtubeOutput ! flow rate from annulus to string which caused by head difference at two sides of U-tube [gpm]
  111. REAL :: PressureDp ! pressure at bit or end of drill string from drill string path [psi]
  112. REAL :: PressureAnn ! pressure at bit or end of drill string from annular path [psi]
  113. END TYPE UTUBEVARSTYPE
  114. TYPE(UTUBEVARSTYPE) :: UTUBEVARS
  115. END MODULE UTUBEVARSModule
  116. SUBROUTINE DeallocateFlowTypes
  117. USE FricPressDropVarsModule
  118. use PressureDisplayVARIABLESModule
  119. use KickVARIABLESModule
  120. IMPLICIT NONE
  121. IF (ALLOCATED(FlowEl)) DEALLOCATE(FlowEl)
  122. IF (ALLOCATED(FinalFlowEl)) DEALLOCATE(FinalFlowEl)
  123. IF (ALLOCATED(GasPocketWeight%Array)) CALL GasPocketWeight%Empty()
  124. IF (ALLOCATED(GasPocketNewPress%Array)) CALL GasPocketNewPress%Empty()
  125. IF (ALLOCATED(GasPocketOldPress%Array)) CALL GasPocketOldPress%Empty()
  126. IF (ALLOCATED(GasPocketNewTemp%Array)) CALL GasPocketNewTemp%Empty()
  127. IF (ALLOCATED(GasPocketOldTemp%Array)) CALL GasPocketOldTemp%Empty()
  128. IF (ALLOCATED(GasPocketNewVol%Array)) CALL GasPocketNewVol%Empty()
  129. IF (ALLOCATED(GasPocketOldVol%Array)) CALL GasPocketOldVol%Empty()
  130. IF (ALLOCATED(GasPocketdeltaVol%Array)) CALL GasPocketdeltaVol%Empty()
  131. IF (ALLOCATED(GasPocketModifiedVol%Array)) CALL GasPocketModifiedVol%Empty()
  132. IF (ALLOCATED(GasPocketFlowInduced%Array)) CALL GasPocketFlowInduced%Empty()
  133. IF (ALLOCATED(GasPocketDensity%Array)) CALL GasPocketDensity%Empty()
  134. IF (ALLOCATED(GasPocketCompressibility%Array)) CALL GasPocketCompressibility%Empty()
  135. IF (ALLOCATED(KickVARIABLES%GasPocketFlowEl)) DEALLOCATE(KickVARIABLES%GasPocketFlowEl)
  136. IF (ALLOCATED(KickVARIABLES%KickJacobian)) DEALLOCATE(KickVARIABLES%KickJacobian)
  137. IF (ALLOCATED(KickVARIABLES%OldKickJacobian)) DEALLOCATE(KickVARIABLES%OldKickJacobian)
  138. IF (ALLOCATED(KickVARIABLES%KickVandPFunction)) DEALLOCATE(KickVARIABLES%KickVandPFunction)
  139. IF (ALLOCATED(KickVARIABLES%KickUnknownVector)) DEALLOCATE(KickVARIABLES%KickUnknownVector)
  140. IF (ALLOCATED(KickVARIABLES%KickCorrectionVector)) DEALLOCATE(KickVARIABLES%KickCorrectionVector)
  141. END SUBROUTINE DeallocateFlowTypes