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.

Kick_Influx.i90 9.0 KiB

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. # 1 "/home/admin/SimulationCore2/Equipments/MudSystem/Kick_Influx.f90"
  2. subroutine Kick_Influx ! is called in subroutine CirculationCodeSelect
  3. Use GeoElements_FluidModule
  4. USE CMudPropertiesVariables
  5. USE MudSystemVARIABLES
  6. use SimulationVariables !@@@
  7. use SimulationVariables
  8. use SimulationVariables !@
  9. !use CTanks
  10. ! !@use ConfigurationVariables, TripTankVolume2 => data%Equipments%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  11. USE sROP_Other_Variables
  12. USE sROP_Variables
  13. use KickVARIABLESModule
  14. implicit none
  15. !===========================================================WELL============================================================
  16. !===========================================================WELL============================================================
  17. !write(*,*) 'Kick Influx'
  18. !=================== Bottom Hole Kick Influx ENTRANCE(due to Kick) ===================
  19. data%State%MudSystem%Kick_Density= 2
  20. data%State%MudSystem%NewInflux_Density= data%State%MudSystem%Kick_Density
  21. if ( data%State%MudSystem%NewInfluxElementCreated==0 ) then ! new kick is pumped- (it is set to zero in sheykh subroutine after a new kick influx)
  22. call data%State%MudSystem%Op_Density%AddToFirst (data%State%MudSystem%NewInflux_Density)
  23. call data%State%MudSystem%Op_MudDischarged_Volume%AddToFirst (0.0d0)
  24. call data%State%MudSystem%Op_Mud_Forehead_X%AddToFirst (data%State%MudSystem%Xstart_OpSection(1))
  25. call data%State%MudSystem%Op_Mud_Forehead_section%AddToFirst (1)
  26. call data%State%MudSystem%Op_Mud_Backhead_X%AddToFirst (data%State%MudSystem%Xstart_OpSection(1))
  27. call data%State%MudSystem%Op_Mud_Backhead_section%AddToFirst (1)
  28. call data%State%MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
  29. call data%State%MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
  30. call data%State%MudSystem%Op_MudOrKick%AddToFirst (data%State%MudSystem%NewInfluxNumber) ! KickNumber= NewInfluxNumber
  31. data%State%MudSystem%NewInfluxElementCreated= 1
  32. endif
  33. data%State%MudSystem%Op_MudDischarged_Volume%Array(1)= data%State%MudSystem%Op_MudDischarged_Volume%Array(1)+ ((KickVARIABLES%GasKickPumpFlowRate/60.0d0)*data%State%MudSystem%DeltaT_Mudline) !(gal) due to KickFlux
  34. !write(*,*) 'kick volume ok=' , Op_MudDischarged_Volume%Array(1)
  35. end subroutine Kick_Influx
  36. subroutine Instructor_CirculationMud_Edit ! is called in subroutine CirculationCodeSelect
  37. use KickVARIABLESModule
  38. USE MudSystemVARIABLES
  39. use SimulationVariables !@@@
  40. USE TD_DrillStemComponents
  41. Use CUnityInputs
  42. Use CUnityOutputs
  43. use OperationScenariosModule
  44. use UTUBEVARSModule
  45. use sROP_Variables
  46. use sROP_Other_Variables
  47. use CDownHoleVariables
  48. implicit none
  49. if ( data%Equipments%DownHole%AnnDrillMud == .true. .and. (data%State%ROP_Bit%RateOfPenetration>0. .and. data%State%MudSystem%DeltaVolumeOp>0.0) ) then
  50. do imud= 1, data%State%MudSystem%Ann_Density%Length()
  51. if ( data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then
  52. data%State%MudSystem%Ann_Density%Array(imud)= (data%State%MudSystem%St_Density%Last() * data%State%MudSystem%AnnulusFlowRate + 141.4296E-4*data%State%ROP_Bit%RateOfPenetration*data%State%ROP_Spec%DiameterOfBit**2)/(data%State%MudSystem%AnnulusFlowRate+6.7995E-4*data%State%ROP_Bit%RateOfPenetration*data%State%ROP_Spec%DiameterOfBit**2)
  53. data%State%MudSystem%Ann_CuttingMud%Array(imud)= 1
  54. endif
  55. enddo
  56. endif
  57. if ( data%Equipments%DownHole%AnnCirculateMud == .true. ) then
  58. do imud= 1, data%State%MudSystem%Ann_Density%Length()
  59. if ( data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0 ) then
  60. data%State%MudSystem%Ann_Density%Array(imud)= data%State%MudSystem%ActiveTankDensity
  61. data%State%MudSystem%Ann_CuttingMud%Array(imud)= 0
  62. endif
  63. enddo
  64. do imud= 1, data%State%MudSystem%St_Density%Length()
  65. data%State%MudSystem%St_Density%Array(imud)= data%State%MudSystem%ActiveTankDensity
  66. enddo
  67. endif
  68. end subroutine Instructor_CirculationMud_Edit
  69. subroutine ShoeLostSub ! is called in subroutine CirculationCodeSelect
  70. use KickVARIABLESModule
  71. USE MudSystemVARIABLES
  72. use SimulationVariables !@@@
  73. USE TD_DrillStemComponents
  74. Use CUnityInputs
  75. Use CUnityOutputs
  76. use OperationScenariosModule
  77. use UTUBEVARSModule
  78. use sROP_Variables
  79. use sROP_Other_Variables
  80. use CDownHoleVariables
  81. use CShoeVariables
  82. use PressureDisplayVARIABLESModule
  83. use CWarnings
  84. implicit none
  85. data%State%MudSystem%ShoeLost= .false.
  86. data%State%MudSystem%Kickexpansion_DueToMudLost= .false.
  87. data%State%MudSystem%ShoeMudPressure= data%State%PressureDisplay%PressureGauges(5)
  88. data%State%MudSystem%UGBOSuccessionCounter = data%State%MudSystem%UGBOSuccessionCounter + 1
  89. !write(*,*) 'check point 1'
  90. if (data%Configuration%Shoe%InactiveFracture == .FALSE. .AND. ((data%State%MudSystem%ShoeMudPressure >= data%State%MudSystem%FormationLostPressure) .or. data%State%MudSystem%ShoeFractured )) then
  91. !write(*,*) 'check point 2 ,UGBOSuccessionCounter' , UGBOSuccessionCounter
  92. ! if ShoeFractured changed to true , then time counter is not needed more
  93. if ( data%State%MudSystem%UGBOSuccessionCounter /= data%State%MudSystem%UGBOSuccessionCounterOld+1 .and. data%State%MudSystem%ShoeFractured==.false. ) then
  94. data%State%MudSystem%UGBOSuccessionCounter = 0 ! also in starup
  95. data%State%MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup
  96. return
  97. else
  98. data%State%MudSystem%UGBOSuccessionCounterOld= data%State%MudSystem%UGBOSuccessionCounter
  99. endif
  100. if ( data%State%MudSystem%UGBOSuccessionCounter < 10 .and. data%State%MudSystem%ShoeFractured==.false.) then
  101. return
  102. endif
  103. !write(*,*) 'check point 3 ,UGBOSuccessionCounter' , UGBOSuccessionCounter
  104. data%State%MudSystem%ShoeFractured= .true.
  105. data%State%MudSystem%ShoeMudViscosity= MAX(data%State%MudSystem%ShoeMudViscosity, 12.d0)
  106. !write(*,*) 'ShoeMudDensity , ShoeMudViscosity' , ShoeMudDensity , ShoeMudViscosity
  107. data%State%MudSystem%ShoeLostCoef = 10.**(-8) * 1.15741d0 * 7.08d0 * 1000000.d0 * 1.d0 * data%State%MudSystem%ShoeMudDensity / &
  108. (data%State%MudSystem%ShoeMudViscosity * LOG(10000.d0))
  109. !write(*,*) 'lost parameters 1' , ShoeMudPressure , FormationLostPressure
  110. data%State%MudSystem%Qlost = MAX( (data%State%MudSystem%ShoeLostCoef * (data%State%MudSystem%ShoeMudPressure - (data%State%MudSystem%FormationLostPressure/2.0))) , 0.d0 )
  111. if (data%State%MudSystem%Qlost > 0.0) then
  112. data%State%MudSystem%ShoeLost= .true.
  113. else
  114. data%State%MudSystem%ShoeLost= .false.
  115. endif
  116. !write(*,*) 'Qlost=' , Qlost, ShoeMudPressure, FormationLostPressure
  117. call Activate_UndergroundBlowout()
  118. do imud= 1, data%State%MudSystem%Ann_Mud_Forehead_X%Length()
  119. IF ( data%State%MudSystem%ShoeLost .and. data%Configuration%Shoe%ShoeDepth < data%State%MudSystem%Ann_Mud_Backhead_X%Array(imud) .and. data%Configuration%Shoe%ShoeDepth >= data%State%MudSystem%Ann_Mud_Forehead_X%Array(imud) &
  120. .and. data%State%MudSystem%Ann_MudOrKick%Array(imud) == 0 .and. data%State%MudSystem%WellHeadIsOpen == .FALSE. ) then
  121. data%State%MudSystem%Kickexpansion_DueToMudLost= .true.
  122. write(*,*) 'Kickexpansion_DueToMudLost'
  123. EXIT
  124. ENDIF
  125. enddo
  126. endif
  127. if (data%Warnings%UndergroundBlowout == .false.) data%State%MudSystem%ShoeLost= .false.
  128. end subroutine ShoeLostSub