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.8 KiB

  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/MudSystem/Circulation_Code_Select.f90"
  2. subroutine CirculationCodeSelect ! is called in subroutine Fluid_Flow_Solver
  3. use KickVARIABLESModule
  4. USE MudSystemVARIABLES
  5. use SimulationVariables !@@@
  6. USE TD_DrillStemComponents
  7. use OperationScenariosModule
  8. use UTUBEVARSModule
  9. use sROP_Variables
  10. use PressureDisplayVARIABLESModule
  11. use UnityModule
  12. implicit none
  13. Integer i,KickNumber
  14. !NewInfluxNumber = NoGasPocket
  15. data%State%MudSystem%Flow_timeCounter= data%State%MudSystem%Flow_timeCounter+1
  16. !if (ChokePanelStrokeResetSwitch == 1) then
  17. ! Flow_timeCounter= 0
  18. !endif
  19. !write(*,*) 'Flow_timeCounter' , Flow_timeCounter
  20. !===========================Shoe Lost===============================
  21. call ShoeLostSub
  22. !===================================================================
  23. data%State%MudSystem%iLoc= 1 ! will be changed in KickFlux and Migration or Pump and TripIn (save OP Mud data)
  24. !KickMigration_2SideBit= .false.
  25. Call Set_FlowPipeDisconnect(.false.)
  26. Call Set_FlowKellyDisconnect(.false.)
  27. call ElementsCreation
  28. if (data%State%MUD(8)%Q > 0.0) call FillingWell_By_BellNipple ! Filling Well Through BellNipple ( Path j11 )
  29. !if (data%State%MUD(10)%Q > 0.0) call FillingWell_By_Pumps ! Filling Well Through Pumps ( Path j19 )
  30. !write(*,*) 'TD_RemoveVolume,Get_JointConnectionPossible=' , TD_RemoveVolume,Get_JointConnectionPossible()
  31. if (data%State%TD_Vol%RemoveVolume > 0.) call DisconnectingPipe !! .and. Get_JointConnectionPossible() == .false.) call DisconnectingPipe
  32. IF (KickVARIABLES%KickFlux .AND. NOT(KickVARIABLES%KickOffBottom)) THEN
  33. call Kick_Influx
  34. endif
  35. IF ( data%State%MudSystem%NewInfluxNumber > 0 ) THEN
  36. call Kick_Migration
  37. endif
  38. ! ============================ must be after migration ==============================
  39. DO KickNumber= data%State%MudSystem%NewInfluxNumber-KickVARIABLES%NoGasPocket+1 , data%State%MudSystem%NewInfluxNumber
  40. ! FINDING NEW KICK LOCATIONS:
  41. data%State%MudSystem%Ann_KickLoc= 0
  42. data%State%MudSystem%Op_KickLoc= 0
  43. data%State%MudSystem%ChokeLine_KickLoc= 0
  44. do i = 1, data%State%MudSystem%Ann_MudOrKick%Length ()
  45. if (data%State%MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then
  46. data%State%MudSystem%Ann_KickLoc = i
  47. exit
  48. endif
  49. end do
  50. do i = 1, data%State%MudSystem%Op_MudOrKick%Length ()
  51. if (data%State%MudSystem%Op_MudOrKick%Array(i) == KickNumber) then
  52. data%State%MudSystem%Op_KickLoc = i
  53. exit
  54. endif
  55. end do
  56. do i = 1, data%State%MudSystem%ChokeLine_MudOrKick%Length ()
  57. if (data%State%MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then
  58. data%State%MudSystem%ChokeLine_KickLoc = i
  59. exit
  60. endif
  61. end do
  62. ! ============================ must be after migration-end ===========================
  63. IF (ALLOCATED(GasPocketWeight%Array) .and. KickNumber == data%State%MudSystem%NewInfluxNumber .AND. NOT(KickVARIABLES%KickOffBottom) .AND. data%State%MudSystem%WellHeadIsOpen) THEN
  64. cycle
  65. ELSE IF (ALLOCATED(GasPocketWeight%Array)) THEN
  66. if (((GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - KickNumber + 1) > 0.0 .AND. data%State%MudSystem%WellHeadIsOpen) .or. data%State%MudSystem%Kickexpansion_DueToMudLost) ) call Kick_Expansion
  67. if ((GasPocketDeltaVol%Array(data%State%MudSystem%NewInfluxNumber - KickNumber + 1) < 0.0 ) .OR. data%State%MudSystem%WellHeadIsOpen == .FALSE.) CALL Kick_Contraction
  68. ENDIF
  69. ENDDO
  70. data%State%MudSystem%KickNumber = KickNumber
  71. data%State%MudSystem%LostInTripOutIsDone= .false.
  72. if( data%State%MudSystem%DeltaVolumeOp >= 0.0 .and. Get_KellyConnection()==KELLY_CONNECTION_STRING) then
  73. !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp
  74. call Pump_and_TripIn
  75. elseif (data%State%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. data%State%MudSystem%WellOutletDensity= data%State%MudSystem%Ann_Density%Last() ! (ppg) used in MudSystem
  81. if (data%State%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. data%State%MudSystem%MudChecked= .true.
  90. data%State%MudSystem%UtubePossibility= .true.
  91. !WRITE(*,*) '***********************************************************************'
  92. end subroutine CirculationCodeSelect