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.i90 4.8 KiB

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