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.
 
 
 
 
 
 

108 lines
4.7 KiB

  1. subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect
  2. Use GeoElements_FluidModule
  3. USE CMudPropertiesVariables
  4. USE MudSystemVARIABLES
  5. USE Pumps_VARIABLES
  6. use CDrillWatchVariables
  7. ! !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  8. USE sROP_Other_Variables
  9. USE sROP_Variables
  10. Use KickVariables
  11. USE TD_DrillStemComponents
  12. Use CKellyConnectionEnumVariables
  13. Use CUnityOutputs
  14. USE CManifolds
  15. implicit none
  16. Real(8) ExcessMudVolume, ExcessMudVolume_Remained
  17. write(*,*) 'DisconnectingPipe'
  18. !TD_RemoveVolume= TD_RemoveVolume* 7.48051948 ! ft^3 to gal
  19. ExcessMudVolume= sum(MudSystemDotSt_MudDischarged_Volume%Array(:)) - sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts))
  20. ! ======if(ExcessMudVolume <= 0.) No Modification Needed Because Removed Pipe was Empty=====
  21. if (Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and. Manifold%Valve(56)%Status == .False.) ExcessMudVolume= 0.d0 !Valve(56)%Status == .False. :: safety valve installed
  22. if (ExcessMudVolume > 0.) then
  23. if ( Manifold%Valve(53)%Status == .true. ) then
  24. MudBucketVolume= ExcessMudVolume
  25. else
  26. MudBucketVolume= 0.0
  27. endif
  28. !========================Flow Disconnect Unity Input Signals=================
  29. !if ( Get_JointConnectionPossible() == .false. ) then
  30. if (Get_KellyConnection() == KELLY_CONNECTION_NOTHING) then
  31. Call Set_FlowKellyDisconnect(.true.)
  32. else
  33. Call Set_FlowPipeDisconnect(.true.)
  34. endif
  35. !endif
  36. !====================Flow Disconnect Unity Input Signals-End=================
  37. !========================Disconnecting Pipe from the String=================
  38. ExcessMudVolume_Remained= ExcessMudVolume ! ft^3 to gal
  39. MudSystemDotimud=1
  40. Do
  41. if(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) < ExcessMudVolume_Remained) then
  42. ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)
  43. call MudSystemDotSt_MudDischarged_Volume%Remove (MudSystemDotimud)
  44. call MudSystemDotSt_Mud_Backhead_X%Remove (MudSystemDotimud)
  45. call St_Mud_Backhead_section%Remove (MudSystemDotimud)
  46. call MudSystemDotSt_Mud_Forehead_X%Remove (MudSystemDotimud)
  47. call St_Mud_Forehead_section%Remove (MudSystemDotimud)
  48. call St_Density%Remove (MudSystemDotimud)
  49. call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (MudSystemDotimud)
  50. call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud)
  51. call St_MudOrKick%Remove (MudSystemDotimud)
  52. elseif(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) > ExcessMudVolume_Remained) then
  53. MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- ExcessMudVolume_Remained
  54. exit
  55. else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained)
  56. call MudSystemDotSt_MudDischarged_Volume%Remove (MudSystemDotimud)
  57. call MudSystemDotSt_Mud_Backhead_X%Remove (MudSystemDotimud)
  58. call St_Mud_Backhead_section%Remove (MudSystemDotimud)
  59. call MudSystemDotSt_Mud_Forehead_X%Remove (MudSystemDotimud)
  60. call St_Mud_Forehead_section%Remove (MudSystemDotimud)
  61. call St_Density%Remove (MudSystemDotimud)
  62. call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (MudSystemDotimud)
  63. call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud)
  64. call St_MudOrKick%Remove (MudSystemDotimud)
  65. exit
  66. endif
  67. enddo
  68. !=================Disconnecting Pipe from the String - End===================
  69. endif
  70. end subroutine DisconnectingPipe