Simulation Core
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
1 рік тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 SimulationVariables !@@@
  13. use UTUBEVARSModule
  14. USE Fluid_Flow_Startup_Vars
  15. IMPLICIT NONE
  16. INTEGER :: i ,j, ibit , ij , ijk
  17. REAL :: AreaBeforeBit !!! Area of element before bit in U-Tube condition [in^2]
  18. UTUBEVARS%QUTubeInput = 1.0
  19. UTUBEVARS%QUTubeOutput = 1.0
  20. data%State%FricPressDrop%TotFricPressLoss = 0
  21. BitPressLoss = 0
  22. UTUBEVARS%PressureDp = 0
  23. UTUBEVARS%PressureAnn = 0
  24. !!!!!!!!!!!!!!!!!!!!!! Bit
  25. !!!!!!!!!!!! Calculating Pressure at the bottom of drill string from mud columns in drill pipes and annulus space
  26. UTUBEVARS%PressureDp = SUM(FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%StringLastEl)%StaticPressDiff)
  27. UTUBEVARS%PressureAnn = SUM(FlowEl(data%State%FricPressDrop%AnnulusFirstEl : data%State%FricPressDrop%AnnulusLastEl)%StaticPressDiff)
  28. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  29. !!!!!!!!!!!! U tube:: flow from string to annulus
  30. IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > UTubePressTolerance) THEN
  31. DO ijk = 1 , 10
  32. FlowEl(data%State%FricPressDrop%StringFirstEl : data%State%FricPressDrop%AnnulusLastEl)%Flowrate = UTUBEVARS%QUTubeInput
  33. !WRITE (*,*) 'QUTubeInput', FlowEl(AnnulusLastEl)%Flowrate
  34. DO ij = data%State%FricPressDrop%StringFirstEl , data%State%FricPressDrop%AnnulusLastEl !!!!! Updating values of flowrates
  35. CALL FricPressDrop(ij)
  36. CALL PartialDerivativeFricToFlowRate(ij)
  37. !WRITE (*,*) 'FricPressDrop, PartialDerivative', FlowEl(ij)%FricPressLoss, FlowEl(ij)%FricToQPartialDiff, FlowEl(ij)%Length
  38. END DO
  39. !!!!!!!!!!!!!! Bit pressure drop calculation
  40. IF (BitTrue) THEN
  41. i = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl
  42. AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2
  43. BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2
  44. END IF
  45. !!!!!!!!!!!!!!!!!!!!!!!!!!!
  46. i = data%State%FricPressDrop%NoHorizontalEl + 1
  47. j = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl
  48. data%State%FricPressDrop%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss
  49. IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) <= UTubePressTolerance .OR. UTUBEVARS%QUTubeInput < 1.0) EXIT ! tolerance set to 1.0 psi
  50. IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > data%State%FricPressDrop%TotFricPressLoss) THEN
  51. UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)
  52. ELSE IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) < data%State%FricPressDrop%TotFricPressLoss) THEN
  53. UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)
  54. END IF
  55. !WRITE (*,*) 'QUTubeInput, TotFricPressLoss', QUTubeInput, TotFricPressLoss
  56. !WRITE (*,*) '1) PressureDp, PressureAnn', PressureDp, PressureAnn, TotFricPressLoss, QUTubeInput
  57. END DO
  58. UTUBEVARS%QUTubeOutput = 0.0
  59. !!!!!!!!!!!!!!!!!!!!!!!!
  60. !!!!!!!!!!!! U tube:: flow from annulus to string
  61. ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > UTubePressTolerance) THEN
  62. DO ijk = 1 , 10
  63. DO ij = data%State%FricPressDrop%NoHorizontalEl + 1 , data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl !!!!! Updating values of flowrates
  64. FlowEl(ij)%Flowrate = UTUBEVARS%QUTubeOutput
  65. CALL FricPressDrop(ij)
  66. CALL PartialDerivativeFricToFlowRate(ij)
  67. END DO
  68. !!!!!!!!!!!!!! Bit pressure drop calculation
  69. IF (BitTrue) THEN
  70. i = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + 1
  71. AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2
  72. BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2
  73. END IF
  74. !!!!!!!!!!!!!!!!!!!!!!!!!!!
  75. i = data%State%FricPressDrop%NoHorizontalEl + 1
  76. j = data%State%FricPressDrop%NoHorizontalEl + data%State%FricPressDrop%NoStringEl + data%State%FricPressDrop%NoAnnulusEl
  77. data%State%FricPressDrop%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss
  78. IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - data%State%FricPressDrop%TotFricPressLoss) <= UTubePressTolerance) EXIT ! tolerance set to 1.0 psi
  79. IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > data%State%FricPressDrop%TotFricPressLoss) THEN
  80. UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput - (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff))
  81. ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) < data%State%FricPressDrop%TotFricPressLoss) THEN
  82. UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput + (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - data%State%FricPressDrop%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff))
  83. END IF
  84. !WRITE (*,*) 'QUTubeOutput, TotFricPressLoss', QUTubeOutput, TotFricPressLoss
  85. WRITE (*,*) '2) PressureDp, PressureAnn', UTUBEVARS%PressureDp, UTUBEVARS%PressureAnn, data%State%FricPressDrop%TotFricPressLoss
  86. END DO
  87. UTUBEVARS%QUTubeInput = 0.0
  88. !!!!!!!!!!!! No U-Tube
  89. ELSE
  90. UTUBEVARS%QUTubeInput = 0.0
  91. UTUBEVARS%QUTubeOutput = 0.0
  92. END IF
  93. END SUBROUTINE