subroutine DisconnectingPipe ! is called in subroutine CirculationCodeSelect Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES USE Pumps_VARIABLES use CDrillWatchVariables ! !use CTanksVariables, TripTankVolume2 => DrillingWatch%TripTankVolume, TripTankDensity2 => TripTankDensity USE sROP_Other_Variables USE sROP_Variables Use KickVariables USE TD_DrillStemComponents Use CKellyConnectionEnumVariables Use CUnityOutputs USE CManifolds implicit none Real(8) ExcessMudVolume, ExcessMudVolume_Remained write(*,*) 'DisconnectingPipe' !TD_RemoveVolume= TD_RemoveVolume* 7.48051948 ! ft^3 to gal ExcessMudVolume= sum(MudSystemDotSt_MudDischarged_Volume%Array(:)) - sum(MudSystemDotPipeSection_VolumeCapacity(2:F_StringIntervalCounts)) ! ======if(ExcessMudVolume <= 0.) No Modification Needed Because Removed Pipe was Empty===== if (Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and. Manifold%Valve(56)%Status == .False.) ExcessMudVolume= 0.d0 !Valve(56)%Status == .False. :: safety valve installed if (ExcessMudVolume > 0.) then if ( Manifold%Valve(53)%Status == .true. ) then MudBucketVolume= ExcessMudVolume else MudBucketVolume= 0.0 endif !========================Flow Disconnect Unity Input Signals================= !if ( Get_JointConnectionPossible() == .false. ) then if (Get_KellyConnection() == KELLY_CONNECTION_NOTHING) then Call Set_FlowKellyDisconnect(.true.) else Call Set_FlowPipeDisconnect(.true.) endif !endif !====================Flow Disconnect Unity Input Signals-End================= !========================Disconnecting Pipe from the String================= ExcessMudVolume_Remained= ExcessMudVolume ! ft^3 to gal MudSystemDotimud=1 Do if(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) < ExcessMudVolume_Remained) then ExcessMudVolume_Remained= ExcessMudVolume_Remained- MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) call MudSystemDotSt_MudDischarged_Volume%Remove (MudSystemDotimud) call MudSystemDotSt_Mud_Backhead_X%Remove (MudSystemDotimud) call St_Mud_Backhead_section%Remove (MudSystemDotimud) call MudSystemDotSt_Mud_Forehead_X%Remove (MudSystemDotimud) call St_Mud_Forehead_section%Remove (MudSystemDotimud) call St_Density%Remove (MudSystemDotimud) call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) call St_MudOrKick%Remove (MudSystemDotimud) elseif(MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud) > ExcessMudVolume_Remained) then MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)= MudSystemDotSt_MudDischarged_Volume%Array(MudSystemDotimud)- ExcessMudVolume_Remained exit else !(St_MudDischarged_Volume%Array(imud) == ExcessMudVolume_Remained) call MudSystemDotSt_MudDischarged_Volume%Remove (MudSystemDotimud) call MudSystemDotSt_Mud_Backhead_X%Remove (MudSystemDotimud) call St_Mud_Backhead_section%Remove (MudSystemDotimud) call MudSystemDotSt_Mud_Forehead_X%Remove (MudSystemDotimud) call St_Mud_Forehead_section%Remove (MudSystemDotimud) call St_Density%Remove (MudSystemDotimud) call MudSystemDotSt_RemainedVolume_in_LastSection%Remove (MudSystemDotimud) call MudSystemDotSt_EmptyVolume_inBackheadLocation%Remove (MudSystemDotimud) call St_MudOrKick%Remove (MudSystemDotimud) exit endif enddo !=================Disconnecting Pipe from the String - End=================== endif end subroutine DisconnectingPipe