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.
 
 
 
 
 
 

185 lines
12 KiB

  1. # 1 "/home/admin/SimulationCore2/FluidFlow/Pressure_Distribution_VARIABLES.f90"
  2. MODULE FricPressDropVarsModule
  3. !! Record of revisions
  4. !! Date Programmer Discription of change
  5. !! ------ ------------ -----------------------
  6. !! 1396/07/26 Sheikh Original code
  7. !!
  8. IMPLICIT NONE
  9. TYPE :: FricPressDropVarsTYPE
  10. REAL :: TotFricPressLoss ! Total Frictional Pressure Loss [psi]
  11. REAL :: FlowrateNearShoe
  12. INTEGER :: NoHorizontalEl ! number of elements in horizontal pump to string line
  13. INTEGER :: NoStringEl ! number of elements in string
  14. INTEGER :: NoAnnulusEl ! number of elements in annulus space
  15. INTEGER :: NoWellToChokeEl ! number of elements in well head to choke manifold
  16. INTEGER :: NoOpenHoleEl ! number of elements in openhole
  17. INTEGER :: NumbEl ! number of flow elements in horizontal line, string, annulus and openhole
  18. INTEGER :: StringFirstEl ! number of first string element
  19. INTEGER :: StringLastEl ! number of last string element
  20. INTEGER :: AnnulusFirstEl ! number of first annulus element
  21. INTEGER :: AnnulusLastEl ! number of last annulus element
  22. INTEGER :: ChokeFirstEl ! number of first choke element
  23. INTEGER :: ChokeLastEl ! number of last choke element
  24. INTEGER :: OpenholeFirstEl ! number of first openhole element
  25. REAL :: KBOP ! DeltaPBOP = KBOP * Q**2 [psi * min^2 / gal^2]
  26. REAL :: KBit ! DeltaPBit = KBit * Q**2 [psi * min^2 / gal^2]
  27. !!!! Choke Variables
  28. REAL :: BackPressure , NewBackPressure ! back pressure at riser or choke line [psi]
  29. REAL :: Kchoke ! DeltaPchoke = Kchoke * Q**2 [psi * min^2 / gal^2]
  30. REAL :: TotalOpenChokeArea , OldTotalOpenChokeArea , ChokeBypassArea , NewTotalOpenChokeArea , AreaChange
  31. REAL :: BHPSafetyMargin , AChBHPTol ! BHP safety margin and BHP Tolerance in Auto Choke mode [psi]
  32. REAL(8) :: OnShakerDensity ! Outlet Density of well for displaying in drillwatch and data [ppg]
  33. LOGICAL :: FloatValveIn
  34. LOGICAL :: FloatValveOpen , FloatValveWasOpen
  35. LOGICAL :: BitTotallyPluged
  36. REAL :: StMudVol ! Total mud volume of Horizontal and String that may be compressed [gal]
  37. REAL :: AnnMudVol ! Total mud volume of Bottom hole, Annulus and Choke line that may be compressed [gal]
  38. REAL :: PumpToManifoldMudVol
  39. REAL :: StCompressedMudVol ! Compressed mud volume in Horizontal and String [gal]
  40. REAL :: AnnCompressedMudVol ! Compressed mud volume in Bottom hole, Annulus and Choke line [gal]
  41. REAL :: PumpToManifoldCompressedMudVol
  42. REAL :: StDeltaPDueToCompressibility ! Pressure increase due to mud compressibility in Horizontal and String [psi]
  43. REAL :: AnnDeltaPDueToCompressibility ! Pressure increase due to mud compressibility in Bottom hole, Annulus and Choke line [psi] (usually when wellhead is closed)
  44. REAL :: PumpToManifoldDeltaPDueToCompressibility
  45. REAL :: StDeltaPtoDeltaVCompressibility ! string pressure change due to compressibility [psi/gal]
  46. REAL :: AnnDeltaPtoDeltaVCompressibility ! annulus and openhole pressure change due to compressibility [psi/gal]
  47. !!!! Problem Variables (Choke and Bit)
  48. INTEGER :: ManChoke1Plug , ManChoke2Plug ! = 1 if choke is plugged , = 0 else
  49. INTEGER :: ManChoke1Washout , ManChoke2Washout ! = 1 if choke is washed out , = 0 else
  50. INTEGER :: BitJetsPlugged , BitJetsWashedOut
  51. INTEGER :: CasingPressure_DataDisplayMalF, CasingPressure_ChokeMalF
  52. !!!!!! Note that bit is not an element in these calculations
  53. END TYPE FricPressDropVarsTYPE
  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(GasPocketFlowEl)) DEALLOCATE(GasPocketFlowEl)
  136. IF (ALLOCATED(KickJacobian)) DEALLOCATE(KickJacobian)
  137. IF (ALLOCATED(OldKickJacobian)) DEALLOCATE(OldKickJacobian)
  138. IF (ALLOCATED(KickVandPFunction)) DEALLOCATE(KickVandPFunction)
  139. IF (ALLOCATED(KickUnknownVector)) DEALLOCATE(KickUnknownVector)
  140. IF (ALLOCATED(KickCorrectionVector)) DEALLOCATE(KickCorrectionVector)
  141. END SUBROUTINE DeallocateFlowTypes