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.

Disconnecting_Pipe.f90 4.5 KiB

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