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

  1. subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect
  2. Use GeoElements_FluidModule
  3. USE CMudPropertiesVariables
  4. USE MudSystemVARIABLES
  5. use SimulationVariables
  6. ! !use CTanks
  7. !@use ConfigurationVariables, TripTankVolume2 => data%Equipments%DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity
  8. USE sROP_Other_Variables
  9. USE sROP_Variables
  10. use KickVARIABLESModule
  11. USE TD_DrillStemComponents
  12. use OperationScenariosModule
  13. Use UnityModule
  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(data%State%MudSystem%St_MudDischarged_Volume%Array(:)) - sum(data%State%MudSystem%PipeSection_VolumeCapacity(2:data%State%F_Counts%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. data%State%MudSystem%MudBucketVolume= ExcessMudVolume
  25. else
  26. data%State%MudSystem%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(data%State%MudSystem%St_MudDischarged_Volume%Array(imud) < ExcessMudVolume_Remained) then
  42. ExcessMudVolume_Remained= ExcessMudVolume_Remained- data%State%MudSystem%St_MudDischarged_Volume%Array(imud)
  43. call data%State%MudSystem%St_MudDischarged_Volume%Remove (imud)
  44. call data%State%MudSystem%St_Mud_Backhead_X%Remove (imud)
  45. call data%State%MudSystem%St_Mud_Backhead_section%Remove (imud)
  46. call data%State%MudSystem%St_Mud_Forehead_X%Remove (imud)
  47. call data%State%MudSystem%St_Mud_Forehead_section%Remove (imud)
  48. call data%State%MudSystem%St_Density%Remove (imud)
  49. call data%State%MudSystem%St_RemainedVolume_in_LastSection%Remove (imud)
  50. call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud)
  51. call data%State%MudSystem%St_MudOrKick%Remove (imud)
  52. elseif(data%State%MudSystem%St_MudDischarged_Volume%Array(imud) > ExcessMudVolume_Remained) then
  53. data%State%MudSystem%St_MudDischarged_Volume%Array(imud)= data%State%MudSystem%St_MudDischarged_Volume%Array(imud)- ExcessMudVolume_Remained
  54. exit
  55. else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained)
  56. call data%State%MudSystem%St_MudDischarged_Volume%Remove (imud)
  57. call data%State%MudSystem%St_Mud_Backhead_X%Remove (imud)
  58. call data%State%MudSystem%St_Mud_Backhead_section%Remove (imud)
  59. call data%State%MudSystem%St_Mud_Forehead_X%Remove (imud)
  60. call data%State%MudSystem%St_Mud_Forehead_section%Remove (imud)
  61. call data%State%MudSystem%St_Density%Remove (imud)
  62. call data%State%MudSystem%St_RemainedVolume_in_LastSection%Remove (imud)
  63. call data%State%MudSystem%St_EmptyVolume_inBackheadLocation%Remove (imud)
  64. call data%State%MudSystem%St_MudOrKick%Remove (imud)
  65. exit
  66. endif
  67. enddo
  68. !=================Disconnecting Pipe from the String - End===================
  69. endif
  70. end subroutine DisconnectingPipe