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.
 
 
 
 
 
 

217 lines
10 KiB

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