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.
 
 
 
 
 
 

110 lines
4.9 KiB

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