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.3 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(St_MudDischarged_Volume%Array(:)) - sum(PipeSection_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. imud=1
  40. Do
  41. if(St_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then
  42. ExcessMudVolume_Remained= ExcessMudVolume_Remained- St_MudDischarged_Volume%Array(imud)
  43. call St_MudDischarged_Volume%Remove (imud)
  44. call St_Mud_Backhead_X%Remove (imud)
  45. call St_Mud_Backhead_section%Remove (imud)
  46. call St_Mud_Forehead_X%Remove (imud)
  47. call St_Mud_Forehead_section%Remove (imud)
  48. call St_Density%Remove (imud)
  49. call St_RemainedVolume_in_LastSection%Remove (imud)
  50. call St_EmptyVolume_inBackheadLocation%Remove (imud)
  51. call St_MudOrKick%Remove (imud)
  52. elseif(St_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then
  53. St_MudDischarged_Volume%Array(imud)= St_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained
  54. exit
  55. else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained)
  56. call St_MudDischarged_Volume%Remove (imud)
  57. call St_Mud_Backhead_X%Remove (imud)
  58. call St_Mud_Backhead_section%Remove (imud)
  59. call St_Mud_Forehead_X%Remove (imud)
  60. call St_Mud_Forehead_section%Remove (imud)
  61. call St_Density%Remove (imud)
  62. call St_RemainedVolume_in_LastSection%Remove (imud)
  63. call St_EmptyVolume_inBackheadLocation%Remove (imud)
  64. call St_MudOrKick%Remove (imud)
  65. exit
  66. endif
  67. enddo
  68. !=================Disconnecting Pipe from the String - End===================
  69. endif
  70. end subroutine DisconnectingPipe