SUBROUTINE Utube !! This subroutine calculates flow rate when pump is off, pump is disconnected from drill pipe !! and both annulus and drill pipe are exposed to atmosphere pressure and thus a U-tube situation is occurs !! Record of revisions !! Date Programmer Discription of change !! ------ ------------ ----------------------- !! 1396/07/29 Sheikh Original code !! 1396/08/09 Sheikh Two-side U-tube !! USE FricPressDropVarsModule USE MudSystemVARIABLES use UTUBEVARSModule USE Fluid_Flow_Startup_Vars IMPLICIT NONE INTEGER :: i ,j, ibit , ij , ijk REAL :: AreaBeforeBit !!! Area of element before bit in U-Tube condition [in^2] UTUBEVARS%QUTubeInput = 1.0 UTUBEVARS%QUTubeOutput = 1.0 FricPressDropVars%TotFricPressLoss = 0 BitPressLoss = 0 UTUBEVARS%PressureDp = 0 UTUBEVARS%PressureAnn = 0 !!!!!!!!!!!!!!!!!!!!!! Bit !!!!!!!!!!!! Calculating Pressure at the bottom of drill string from mud columns in drill pipes and annulus space UTUBEVARS%PressureDp = SUM(FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%StringLastEl)%StaticPressDiff) UTUBEVARS%PressureAnn = SUM(FlowEl(FricPressDropVars%AnnulusFirstEl : FricPressDropVars%AnnulusLastEl)%StaticPressDiff) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! U tube:: flow from string to annulus IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > UTubePressTolerance) THEN DO ijk = 1 , 10 FlowEl(FricPressDropVars%StringFirstEl : FricPressDropVars%AnnulusLastEl)%Flowrate = UTUBEVARS%QUTubeInput !WRITE (*,*) 'QUTubeInput', FlowEl(AnnulusLastEl)%Flowrate DO ij = FricPressDropVars%StringFirstEl , FricPressDropVars%AnnulusLastEl !!!!! Updating values of flowrates CALL FricPressDrop(ij) CALL PartialDerivativeFricToFlowRate(ij) !WRITE (*,*) 'FricPressDrop, PartialDerivative', FlowEl(ij)%FricPressLoss, FlowEl(ij)%FricToQPartialDiff, FlowEl(ij)%Length END DO !!!!!!!!!!!!!! Bit pressure drop calculation IF (BitTrue) THEN i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2 BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2 END IF !!!!!!!!!!!!!!!!!!!!!!!!!!! i = FricPressDropVars%NoHorizontalEl + 1 j = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl FricPressDropVars%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) <= UTubePressTolerance .OR. UTUBEVARS%QUTubeInput < 1.0) EXIT ! tolerance set to 1.0 psi IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) > FricPressDropVars%TotFricPressLoss) THEN UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) ELSE IF ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) < FricPressDropVars%TotFricPressLoss) THEN UTUBEVARS%QUTubeInput = UTUBEVARS%QUTubeInput + ((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff) END IF !WRITE (*,*) 'QUTubeInput, TotFricPressLoss', QUTubeInput, TotFricPressLoss !WRITE (*,*) '1) PressureDp, PressureAnn', PressureDp, PressureAnn, TotFricPressLoss, QUTubeInput END DO UTUBEVARS%QUTubeOutput = 0.0 !!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! U tube:: flow from annulus to string ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > UTubePressTolerance) THEN DO ijk = 1 , 10 DO ij = FricPressDropVars%NoHorizontalEl + 1 , FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl !!!!! Updating values of flowrates FlowEl(ij)%Flowrate = UTUBEVARS%QUTubeOutput CALL FricPressDrop(ij) CALL PartialDerivativeFricToFlowRate(ij) END DO !!!!!!!!!!!!!! Bit pressure drop calculation IF (BitTrue) THEN i = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + 1 AreaBeforeBit = FlowEl(i)%Area * Convfttoinch**2 BitPressLoss = FlowEl(i)%density * Convft3toUSgal * (FlowEl(i)%vel**2 * ((AreaBeforeBit/BitTotNozzArea)**2 - 1.)) / 2. / Convlbftolbm / Convfttoinch**2 END IF !!!!!!!!!!!!!!!!!!!!!!!!!!! i = FricPressDropVars%NoHorizontalEl + 1 j = FricPressDropVars%NoHorizontalEl + FricPressDropVars%NoStringEl + FricPressDropVars%NoAnnulusEl FricPressDropVars%TotFricPressLoss = SUM(FlowEl(i : j)%FricPressLoss) + BitPressLoss IF (ABS((UTUBEVARS%PressureDp - UTUBEVARS%PressureAnn) - FricPressDropVars%TotFricPressLoss) <= UTubePressTolerance) EXIT ! tolerance set to 1.0 psi IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) > FricPressDropVars%TotFricPressLoss) THEN UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput - (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) ELSE IF ((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) < FricPressDropVars%TotFricPressLoss) THEN UTUBEVARS%QUTubeOutput = UTUBEVARS%QUTubeOutput + (((UTUBEVARS%PressureAnn - UTUBEVARS%PressureDp) - FricPressDropVars%TotFricPressLoss) / SUM(FlowEl(i : j)%FricToQPartialDiff)) END IF !WRITE (*,*) 'QUTubeOutput, TotFricPressLoss', QUTubeOutput, TotFricPressLoss WRITE (*,*) '2) PressureDp, PressureAnn', UTUBEVARS%PressureDp, UTUBEVARS%PressureAnn, FricPressDropVars%TotFricPressLoss END DO UTUBEVARS%QUTubeInput = 0.0 !!!!!!!!!!!! No U-Tube ELSE UTUBEVARS%QUTubeInput = 0.0 UTUBEVARS%QUTubeOutput = 0.0 END IF END SUBROUTINE