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.
 
 
 
 
 
 

148 lines
5.6 KiB

  1. subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
  2. Use KickVariables
  3. Use MudSystemVARIABLES
  4. USE TD_DrillStemComponents
  5. Use CUnityInputs
  6. Use CUnityOutputs
  7. USE CKellyConnectionEnumVariables
  8. USE UTUBEVARS
  9. use sROP_Variables
  10. USE PressureDisplayVARIABLES
  11. implicit none
  12. Integer i,KickNumber
  13. !NewInfluxNumber = NoGasPocket
  14. MudSystem%Flow_timeCounter= MudSystem%Flow_timeCounter+1
  15. !if (ChokePanelStrokeResetSwitch == 1) then
  16. ! Flow_timeCounter= 0
  17. !endif
  18. !write(*,*) 'Flow_timeCounter' , Flow_timeCounter
  19. !===========================Shoe Lost===============================
  20. call ShoeLostSub
  21. !===================================================================
  22. MudSystem%iLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data)
  23. !KickMigration_2SideBit= .false.
  24. Call Set_FlowPipeDisconnect(.false.)
  25. Call Set_FlowKellyDisconnect(.false.)
  26. call ElementsCreation
  27. if (MUD(8)%Q > 0.0) call FillingWell_By_BellNipple ! Filling Well Through BellNipple ( Path j11 )
  28. !if (MUD(10)%Q > 0.0) call FillingWell_By_Pumps ! Filling Well Through Pumps ( Path j19 )
  29. !write(*,*) 'TD_RemoveVolume,Get_JointConnectionPossible=' , TD_RemoveVolume,Get_JointConnectionPossible()
  30. if (TD_Vol%RemoveVolume > 0.) call DisconnectingPipe !! .and. Get_JointConnectionPossible() == .false.) call DisconnectingPipe
  31. IF (KickFlux .AND. NOT(KickOffBottom)) THEN
  32. call Kick_Influx
  33. endif
  34. IF ( MudSystem%NewInfluxNumber > 0 ) THEN
  35. !write(*,*) 'KickOffBottom , ROP=' , KickOffBottom , ROP_Bit%RateOfPenetration
  36. call Kick_Migration
  37. endif
  38. ! ============================ must be after migration ==============================
  39. DO KickNumber= MudSystem%NewInfluxNumber-NoGasPocket+1 , MudSystem%NewInfluxNumber
  40. ! FINDING NEW KICK LOCATIONS:
  41. MudSystem%Ann_KickLoc= 0
  42. MudSystem%Op_KickLoc= 0
  43. MudSystem%ChokeLine_KickLoc= 0
  44. do i = 1, MudSystem%Ann_MudOrKick%Length ()
  45. if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then
  46. MudSystem%Ann_KickLoc = i
  47. exit
  48. endif
  49. end do
  50. do i = 1, MudSystem%Op_MudOrKick%Length ()
  51. if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then
  52. MudSystem%Op_KickLoc = i
  53. exit
  54. endif
  55. end do
  56. do i = 1, MudSystem%ChokeLine_MudOrKick%Length ()
  57. if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then
  58. MudSystem%ChokeLine_KickLoc = i
  59. exit
  60. endif
  61. end do
  62. ! ============================ must be after migration-end ===========================
  63. IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == MudSystem%NewInfluxNumber .AND. NOT(KickOffBottom) .AND. MudSystem%WellHeadIsOpen) THEN
  64. cycle
  65. ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN
  66. if (((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) > 0.0 .AND. MudSystem%WellHeadIsOpen) .or. MudSystem%Kickexpansion_DueToMudLost) ) call Kick_Expansion
  67. if ((GasPocketDeltaVol%Array(MudSystem%NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. MudSystem%WellHeadIsOpen == .FALSE.) CALL Kick_Contraction
  68. ENDIF
  69. ENDDO
  70. MudSystem%KickNumber = KickNumber
  71. MudSystem%LostInTripOutIsDone= .false.
  72. if( MudSystem%DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then
  73. !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
  74. call Pump_and_TripIn
  75. elseif (MudSystem%DeltaVolumeOp < 0.0) then
  76. ! when we have Utube and tripping out simultaneously, it uses "TripOut_and_Pump" subroutine, and then Utube code is done
  77. ! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in
  78. call TripOut_and_Pump
  79. endif
  80. MudSystem%WellOutletDensity= MudSystem%Ann_Density%Last() ! (ppg) used in MudSystem
  81. if (MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18
  82. call ChokeLineMud
  83. endif
  84. call Choke_GasSound
  85. !WRITE(*,*) 'CIRCU-Ann_Saved_MudDischarged_Volume' , Ann_Saved_MudDischarged_Volume
  86. !****Utube is called in Plot Subroutine****
  87. Call Instructor_CirculationMud_Edit
  88. call PlotFinalMudElements
  89. MudSystem%MudChecked= .true.
  90. MudSystem%UtubePossibility= .true.
  91. !WRITE(*,*) '***********************************************************************'
  92. end subroutine CirculationCodeSelect