SUBROUTINE Utube1_and_TripIn ! is called in subroutine CirculationCodeSelect string to annulus Use UTUBEVARS Use GeoElements_FluidModule USE CMudPropertiesVariables USE MudSystemVARIABLES USE Pump_VARIABLES USE sROP_Variables use CDrillWatchVariables use CTanksVariables, TripTankVolume2 => TripTankVolume, TripTankDensity2 => TripTankDensity Use CShoeVariables Use CUnityOutputs implicit none write(*,*) 'Utube1 code' !===========================================================WELL============================================================ !===========================================================WELL============================================================ UtubeMode1Activated= .true. !write(*,*) 'QUTubeInput=' , QUTubeInput !Qinput=5000. StringFlowRate= QUTubeInput ! (gpm) AnnulusFlowRate= QUTubeInput StringFlowRateFinal= StringFlowRate AnnulusFlowRateFinal= AnnulusFlowRate !=========================================== if (FirstSetUtube1==0) then ! call St_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval(1:F_StringIntervalCounts)%Volume))) !startup initial ! call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) ! call St_Mud_Backhead_section%AddToFirst (1) ! call St_Mud_Forehead_X%AddToFirst (Xend_PipeSection(F_StringIntervalCounts)) ! call St_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts) ! call St_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) ! call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! ! call Ann_MudDischarged_Volume%AddToFirst (REAL(sum(F_Interval((F_StringIntervalCounts+F_BottomHoleIntervalCounts+1):F_IntervalsTotalCounts)%Volume))) !startup initial ! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) ! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) ! call Ann_Mud_Forehead_X%AddToFirst (Xend_PipeSection(NoPipeSections)) ! call Ann_Mud_Forehead_section%AddToFirst (NoPipeSections) ! call Ann_Density%AddToFirst (REAL(ActiveDensity)) ! initial(ppg) ! call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) !Hz_Density%Array(:)= 0.0 !commented !Hz_MudOrKick%Array(:)= 104 !commented Hz_Density_Utube= 0.0 Hz_MudOrKick_Utube= 104 FirstSetUtube1= 1 endif !========================Horizontal PIPE ENTRANCE================= !if (SuctionDensity_Old >= (ActiveDensity+0.05) .or. SuctionDensity_Old <= (ActiveDensity-0.05)) then ! new mud is pumped ! !ImudCount= ImudCount+1 ! !SuctionMud= ImudCount ! call Hz_Density%AddToFirst (REAL(ActiveDensity)) !ActiveDensity : badan in moteghayer bayad avaz beshe ! call Hz_MudDischarged_Volume%AddToFirst (0.0d0) ! call Hz_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(1)) ! call Hz_Mud_Forehead_section%AddToFirst (1) ! call Hz_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(1)) ! call Hz_Mud_Backhead_section%AddToFirst (1) ! call Hz_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Hz_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! call Hz_MudOrKick%AddToFirst (0) ! ! SuctionDensity_Old= ActiveDensity !endif !========================Horizontal PIPE STRING================= !commented ! Hz_MudDischarged_Volume%Array(1)= Hz_MudDischarged_Volume%Array(1)+ ((StringFlowRate/60.)*DeltaT_Mudline) !(gal) ! !imud=0 ! do while (imud < Hz_Mud_Forehead_X%Length()) ! imud = imud + 1 ! ! if (imud> 1) then ! Hz_Mud_Backhead_X%Array(imud)= Hz_Mud_Forehead_X%Array(imud-1) ! Hz_Mud_Backhead_section%Array(imud)= Hz_Mud_Forehead_section%Array(imud-1) ! endif ! ! ! DirectionCoef= (Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Hz_Mud_Backhead_section%Array(imud))) & ! / ABS(Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Hz_Mud_Backhead_section%Array(imud))) ! ! +1 for string , -1 for annulus ! ! ! Hz_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_PipeSection(Hz_Mud_Backhead_section%Array(imud))- Hz_Mud_Backhead_X%Array(imud))* & ! Area_PipeSectionFt(Hz_Mud_Backhead_section%Array(imud)) !(ft^3) ! Hz_EmptyVolume_inBackheadLocation%Array(imud)= Hz_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948 ! ft^3 to gal ! ! ! if ( Hz_MudDischarged_Volume%Array(imud) <= Hz_EmptyVolume_inBackheadLocation%Array(imud)) then ! Hz_Mud_Forehead_section%Array(imud)= Hz_Mud_Backhead_section%Array(imud) ! Hz_Mud_Forehead_X%Array(imud)= Hz_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Hz_MudDischarged_Volume%Array(imud)/7.48051948)/Area_PipeSectionFt(Hz_Mud_Backhead_section%Array(imud)) ! ! 7.48 is for gal to ft^3 ! else ! ! isection= Hz_Mud_Backhead_section%Array(imud)+1 ! Hz_RemainedVolume_in_LastSection%Array(imud)= Hz_MudDischarged_Volume%Array(imud)- Hz_EmptyVolume_inBackheadLocation%Array(imud) ! ! do ! if (isection > 1) then ! (horizontal pipe exit) ! Hz_MudDischarged_Volume%Array(imud)= Hz_MudDischarged_Volume%Array(imud)- Hz_RemainedVolume_in_LastSection%Array(imud) ! Hz_Mud_Forehead_X%Array(imud)= Xend_PipeSection(1) ! Hz_Mud_Forehead_section%Array(imud)= 1 ! if (Hz_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string ! call Hz_MudDischarged_Volume%Remove (imud) ! call Hz_Mud_Backhead_X%Remove (imud) ! call Hz_Mud_Backhead_section%Remove (imud) ! call Hz_Mud_Forehead_X%Remove (imud) ! call Hz_Mud_Forehead_section%Remove (imud) ! call Hz_Density%Remove (imud) ! call Hz_RemainedVolume_in_LastSection%Remove (imud) ! call Hz_EmptyVolume_inBackheadLocation%Remove (imud) ! call Hz_MudOrKick%Remove (imud) ! ! endif ! exit ! endif ! ! xx= Hz_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal) ! ! if (xx<= 1.0) then ! Hz_Mud_Forehead_section%Array(imud)= isection ! Hz_Mud_Forehead_X%Array(imud)= (xx * (Xend_PipeSection(isection)- Xstart_PipeSection(isection)))+ Xstart_PipeSection(isection) ! exit ! else ! Hz_RemainedVolume_in_LastSection%Array(imud)= Hz_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection) ! isection= isection+ 1 ! ! ! endif ! ! enddo ! ! endif ! ! enddo !commented !========================Horizontal PIPE END================= !========================STRING ENTRANCE================= !write(*,*) 'a) St_Density%Length()=' , St_Density%Length() if (ABS(St_Density%First() - Hz_Density_Utube) >= DensityMixTol) then ! new mud is pumped call St_Density%AddToFirst (Hz_Density_Utube) call St_MudDischarged_Volume%AddToFirst (0.0d0) call St_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(2)) call St_Mud_Forehead_section%AddToFirst (2) call St_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(2)) call St_Mud_Backhead_section%AddToFirst (2) call St_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call St_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call St_MudOrKick%AddToFirst (Hz_MudOrKick_Utube) ! Hz_MudOrKick%Last() = 104 !StringDensity_Old= Hz_Density_Utube endif !write(*,*) 'b) St_Density%Length()=' , St_Density%Length() !write(*,*) 'b) St_Density%Array(1)=' , St_Density%Array(1) !write(*,*) 'b) St_MudOrKick%Array(1)=' , St_MudOrKick%Array(1) !========================STRING================= !WRITE (*,*) 'Utube1 StringFlowRate', StringFlowRate St_MudDischarged_Volume%Array(1)= St_MudDischarged_Volume%Array(1)+ ((StringFlowRate/60.d0)*DeltaT_Mudline) !(gal) imud=0 do while (imud < St_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then St_Mud_Backhead_X%Array(imud)= St_Mud_Forehead_X%Array(imud-1) St_Mud_Backhead_section%Array(imud)= St_Mud_Forehead_section%Array(imud-1) endif DirectionCoef= (Xend_PipeSection(St_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(St_Mud_Backhead_section%Array(imud))) & / ABS(Xend_PipeSection(St_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(St_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus St_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_PipeSection(St_Mud_Backhead_section%Array(imud))- St_Mud_Backhead_X%Array(imud))* & Area_PipeSectionFt(St_Mud_Backhead_section%Array(imud)) !(ft^3) St_EmptyVolume_inBackheadLocation%Array(imud)= St_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal if ( St_MudDischarged_Volume%Array(imud) <= St_EmptyVolume_inBackheadLocation%Array(imud)) then St_Mud_Forehead_section%Array(imud)= St_Mud_Backhead_section%Array(imud) St_Mud_Forehead_X%Array(imud)= St_Mud_Backhead_X%Array(imud)+ DirectionCoef*(St_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_PipeSectionFt(St_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else isection= St_Mud_Backhead_section%Array(imud)+1 St_RemainedVolume_in_LastSection%Array(imud)= St_MudDischarged_Volume%Array(imud)- St_EmptyVolume_inBackheadLocation%Array(imud) do if (isection > F_StringIntervalCounts) then ! last pipe section(string exit) F_StringIntervalCounts includes Horizontal line St_MudDischarged_Volume%Array(imud)= St_MudDischarged_Volume%Array(imud)- St_RemainedVolume_in_LastSection%Array(imud) St_Mud_Forehead_X%Array(imud)= Xend_PipeSection(F_StringIntervalCounts) St_Mud_Forehead_section%Array(imud)= F_StringIntervalCounts if (St_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the string call RemoveStringMudArrays(imud) endif exit endif xx= St_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal) if (xx<= 1.0) then St_Mud_Forehead_section%Array(imud)= isection St_Mud_Forehead_X%Array(imud)= (xx * (Xend_PipeSection(isection)- Xstart_PipeSection(isection)))+ Xstart_PipeSection(isection) exit else St_RemainedVolume_in_LastSection%Array(imud)= St_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection) isection= isection+ 1 endif enddo endif enddo !========================STRING END================= !========================== tripping in for OP remove =============================== !if (DeltaVolumeOp>0. .and. DeltaVolumeOp< Op_MudDischarged_Volume%Last()) then ! Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length())= Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()) - DeltaVolumeOp !else ! Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()-1)= Op_MudDischarged_Volume%Array(Op_MudDischarged_Volume%Length()-1) - (DeltaVolumeOp-Op_MudDischarged_Volume%Last()) ! ! call Op_MudDischarged_Volume%Remove (Op_MudDischarged_Volume%Length()) ! call Op_Mud_Backhead_X%Remove (Op_MudDischarged_Volume%Length()) ! call Op_Mud_Backhead_section%Remove (Op_MudDischarged_Volume%Length()) ! call Op_Mud_Forehead_X%Remove (Op_MudDischarged_Volume%Length()) ! call Op_Mud_Forehead_section%Remove (Op_MudDischarged_Volume%Length()) ! call Op_Density%Remove (Op_MudDischarged_Volume%Length()) ! call Op_RemainedVolume_in_LastSection%Remove (Op_MudDischarged_Volume%Length()) ! call Op_EmptyVolume_inBackheadLocation%Remove (Op_MudDischarged_Volume%Length()) ! call Op_MudOrKick%Remove (Op_MudDischarged_Volume%Length()) !endif ! !============================= Bottom Hole ============================== !Op_MudDischarged_Volume%Array(1)= Op_MudDischarged_Volume%Array(1)+ ((GasKickPumpFlowRate/60.)*DeltaT_Mudline) !(gal) due to KickFlux imud=0 do while (imud < Op_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then Op_Mud_Backhead_X%Array(imud)= Op_Mud_Forehead_X%Array(imud-1) Op_Mud_Backhead_section%Array(imud)= Op_Mud_Forehead_section%Array(imud-1) endif DirectionCoef= (Xend_OpSection(Op_Mud_Backhead_section%Array(imud))-Xstart_OpSection(Op_Mud_Backhead_section%Array(imud))) & / ABS(Xend_OpSection(Op_Mud_Backhead_section%Array(imud))-Xstart_OpSection(Op_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus Op_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_OpSection(Op_Mud_Backhead_section%Array(imud))- Op_Mud_Backhead_X%Array(imud))* & Area_OpSectionFt(Op_Mud_Backhead_section%Array(imud)) !(ft^3) Op_EmptyVolume_inBackheadLocation%Array(imud)= Op_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal if ( Op_MudDischarged_Volume%Array(imud) <= Op_EmptyVolume_inBackheadLocation%Array(imud)) then Op_Mud_Forehead_section%Array(imud)= Op_Mud_Backhead_section%Array(imud) Op_Mud_Forehead_X%Array(imud)= Op_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Op_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_OpSectionFt(Op_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else isection= Op_Mud_Backhead_section%Array(imud)+1 Op_RemainedVolume_in_LastSection%Array(imud)= Op_MudDischarged_Volume%Array(imud)- Op_EmptyVolume_inBackheadLocation%Array(imud) do if (isection > F_BottomHoleIntervalCounts) then ! last pipe section(well exit) if( imud==1) KickDeltaVinAnnulus= Op_RemainedVolume_in_LastSection%Array(imud) ! Kick enters Annulus space Op_MudDischarged_Volume%Array(imud)= Op_MudDischarged_Volume%Array(imud)- Op_RemainedVolume_in_LastSection%Array(imud) Op_Mud_Forehead_X%Array(imud)= Xend_OpSection(F_BottomHoleIntervalCounts) Op_Mud_Forehead_section%Array(imud)= F_BottomHoleIntervalCounts if (Op_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveOpMudArrays(imud) endif exit endif xx= Op_RemainedVolume_in_LastSection%Array(imud)/ OpSection_VolumeCapacity(isection) !(gal) if (xx<= 1.0) then Op_Mud_Forehead_section%Array(imud)= isection Op_Mud_Forehead_X%Array(imud)= (xx * (Xend_OpSection(isection)- Xstart_OpSection(isection)))+ Xstart_OpSection(isection) exit else Op_RemainedVolume_in_LastSection%Array(imud)= Op_RemainedVolume_in_LastSection%Array(imud)- OpSection_VolumeCapacity(isection) isection= isection+ 1 endif enddo endif if (Op_Mud_Forehead_X%Array(imud)== Xend_OpSection(F_BottomHoleIntervalCounts)) then totalLength = Op_MudDischarged_Volume%Length() do while(imud < totalLength) !imud = imud + 1 call RemoveOpMudArrays(totalLength) totalLength = totalLength - 1 enddo exit ! endif !WRITE(*,*) imud,'Op_MudDischarged_Volume%Array(imud)' , Op_MudDischarged_Volume%Array(imud), Op_Density%Array(imud) enddo !write(*,*) 'Op_Mud_Forehead_X%Length()' , Op_Mud_Forehead_X%Length() ! ! WRITE(*,*) 'Xend_PipeSection(F_StringIntervalCounts)' , Xend_PipeSection(F_StringIntervalCounts) ! WRITE(*,*) 'Op_Mud_Backhead_X%Array(1)' , Op_Mud_Backhead_X%Array(1) ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(1)' , Op_Mud_Forehead_X%Array(1) ! WRITE(*,*) 'Op_Mud_Backhead_X%Array(2)' , Op_Mud_Backhead_X%Array(2) ! WRITE(*,*) 'Op_Mud_Forehead_X%Array(2)' , Op_Mud_Forehead_X%Array(2) !========================Bottom Hole END================= if (iLoc == 1) then MudSection= F_StringIntervalCounts+1 BackheadX= Xstart_PipeSection(F_StringIntervalCounts+1) elseif (iLoc == 2) then MudSection= Kick_Forehead_section BackheadX= Kick_Forehead_X endif !========================ANNULUS ENTRANCE==================== !write(*,*) 'iloc=====' , iLoc if ((ABS(AnnulusSuctionDensity_Old - St_Density%Last()) >= DensityMixTol) .OR. (DeltaVolumeOp == 0.0 .and. ABS(Ann_Density%Array(iLoc)-St_Density%Last())>=DensityMixTol .and. AnnulusFlowRate/=0.0d0) ) then ! new mud is pumped call Ann_Density%AddTo (iLoc,St_Density%Last()) call Ann_MudDischarged_Volume%AddTo (iLoc,0.0d0) call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection) call Ann_Mud_Backhead_X%AddTo (iLoc,BackheadX) call Ann_Mud_Backhead_section%AddTo (iLoc,MudSection) call Ann_RemainedVolume_in_LastSection%AddTo (iLoc,0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddTo (iLoc,0.0d0) call Ann_MudOrKick%AddTo (iLoc,0) call Ann_CuttingMud%AddTo (iloc,0) AnnulusSuctionDensity_Old= St_Density%Last() MudIsChanged= .true. endif Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+ ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) !(gal) !========================Tripping In==================== !write(*,*) 'DeltaVolumeOp=' , DeltaVolumeOp if (DeltaVolumeOp > 0.0 .and. MudIsChanged== .false.) then !.and. DrillingMode== .false.) then ! trip in mode(loole paeen) !write(*,*) 'Tripping In' NewDensity= (St_Density%Last()*((AnnulusFlowRate/60.)*DeltaT_Mudline)+Op_Density%Last()*DeltaVolumeOp)/(((AnnulusFlowRate/60.0d0)*DeltaT_Mudline)+DeltaVolumeOp) NewVolume= ((AnnulusFlowRate/60.)*DeltaT_Mudline)+DeltaVolumeOp !write(*,*) 'Ann_MudDischarged_Volume%Array(1)=', Ann_MudDischarged_Volume%Array(1), 'NewVolume=', NewVolume if (abs(Ann_Density%Array(iLoc)-NewDensity)< DensityMixTol) then ! 1-Pockets are Merged - (ROP is 0) Ann_Density%Array(iLoc)= (Ann_Density%Array(iLoc)*Ann_MudDischarged_Volume%Array(iLoc)+NewDensity*NewVolume)/(Ann_MudDischarged_Volume%Array(iLoc)+NewVolume) Ann_MudDischarged_Volume%Array(iLoc)= Ann_MudDischarged_Volume%Array(iLoc)+DeltaVolumeOp Ann_Mud_Forehead_X%Array(iLoc)= BackheadX Ann_Mud_Forehead_section%Array(iLoc)= MudSection Ann_Mud_Backhead_X%Array(iLoc)= BackheadX Ann_Mud_Backhead_section%Array(iLoc)= MudSection Ann_RemainedVolume_in_LastSection%Array(iLoc)= (0.0d0) Ann_EmptyVolume_inBackheadLocation%Array(iLoc)= (0.0d0) else ! 2-Merging conditions are not meeted, so new pocket call Ann_Density%AddTo (iLoc,NewDensity) call Ann_MudDischarged_Volume%AddTo (iLoc,NewVolume) call Ann_Mud_Forehead_X%AddTo (iLoc,BackheadX) call Ann_Mud_Forehead_section%AddTo (iLoc,MudSection) call Ann_Mud_Backhead_X%AddTo (iLoc,BackheadX) call Ann_Mud_Backhead_section%AddTo (iLoc,MudSection) call Ann_RemainedVolume_in_LastSection%AddTo (iLoc,0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddTo (iLoc,0.0d0) call Ann_MudOrKick%AddTo (iLoc,0) call Ann_CuttingMud%AddTo (iLoc,0) endif elseif (DeltaVolumeOp > 0.0 .and. MudIsChanged== .true. .and. Rate_of_Penetration==0.) then Ann_Density%Array(iLoc)= NewDensity Ann_MudDischarged_Volume%Array(iLoc)= NewVolume Ann_Mud_Forehead_X%Array(iLoc)= BackheadX Ann_Mud_Forehead_section%Array(iLoc)= MudSection Ann_Mud_Backhead_X%Array(iLoc)= BackheadX Ann_Mud_Backhead_section%Array(iLoc)= MudSection Ann_RemainedVolume_in_LastSection%Array(iLoc)= (0.0d0) Ann_EmptyVolume_inBackheadLocation%Array(iLoc)= (0.0d0) endif !========================Tripping In - End==================== !======================== ANNULUS ==================== MudIsChanged= .false. imud= 0 do while (imud < Ann_Mud_Forehead_X%Length()) imud = imud + 1 if (imud> 1) then Ann_Mud_Backhead_X%Array(imud)= Ann_Mud_Forehead_X%Array(imud-1) Ann_Mud_Backhead_section%Array(imud)= Ann_Mud_Forehead_section%Array(imud-1) endif ! <<< Fracture Shoe Lost IF ( ShoeLost .and. LostInTripOutIsDone== .false. .and. ShoeDepth < Ann_Mud_Backhead_X%Array(imud) .and. ShoeDepth >= Ann_Mud_Forehead_X%Array(imud) ) then !write(*,*) 'ShoeLost imud,AnnVolume(imud), VolumeLost:' , imud,Ann_MudDischarged_Volume%Array(imud), (( Qlost/60.0d0)*DeltaT_Mudline) Ann_MudDischarged_Volume%Array(imud)= Ann_MudDischarged_Volume%Array(imud)-((Qlost/60.0d0)*DeltaT_Mudline) !(gal) if (Ann_MudDischarged_Volume%Array(imud) < 0.0) then !write(*,*) 'mud is removed by shoe lost, imud=' , imud call RemoveAnnulusMudArrays(imud) imud= imud-1 cycle endif ENDIF ! Fracture Shoe Lost >>> DirectionCoef= (Xend_PipeSection(Ann_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Ann_Mud_Backhead_section%Array(imud))) & / ABS(Xend_PipeSection(Ann_Mud_Backhead_section%Array(imud))-Xstart_PipeSection(Ann_Mud_Backhead_section%Array(imud))) ! +1 for string , -1 for annulus Ann_EmptyVolume_inBackheadLocation%Array(imud)= DirectionCoef* (Xend_PipeSection(Ann_Mud_Backhead_section%Array(imud))- Ann_Mud_Backhead_X%Array(imud))* & Area_PipeSectionFt(Ann_Mud_Backhead_section%Array(imud)) !(ft^3) Ann_EmptyVolume_inBackheadLocation%Array(imud)= Ann_EmptyVolume_inBackheadLocation%Array(imud)* 7.48051948d0 ! ft^3 to gal if ( Ann_MudDischarged_Volume%Array(imud) <= Ann_EmptyVolume_inBackheadLocation%Array(imud)) then Ann_Mud_Forehead_section%Array(imud)= Ann_Mud_Backhead_section%Array(imud) Ann_Mud_Forehead_X%Array(imud)= Ann_Mud_Backhead_X%Array(imud)+ DirectionCoef*(Ann_MudDischarged_Volume%Array(imud)/7.48051948d0)/Area_PipeSectionFt(Ann_Mud_Backhead_section%Array(imud)) ! 7.48 is for gal to ft^3 else isection= Ann_Mud_Backhead_section%Array(imud)+1 Ann_RemainedVolume_in_LastSection%Array(imud)= Ann_MudDischarged_Volume%Array(imud)- Ann_EmptyVolume_inBackheadLocation%Array(imud) do if (isection > NoPipeSections) then ! last pipe section(well exit) Ann_MudDischarged_Volume%Array(imud)= Ann_MudDischarged_Volume%Array(imud)- Ann_RemainedVolume_in_LastSection%Array(imud) Ann_Mud_Forehead_X%Array(imud)= Xend_PipeSection(NoPipeSections) Ann_Mud_Forehead_section%Array(imud)= NoPipeSections if (Ann_MudDischarged_Volume%Array(imud)<= 0.0d0) then ! imud is completely exited form the well call RemoveAnnulusMudArrays(imud) endif exit endif xx= Ann_RemainedVolume_in_LastSection%Array(imud)/ PipeSection_VolumeCapacity(isection) !(gal) if (xx<= 1.0) then Ann_Mud_Forehead_section%Array(imud)= isection Ann_Mud_Forehead_X%Array(imud)= (xx * (Xend_PipeSection(isection)- Xstart_PipeSection(isection)))+ Xstart_PipeSection(isection) exit else Ann_RemainedVolume_in_LastSection%Array(imud)= Ann_RemainedVolume_in_LastSection%Array(imud)- PipeSection_VolumeCapacity(isection) isection= isection+ 1 endif enddo endif enddo !========================ANNULUS END================= !if ( WellisNOTFull == .false. ) then ! write(*,*) 'AnnulusFlowRate==' , AnnulusFlowRate ! call Set_FlowRate(real(100.*min(AnnulusFlowRate,PedalMeter)/(PedalMeter/10.), 8)) ! ! !endif end subroutine Utube1_and_TripIn