Simulation Core
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

110 rindas
6.4 KiB

  1. SUBROUTINE Utube
  2. !! This subroutine calculates flow rate when pump is off, pump is disconnected from drill pipe
  3. !! and both annulus and drill pipe are exposed to atmosphere pressure and thus a U-tube situation is occurs
  4. !! Record of revisions
  5. !! Date Programmer Discription of change
  6. !! ------ ------------ -----------------------
  7. !! 1396/07/29 Sheikh Original code
  8. !! 1396/08/09 Sheikh Two-side U-tube
  9. !!
  10. USE FricPressDropVarsModule
  11. USE MudSystemVARIABLES
  12. use UTUBEVARSModule
  13. USE Fluid_Flow_Startup_Vars
  14. IMPLICIT NONE
  15. INTEGER :: i ,j, ibit , ij , ijk
  16. REAL :: AreaBeforeBit !!! Area of element before bit in U-Tube condition [in^2]
  17. UTUBEVARS%QUTubeInput = 1.0
  18. UTUBEVARS%QUTubeOutput = 1.0
  19. FricPressDropVars%TotFricPressLoss = 0
  20. BitPressLoss = 0
  21. UTUBEVARS%PressureDp = 0
  22. UTUBEVARS%PressureAnn = 0
  23. !!!!!!!!!!!!!!!!!!!!!! Bit
  24. !!!!!!!!!!!! Calculating Pressure at the bottom of drill string from mud columns in drill pipes and annulus space
  25. UTUBEVARS%PressureDp = SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff)
  26. UTUBEVARS%PressureAnn = SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%AnnulusLastEl)%StaticPressDiff)
  27. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  28. !!!!!!!!!!!! U tube:: flow from string to annulus
  29. IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > UTubePressTolerance) THEN
  30. DO ijk = 1 , 10
  31. FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%AnnulusLastEl)%Flowrate = UTUBEVARS%QUTubeInput
  32. !WRITE (*,*) 'QUTubeInput', FlowEl(AnnulusLastEl)%Flowrate
  33. DO ij = FricPressDropVars%StringFirstEl , FricPressDropVars%AnnulusLastEl !!!!! Updating values of flowrates
  34. CALL FricPressDrop(ij)
  35. CALL PartialDerivativeFricToFlowRate(ij)
  36. !WRITE (*,*) 'FricPressDrop, PartialDerivative', FlowEl(ij)%FricPressLoss, FlowEl(ij)%FricToQPartialDiff, FlowEl(ij)%Length
  37. END DO
  38. !!!!!!!!!!!!!! Bit pressure drop calculation
  39. IF (BitTrue) THEN
  40. i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl
  41. AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2
  42. BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2
  43. END IF
  44. !!!!!!!!!!!!!!!!!!!!!!!!!!!
  45. i = FricPressDropVars%NoHorizontalEl + 1
  46. j = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl
  47. FricPressDropVars%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss
  48. IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) <= UTubePressTolerance .OR. UTUBEVARS%QUTubeInput < 1.0) EXIT ! tolerance set to 1.0 psi
  49. IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > FricPressDropVars%TotFricPressLoss) THEN
  50. UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)
  51. ELSE IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) < FricPressDropVars%TotFricPressLoss) THEN
  52. UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)
  53. END IF
  54. !WRITE (*,*) 'QUTubeInput, TotFricPressLoss', QUTubeInput, TotFricPressLoss
  55. !WRITE (*,*) '1) PressureDp, PressureAnn', PressureDp, PressureAnn, TotFricPressLoss, QUTubeInput
  56. END DO
  57. UTUBEVARS%QUTubeOutput = 0.0
  58. !!!!!!!!!!!!!!!!!!!!!!!!
  59. !!!!!!!!!!!! U tube:: flow from annulus to string
  60. ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > UTubePressTolerance) THEN
  61. DO ijk = 1 , 10
  62. DO ij = FricPressDropVars%NoHorizontalEl + 1 , FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl !!!!! Updating values of flowrates
  63. FlowEl(ij)%Flowrate = UTUBEVARS%QUTubeOutput
  64. CALL FricPressDrop(ij)
  65. CALL PartialDerivativeFricToFlowRate(ij)
  66. END DO
  67. !!!!!!!!!!!!!! Bit pressure drop calculation
  68. IF (BitTrue) THEN
  69. i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + 1
  70. AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2
  71. BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2
  72. END IF
  73. !!!!!!!!!!!!!!!!!!!!!!!!!!!
  74. i = FricPressDropVars%NoHorizontalEl + 1
  75. j = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl
  76. FricPressDropVars%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss
  77. IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) <= UTubePressTolerance) EXIT ! tolerance set to 1.0 psi
  78. IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > FricPressDropVars%TotFricPressLoss) THEN
  79. UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput - (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff))
  80. ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) < FricPressDropVars%TotFricPressLoss) THEN
  81. UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput + (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff))
  82. END IF
  83. !WRITE (*,*) 'QUTubeOutput, TotFricPressLoss', QUTubeOutput, TotFricPressLoss
  84. WRITE (*,*) '2) PressureDp, PressureAnn', UTUBEVARS%PressureDp, UTUBEVARS%PressureAnn, FricPressDropVars%TotFricPressLoss
  85. END DO
  86. UTUBEVARS%QUTubeInput = 0.0
  87. !!!!!!!!!!!! No U-Tube
  88. ELSE
  89. UTUBEVARS%QUTubeInput = 0.0
  90. UTUBEVARS%QUTubeOutput = 0.0
  91. END IF
  92. END SUBROUTINE