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.

FillingWell_By_BellNipple.f90 8.3 KiB

1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. subroutine FillingWell_By_BellNipple ! is called in subroutine CirculationCodeSelect
  2. ! this subroutine is for lines: 1) BellNippleToWell-NonFullWell : MUD(8)%Q
  3. ! 2) PumpsToWell_KillLine : MUD(10)%Q
  4. Use GeoElements_FluidModule
  5. USE CMudPropertiesVariables
  6. USE MudSystemVARIABLES
  7. USE Pumps_VARIABLES
  8. use CDrillWatchVariables
  9. !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  10. USE sROP_Other_Variables
  11. USE sROP_Variables
  12. Use KickVariables
  13. implicit none
  14. real(8) deltaV,Xposition,FillingDensity
  15. integer kloc,SectionPosition
  16. ! Well Is Not Full
  17. if (Ann_MudOrKick%Last() == 104) then ! Last Element is air we must observe: Ann_Mud_Forehead_X%Last()=0.0
  18. write(*,*) 'FillingWell_By_BellNipple-Last Element is air'
  19. !write(*,*) '*Ann_Mud_Forehead_X%Last()=' , Ann_Mud_Forehead_X%Last()
  20. !write(*,*) '*Ann_MudOrKick%Last()=' , Ann_MudOrKick%Last()
  21. FillingDensity= BellNippleDensity
  22. !****************************
  23. if ( Ann_MudDischarged_Volume%Last() > (((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi mimune
  24. kloc= Ann_MudDischarged_Volume%Length()-1
  25. deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline
  26. Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())= Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length()) - deltaV
  27. !========================ANNULUS ENTRANCE====================
  28. if (ABS(Ann_Density%Array(kloc) - FillingDensity) >= DensityMixTol) then ! new mud is pumped
  29. call Ann_Density%AddTo (kloc, FillingDensity)
  30. call Ann_MudDischarged_Volume%AddTo (kloc, 0.0d0)
  31. call Ann_Mud_Forehead_X%AddTo (kloc, 0.0d0)
  32. call Ann_Mud_Forehead_section%AddTo (kloc, 1)
  33. call Ann_Mud_Backhead_X%AddTo (kloc, 0.0d0)
  34. call Ann_Mud_Backhead_section%AddTo (kloc, NoPipeSections)
  35. call Ann_RemainedVolume_in_LastSection%AddTo (kloc, 0.0d0)
  36. call Ann_EmptyVolume_inBackheadLocation%AddTo (kloc, 0.0d0)
  37. call Ann_MudOrKick%AddTo (kloc, 0)
  38. call Ann_CuttingMud%AddTo (kloc,0)
  39. !AnnulusSuctionDensity_Old= Hz_Density_Utube
  40. endif
  41. !========================ANNULUS====================
  42. Ann_MudDischarged_Volume%Array(kloc)= Ann_MudDischarged_Volume%Array(kloc)+ deltaV !(gal)
  43. else ! ( Ann_MudDischarged_Volume%Last() <= (((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline)) then ! air baghi namune
  44. kloc= Ann_MudDischarged_Volume%Length()-1
  45. deltaV= Ann_MudDischarged_Volume%Last()
  46. if (ABS(Ann_Density%Array(kloc)-FillingDensity)< DensityMixTol .and. Ann_CuttingMud%Array(kloc)==0) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)< 42.) ) then ! 1-Pockets are Merged
  47. Ann_Density%Array(kloc)= (Ann_Density%Array(kloc)*Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(Ann_MudDischarged_Volume%Array(kloc)+deltaV)
  48. Ann_MudDischarged_Volume%Array(kloc)= Ann_MudDischarged_Volume%Array(kloc)+deltaV
  49. Ann_Mud_Forehead_X%Array(kloc)= Xend_PipeSection(NoPipeSections)
  50. Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections
  51. !Ann_Mud_Backhead_X%Array(kloc)= no change
  52. !Ann_Mud_Backhead_section%Array(kloc)= no change
  53. Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0)
  54. Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0)
  55. call Ann_MudDischarged_Volume%Remove (kloc+1)
  56. call Ann_Mud_Backhead_X%Remove (kloc+1)
  57. call Ann_Mud_Backhead_section%Remove (kloc+1)
  58. call Ann_Mud_Forehead_X%Remove (kloc+1)
  59. call Ann_Mud_Forehead_section%Remove (kloc+1)
  60. call Ann_Density%Remove (kloc+1)
  61. call Ann_RemainedVolume_in_LastSection%Remove (kloc+1)
  62. call Ann_EmptyVolume_inBackheadLocation%Remove (kloc+1)
  63. call Ann_MudOrKick%Remove (kloc+1)
  64. call Ann_CuttingMud%Remove (kloc+1)
  65. else ! 2-Merging conditions are not meeted, so new pocket== air is replaced with filling mud
  66. Ann_Density%Array(kloc+1) =FillingDensity
  67. Ann_MudOrKick%Array(kloc+1)= 0
  68. endif
  69. endif
  70. ! end condition (Ann_MudOrKick%Last() == 104) ! Last Element is air
  71. !**********************************************************************************************************************************************************
  72. else ! (Ann_MudOrKick%Last() == 0) then ! Last Element is NOT air- so we must observe: Ann_Mud_Forehead_X%Last()/=0.0
  73. !write(*,*) 'FillingWell_By_BellNipple-Last Element is NOT air'
  74. !
  75. !write(*,*) '*Ann_Mud_Forehead_X%Last()=' , Ann_Mud_Forehead_X%Last()
  76. !write(*,*) '*Ann_MudOrKick%Last()=' , Ann_MudOrKick%Last()
  77. deltaV= ((MUD(8)%Q+MUD(10)%Q)/60.)*DeltaT_Mudline
  78. kloc= Ann_MudDischarged_Volume%Length()
  79. !========================ANNULUS ENTRANCE====================
  80. if (ABS(Ann_Density%Last() - FillingDensity) >= DensityMixTol .or. Ann_CuttingMud%Last()==1) then ! .OR. (Ann_MudDischarged_Volume%Array(kloc)>42.) ) then ! new mud is pumped
  81. Xposition= Ann_Mud_Forehead_X%Last()
  82. SectionPosition= Ann_Mud_Forehead_section%Last()
  83. call Ann_Density%Add (FillingDensity)
  84. call Ann_MudDischarged_Volume%Add (0.0d0)
  85. call Ann_Mud_Forehead_X%Add (Xposition)
  86. call Ann_Mud_Forehead_section%Add (SectionPosition)
  87. call Ann_Mud_Backhead_X%Add (Xposition)
  88. call Ann_Mud_Backhead_section%Add (SectionPosition)
  89. call Ann_RemainedVolume_in_LastSection%Add (0.0d0)
  90. call Ann_EmptyVolume_inBackheadLocation%Add (0.0d0)
  91. call Ann_MudOrKick%Add (0)
  92. call Ann_CuttingMud%Add (0)
  93. !AnnulusSuctionDensity_Old= Hz_Density_Utube
  94. !endif
  95. !========================ANNULUS====================
  96. Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())= Ann_MudDischarged_Volume%Array(Ann_MudDischarged_Volume%Length())+ deltaV !(gal)
  97. else ! Merged with last Mud
  98. Ann_Density%Array(kloc)= (Ann_Density%Array(kloc)*Ann_MudDischarged_Volume%Array(kloc)+FillingDensity*deltaV)/(Ann_MudDischarged_Volume%Array(kloc)+deltaV)
  99. Ann_MudDischarged_Volume%Array(kloc)= Ann_MudDischarged_Volume%Array(kloc)+deltaV
  100. !Ann_Mud_Forehead_X%Array(kloc)= Xend_PipeSection(NoPipeSections)
  101. !Ann_Mud_Forehead_section%Array(kloc)= NoPipeSections
  102. !Ann_Mud_Backhead_X%Array(kloc)= no change
  103. !Ann_Mud_Backhead_section%Array(kloc)= no change
  104. Ann_RemainedVolume_in_LastSection%Array(kloc)= (0.0)
  105. Ann_EmptyVolume_inBackheadLocation%Array(kloc)= (0.0)
  106. endif
  107. endif
  108. end subroutine FillingWell_By_BellNipple