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.
 
 
 
 
 
 

158 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
  13. !NewInfluxNumber = NoGasPocket
  14. MudSystemDotFlow_timeCounter= MudSystemDotFlow_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. MudSystemDotiLoc= 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_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 ( MudSystemDotNewInfluxNumber > 0 ) THEN
  35. !write(*,*) 'KickOffBottom , ROP=' , KickOffBottom , Rate_of_Penetration
  36. call Kick_Migration
  37. endif
  38. ! ============================ must be after migration ==============================
  39. DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystemDotNewInfluxNumber
  40. ! FINDING NEW KICK LOCATIONS:
  41. MudSystemDotAnn_KickLoc= 0
  42. MudSystemDotOp_KickLoc= 0
  43. MudSystemDotChokeLine_KickLoc= 0
  44. do i = 1, Ann_MudOrKick%Length ()
  45. if (Ann_MudOrKick%Array(i) == MudSystemDotKickNumber) then
  46. MudSystemDotAnn_KickLoc = i
  47. exit
  48. endif
  49. end do
  50. do i = 1, Op_MudOrKick%Length ()
  51. if (Op_MudOrKick%Array(i) == MudSystemDotKickNumber) then
  52. MudSystemDotOp_KickLoc = i
  53. exit
  54. endif
  55. end do
  56. do i = 1, ChokeLine_MudOrKick%Length ()
  57. if (ChokeLine_MudOrKick%Array(i) == MudSystemDotKickNumber) then
  58. MudSystemDotChokeLine_KickLoc = i
  59. exit
  60. endif
  61. end do
  62. ! ============================ must be after migration-end ===========================
  63. IF (ALLOCATED(GasPocketWeight%Array) .and. MudSystemDotKickNumber == MudSystemDotNewInfluxNumber .AND. NOT(KickOffBottom) .AND. WellHeadIsOpen) THEN
  64. cycle
  65. ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN
  66. if (((GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) > 0.0 .AND. WellHeadIsOpen) .or. MudSystemDotKickexpansion_DueToMudLost) ) call Kick_Expansion
  67. if ((GasPocketDeltaVol%Array(MudSystemDotNewInfluxNumber - MudSystemDotKickNumber + 1) < 0.0 ) .OR. WellHeadIsOpen == .FALSE.) CALL Kick_Contraction
  68. ENDIF
  69. ENDDO
  70. MudSystemDotLostInTripOutIsDone= .false.
  71. if( MudSystemDotDeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then
  72. !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
  73. call Pump_and_TripIn
  74. elseif (MudSystemDotDeltaVolumeOp < 0.0) then
  75. ! when we have Utube and tripping out simultaneously, it uses "TripOut_and_Pump" subroutine, and then Utube code is done
  76. ! "Utube" and "Pump_and_TripIn" subroutines, not to be used simultaneously because "Utube" code supports trip in
  77. call TripOut_and_Pump
  78. endif
  79. WellOutletDensity= Ann_Density%Last() ! (ppg) used in MudSystem
  80. if (MUD(4)%Q > 0.) then ! ( j4 > 0 ) ! THIS CIRCULATION CODE IS JUST FOR LINE J4, AND NOT NEEDED FOR LINE J18
  81. call ChokeLineMud
  82. endif
  83. call Choke_GasSound
  84. !WRITE(*,*) 'CIRCU-Ann_Saved_MudDischarged_Volume' , Ann_Saved_MudDischarged_Volume
  85. ! ****Utube is called in Plot Subroutine****
  86. Call Instructor_CirculationMud_Edit
  87. call PlotFinalMudElements
  88. MudChecked= .true.
  89. MudSystemDotUtubePossibility= .true.
  90. !WRITE(*,*) '***********************************************************************'
  91. end subroutine CirculationCodeSelect