subroutine Kick_Migration ! 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 CReservoirVariables USE KickVARIABLES implicit none integer jelement, jmud, jsection,ielement,i integer jopelement,jopmud,jopsection,CuttingValue !MUD(2)%Q= MPumps%Total_Pump_GPM !StringFlowRate= MUD(2)%Q !AnnulusFlowRate= MUD(2)%Q ! !if (NewPipeFilling == 0) then ! StringFlowRate= 0. ! AnnulusFlowRate= 0. !endif !StringFlowRateFinal= StringFlowRate !AnnulusFlowRateFinal= AnnulusFlowRate !write(*,*) 'MUD(2)%Q=====' , MUD(2)%Q !write(*,*) 'Kick Migration,NewInfluxNumber:' , NewInfluxNumber !FirstSetKickMigration !write(*,*) 'NewInfluxNumber=' , NewInfluxNumber DO MudSystemDotKickNumber= MudSystemDotNewInfluxNumber-NoGasPocket+1 , MudSystemDotNewInfluxNumber !write(*,*) 'KickNumber=' , KickNumber if (KickFlux .AND. NOT(KickOffBottom) .and. MudSystemDotKickNumber == MudSystemDotNewInfluxNumber) cycle if ( MudSystemDotKickNumber == Ann_MudOrKick%Last() ) cycle ! when the last element in Annulus is kick, Migration is not called !write(*,*) 'Migration will be done for,KickNumber=' ,KickNumber !=================== Bottom Hole ENTRANCE(due to Kick) =================== !KickDx= (AutoMigrationRate/60.)*DeltaT_Mudline !3600 (ft/min)= 6 ft set in start up MudSystemDotOp_KickLoc= 0 MudSystemDotAnn_KickLoc= 0 MudSystemDotChokeLine_KickLoc= 0 do i = 1, Op_MudOrKick%Length () if (Op_MudOrKick%Array(i) == MudSystemDotKickNumber) then MudSystemDotOp_KickLoc = i exit endif end do do i = 1, Ann_MudOrKick%Length () if (Ann_MudOrKick%Array(i) == MudSystemDotKickNumber) then MudSystemDotAnn_KickLoc = i exit endif end do do i = 1, ChokeLine_MudOrKick%Length () if (ChokeLine_MudOrKick%Array(i) == MudSystemDotKickNumber) then MudSystemDotChokeLine_KickLoc = i exit endif end do !write(*,*) 'Op_KickLoc=' , Op_KickLoc !write(*,*) 'Ann_KickLoc=' , Ann_KickLoc !!write(*,*) 'ChokeLine_KickLoc=' , ChokeLine_KickLoc ! ! !write(*,*) 'Op_MudOrKick%Length ()=' , Op_MudOrKick%Length () ! ! !============================== foreheade kick be mate reside bashad *3 ============================== if (MudSystemDotOp_KickLoc == Op_MudOrKick%Length () .and. MudSystemDotAnn_KickLoc==0 ) then !write(*,*) '****3' MudSystemDotiLoc= 2 MudSystemDotKickDv= MudSystemDotArea_OpSectionFt(Op_Mud_Forehead_section%Array(MudSystemDotOp_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal MudSystemDotMinKickDv= min( MudSystemDotKickDv,MudSystemDotAnn_MudDischarged_Volume%Array (1), MudSystemDotOp_MudDischarged_Volume%Last () ) NewDensity= Ann_Density%Array (1) MudSystemDotNewVolume= MudSystemDotMinKickDv if ( MudSystemDotMinKickDv == MudSystemDotKickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund MudSystemDotAnn_MudDischarged_Volume%Array (1)= MudSystemDotAnn_MudDischarged_Volume%Array (1) - MudSystemDotMinKickDv call Ann_Density%AddToFirst (MudSystemDotOp_Density%Last()) call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotMinKickDv) call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Ann_MudOrKick%AddToFirst (MudSystemDotKickNumber) call Ann_CuttingMud%AddToFirst (0) MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! backheade kick zire mate bashad if (MudSystemDotOp_KickLoc > 1) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) else !Op_Density%Array (imudKick-1) == NewDensity MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1=============================== !write(*,*) '****3-1' call MudSystemDotOp_Density%AddToFirst (NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Op_MudOrKick%AddToFirst (0) endif elseif ( MudSystemDotMinKickDv == MudSystemDotAnn_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund Ann_Density%Array(1)= MudSystemDotOp_Density%Last() Ann_MudOrKick%Array(1)= MudSystemDotKickNumber MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! backheade kick zire mate bashad if (MudSystemDotOp_KickLoc > 1) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) else !Op_Density%Array (imudKick-1) == NewDensity MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *3-2=============================== !write(*,*) '****3-2' call MudSystemDotOp_Density%AddToFirst (NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Op_MudOrKick%AddToFirst (0) endif ! elseif ( MudSystemDotMinKickDv == MudSystemDotOp_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod MudSystemDotAnn_MudDischarged_Volume%Array (1)= MudSystemDotAnn_MudDischarged_Volume%Array (1) - MudSystemDotMinKickDv call Ann_Density%AddToFirst (MudSystemDotOp_Density%Last()) call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotMinKickDv) call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotXstart_PipeSection(F_StringIntervalCounts+1)) call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Ann_MudOrKick%AddToFirst (MudSystemDotKickNumber) call Ann_CuttingMud%AddToFirst (0) MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_MudDischarged_Volume%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_Mud_Backhead_X%Remove (MudSystemDotOp_KickLoc) call Op_Mud_Backhead_section%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_Mud_Forehead_X%Remove (MudSystemDotOp_KickLoc) call Op_Mud_Forehead_section%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (MudSystemDotOp_KickLoc) call Op_MudOrKick%Remove (MudSystemDotOp_KickLoc) ! backheade kick zire mate bashad if (MudSystemDotOp_KickLoc > 1) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) else !Op_Density%Array (imudKick-1) == NewDensity MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3=============================== !write(*,*) '****3-3' call MudSystemDotOp_Density%AddToFirst (NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Op_MudOrKick%AddToFirst (0) endif endif endif !======================================================================================== !============================== foreheade kick be mate reside bashad *3 with pump ============================== ! if (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 .and. AnnulusFlowRate /= 0.0 ) then ! write(*,*) '****3 with pump' ! ! KickMigration_2SideBit= .true. ! !iloc= 2 ! ! !KickDv= Area_OpSectionFt(Op_Mud_Forehead_section%Array(Op_KickLoc)) * KickDx * 7.48051948 ! ft^3 to gal ! !!farz mikonam baraye in yek iteration kick az OP hazf nemishavad va hajme aan bishtar az pump flow ast ! ! KickDv= ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! ! call Ann_Density%AddToFirst (Kick_Density) ! call Ann_MudDischarged_Volume%AddToFirst (KickDv) ! call Ann_Mud_Forehead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) ! call Ann_Mud_Forehead_section%AddToFirst (F_StringIntervalCounts+1) ! call Ann_Mud_Backhead_X%AddToFirst (Xstart_PipeSection(F_StringIntervalCounts+1)) ! call Ann_Mud_Backhead_section%AddToFirst (F_StringIntervalCounts+1) ! call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! call Ann_MudOrKick%AddToFirst (KickNumber) ! call Ann_CuttingMud%AddToFirst (0) ! ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! ! ! ! !if ( ((AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad ! ! ! ! KickDv= ((AnnulusFlowRate/60.)*DeltaT_Mudline) ! ! ! ! ! BackHead: ! if ( Op_Density%Array (Op_KickLoc-1) /= St_Density%Last() ) then ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! call Op_Density%AddTo (Op_KickLoc,St_Density%Last()) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,KickDv) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! ! else !Op_Density%Array (imudKick-1) == NewDensity ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + KickDv ! ! endif ! ! ! ! ! endif !======================================================================================== !============================= tamame kick zire mate bashad *1 ================================ if ( MudSystemDotOp_KickLoc>0 .and. MudSystemDotOp_KickLoc < Op_MudOrKick%Length () ) then !write(*,*) '****1' !iloc= 1 MudSystemDotKickDv= MudSystemDotArea_OpSectionFt(Op_Mud_Forehead_section%Array(MudSystemDotOp_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) if ( MudSystemDotKickDv < MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) ) then !eleman bala sari baghi mimund !write(*,*) 'cond 11111111111111' MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) - MudSystemDotKickDv NewDensity= MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc+1) MudSystemDotNewVolume= MudSystemDotKickDv else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund ! write(*,*) 'cond 22222222222222222' MudSystemDotKickDv= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc+1) MudSystemDotNewVolume= MudSystemDotKickDv NewDensity= MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc+1) call MudSystemDotOp_MudDischarged_Volume%Remove (MudSystemDotOp_KickLoc+1) call MudSystemDotOp_Mud_Backhead_X%Remove (MudSystemDotOp_KickLoc+1) call Op_Mud_Backhead_section%Remove (MudSystemDotOp_KickLoc+1) call MudSystemDotOp_Mud_Forehead_X%Remove (MudSystemDotOp_KickLoc+1) call Op_Mud_Forehead_section%Remove (MudSystemDotOp_KickLoc+1) call MudSystemDotOp_Density%Remove (MudSystemDotOp_KickLoc+1) call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (MudSystemDotOp_KickLoc+1) call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (MudSystemDotOp_KickLoc+1) call Op_MudOrKick%Remove (MudSystemDotOp_KickLoc+1) endif ! backheade kick zire mate bashad if (MudSystemDotOp_KickLoc > 1) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) else !Op_Density%Array (Op_KickLoc-1) == NewDensity MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1=============================== !write(*,*) '****5-1' call MudSystemDotOp_Density%AddToFirst (NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Op_MudOrKick%AddToFirst (0) endif endif !======================================================================================== !write(*,*) 'a) density and cutting:' , Ann_Density%Length() , Ann_CuttingMud%Length() !=========================== tamame kick balaye mate bashad *2 ================================== if ( MudSystemDotAnn_KickLoc > 0 .and. MudSystemDotOp_KickLoc==0 ) then !write(*,*) '****2' !iloc= 1 MudSystemDotKickDv= MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotAnn_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal NewDensity= Ann_Density%Array (MudSystemDotAnn_KickLoc+1) MudSystemDotNewVolume= MudSystemDotKickDv CuttingValue= Ann_CuttingMud%Array (MudSystemDotAnn_KickLoc+1) if ( MudSystemDotKickDv < MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) ) then !eleman bala sari baghi mimund MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotKickDv else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund MudSystemDotKickDv= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) MudSystemDotNewVolume= MudSystemDotKickDv call MudSystemDotAnn_MudDischarged_Volume%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Backhead_X%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Backhead_section%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Forehead_X%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Forehead_section%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Density%Remove (MudSystemDotAnn_KickLoc+1) call Ann_RemainedVolume_in_LastSection%Remove (MudSystemDotAnn_KickLoc+1) call Ann_EmptyVolume_inBackheadLocation%Remove (MudSystemDotAnn_KickLoc+1) call Ann_MudOrKick%Remove (MudSystemDotAnn_KickLoc+1) call Ann_CuttingMud%Remove (MudSystemDotAnn_KickLoc+1) endif ! backheade kick balaye mate bashad if (MudSystemDotAnn_KickLoc > 1) then !if ( Ann_Density%Array (Ann_KickLoc-1) /= NewDensity ) then if ( ABS(Ann_Density%Array (MudSystemDotAnn_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then MudSystemDotOld_KickBackHead_X= Ann_Mud_Backhead_X%Array (MudSystemDotAnn_KickLoc) MudSystemDotOld_KickBackHead_Section= Ann_Mud_Backhead_section%Array (MudSystemDotAnn_KickLoc) call Ann_Density%AddTo (MudSystemDotAnn_KickLoc,NewDensity) call MudSystemDotAnn_MudDischarged_Volume%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotNewVolume) call Ann_Mud_Forehead_X%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_X) call Ann_Mud_Forehead_section%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_Section) call Ann_Mud_Backhead_X%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_X) call Ann_Mud_Backhead_section%AddTo (MudSystemDotAnn_KickLoc,MudSystemDotOld_KickBackHead_Section) call Ann_RemainedVolume_in_LastSection%AddTo (MudSystemDotAnn_KickLoc,0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotAnn_KickLoc,0.0d0) call Ann_MudOrKick%AddTo (MudSystemDotAnn_KickLoc,0) call Ann_CuttingMud%AddTo (MudSystemDotAnn_KickLoc,0) else !Op_Density%Array (imudKick-1) == NewDensity Ann_Density%Array(MudSystemDotAnn_KickLoc-1)= (Ann_Density%Array(MudSystemDotAnn_KickLoc-1)*MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1)= MudSystemDotAnn_MudDischarged_Volume%Array(MudSystemDotAnn_KickLoc-1) + MudSystemDotNewVolume endif else !if Ann_KickLoc == 1 *6 =============================== !write(*,*) '****6' MudSystemDotOld_KickBackHead_X= Ann_Mud_Backhead_X%Array (MudSystemDotAnn_KickLoc) MudSystemDotOld_KickBackHead_Section= Ann_Mud_Backhead_section%Array (MudSystemDotAnn_KickLoc) call Ann_Density%AddToFirst (NewDensity) call MudSystemDotAnn_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call Ann_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Ann_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call Ann_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Ann_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Ann_MudOrKick%AddToFirst (0) call Ann_CuttingMud%AddToFirst (CuttingValue) endif endif !======================================================================================== !============================== kick 2 tarafe mate bashad *4 ============================== if ( MudSystemDotAnn_KickLoc > 0 .and. MudSystemDotOp_KickLoc > 0 ) then !write(*,*) '****4' MudSystemDotiLoc= 2 MudSystemDotKickDv= MudSystemDotArea_PipeSectionFt(Ann_Mud_Forehead_section%Array(MudSystemDotAnn_KickLoc)) * MudSystemDotKickDx * 7.48051948d0 ! ft^3 to gal MudSystemDotMinKickDv= min( MudSystemDotKickDv,MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1), MudSystemDotOp_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick NewDensity= Ann_Density%Array (MudSystemDotAnn_KickLoc+1) MudSystemDotNewVolume= MudSystemDotMinKickDv if ( MudSystemDotMinKickDv == MudSystemDotKickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund !write(*,*) '****4----1' MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotMinKickDv MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1 MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! Op_KickLoc= last ! backheade kick zire mate bashad if ( MudSystemDotOp_KickLoc>1) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) else ! merge MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== !write(*,*) '****5-2' MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%AddToFirst (NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Op_MudOrKick%AddToFirst (0) endif elseif ( MudSystemDotMinKickDv == MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) ) then ! eleman bala sari baghi nemimund !write(*,*) '****4----2' call MudSystemDotAnn_MudDischarged_Volume%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Backhead_X%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Backhead_section%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Forehead_X%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Mud_Forehead_section%Remove (MudSystemDotAnn_KickLoc+1) call Ann_Density%Remove (MudSystemDotAnn_KickLoc+1) call Ann_RemainedVolume_in_LastSection%Remove (MudSystemDotAnn_KickLoc+1) call Ann_EmptyVolume_inBackheadLocation%Remove (MudSystemDotAnn_KickLoc+1) call Ann_MudOrKick%Remove (MudSystemDotAnn_KickLoc+1) call Ann_CuttingMud%Remove (MudSystemDotAnn_KickLoc+1) MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1 MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc)= MudSystemDotOp_MudDischarged_Volume%Array (MudSystemDotOp_KickLoc) - MudSystemDotMinKickDv ! Op_KickLoc= last ! backheade kick zire mate bashad if (MudSystemDotOp_KickLoc > 1) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) else !Op_Density%Array (imudKick-1) == NewDensity MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%AddToFirst (NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Op_MudOrKick%AddToFirst (0) endif elseif ( MudSystemDotMinKickDv == MudSystemDotOp_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod !write(*,*) '****4----3' MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc+1) - MudSystemDotMinKickDv MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc)= MudSystemDotAnn_MudDischarged_Volume%Array (MudSystemDotAnn_KickLoc) + MudSystemDotMinKickDv ! Ann_KickLoc= 1 MudSystemDotOld_KickBackHead_X= MudSystemDotOp_Mud_Backhead_X%Array (MudSystemDotOp_KickLoc) MudSystemDotOld_KickBackHead_Section= Op_Mud_Backhead_section%Array (MudSystemDotOp_KickLoc) call MudSystemDotOp_MudDischarged_Volume%Remove (MudSystemDotOp_KickLoc) ! Op_KickLoc= last call MudSystemDotOp_Mud_Backhead_X%Remove (MudSystemDotOp_KickLoc) call Op_Mud_Backhead_section%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_Mud_Forehead_X%Remove (MudSystemDotOp_KickLoc) call Op_Mud_Forehead_section%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_Density%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_RemainedVolume_in_LastSection%Remove (MudSystemDotOp_KickLoc) call MudSystemDotOp_EmptyVolume_inBackheadLocation%Remove (MudSystemDotOp_KickLoc) call Op_MudOrKick%Remove (MudSystemDotOp_KickLoc) ! backheade kick zire mate bashad if (MudSystemDotOp_KickLoc > 1) then !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then if ( ABS(MudSystemDotOp_Density%Array (MudSystemDotOp_KickLoc-1) - NewDensity) >= MudSystemDotDensityMixTol ) then call MudSystemDotOp_Density%AddTo (MudSystemDotOp_KickLoc,NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddTo (MudSystemDotOp_KickLoc,MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddTo (MudSystemDotOp_KickLoc,MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddTo (MudSystemDotOp_KickLoc,0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddTo (MudSystemDotOp_KickLoc,0.0d0) call Op_MudOrKick%AddTo (MudSystemDotOp_KickLoc,0) else !Op_Density%Array (imudKick-1) == NewDensity MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)= (MudSystemDotOp_Density%Array(MudSystemDotOp_KickLoc-1)*MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+NewDensity*MudSystemDotNewVolume)/(MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)+MudSystemDotNewVolume) MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1)= MudSystemDotOp_MudDischarged_Volume%Array(MudSystemDotOp_KickLoc-1) + MudSystemDotNewVolume endif else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== call MudSystemDotOp_Density%AddToFirst (NewDensity) call MudSystemDotOp_MudDischarged_Volume%AddToFirst (MudSystemDotNewVolume) call MudSystemDotOp_Mud_Forehead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Forehead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_Mud_Backhead_X%AddToFirst (MudSystemDotOld_KickBackHead_X) call Op_Mud_Backhead_section%AddToFirst (MudSystemDotOld_KickBackHead_Section) call MudSystemDotOp_RemainedVolume_in_LastSection%AddToFirst (0.0d0) call MudSystemDotOp_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) call Op_MudOrKick%AddToFirst (0) endif MudSystemDotiLoc= 1 ! ok endif endif !======================================================================================== !============================== kick 2 tarafe mate bashad *4 with pump ============================== ! !if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 .and. AnnulusFlowRate /= 0.0 ) then ! write(*,*) '****4 with pump' ! ! KickMigration_2SideBit= .true. ! ! !iloc= 2 ! ! KickDv= Area_PipeSectionFt(Ann_Mud_Forehead_section%Array(Ann_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal ! !MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick ! ! ! !MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick ! ! ! !NewDensity= Ann_Density%Array (Ann_KickLoc+1) ! !NewVolume= MinKickDv ! ! ! if ( ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad---tu in halat aslan kari be elemane balaiye kick tuye Ann nadarim ! !WRITE(*,*) '*****sorate pump bishtar az kick*******' ! MinKickDv= ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) ! dar asl maxKickDv ast ! ! ! ! ! ! ! ! ! if ( Op_MudDischarged_Volume%Last () > MinKickDv ) then !eleman paeeni(kick) dar OP baghi mimund ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! backheade kick zire mate bashad ! if ( Op_KickLoc>1) then ! ! if ( Op_Density%Array (Op_KickLoc-1) /= St_Density%Last() ) then ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! call Op_Density%AddTo (Op_KickLoc,St_Density%Last()) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,MinKickDv) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! ! else !Op_Density%Array (imudKick-1) == NewDensity ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume ! ! endif ! ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== ! write(*,*) '****5-2 with pump' ! ! ! !Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! !Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! ! call Op_Density%AddToFirst (St_Density%Last()) ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! call Op_MudOrKick%AddToFirst (0) ! ! endif ! ! elseif ( Op_MudDischarged_Volume%Last () <= MinKickDv ) then !eleman paeeni(kick) dar OP baghi nemimund yani kick az OP kamel kharej mishod ! ! MinKickDv= Op_MudDischarged_Volume%Last () ! ! ! write(*,*) '****4----3 with pump a' ! ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) + ((AnnulusFlowRate/60.0d0)*DeltaT_Mudline)-MinKickDv ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! ! call Op_MudDischarged_Volume%Remove (Op_KickLoc) ! Op_KickLoc= last ! call Op_Mud_Backhead_X%Remove (Op_KickLoc) ! call Op_Mud_Backhead_section%Remove (Op_KickLoc) ! call Op_Mud_Forehead_X%Remove (Op_KickLoc) ! call Op_Mud_Forehead_section%Remove (Op_KickLoc) ! call Op_Density%Remove (Op_KickLoc) ! call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc) ! call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc) ! call Op_MudOrKick%Remove (Op_KickLoc) ! ! ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! ! if ( Op_Density%Array (Op_KickLoc-1) /= St_Density%Last() ) then ! ! ! !Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! !Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! call Op_Density%AddTo (Op_KickLoc,St_Density%Last()) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,MinKickDv) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! ! ! else !Op_Density%Array (imudKick-1) == NewDensity ! ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + MinKickDv ! ! endif ! ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! ! call Op_Density%AddToFirst (St_Density%Last()) ! call Op_MudDischarged_Volume%AddToFirst (MinKickDv) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! call Op_MudOrKick%AddToFirst (0) ! ! endif ! ! ! endif ! ende 2 halat ke kick tuye Op baghi bemune ya namune- dar halati ke ((AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) ! sorate pump bishtar az kick bashad ! ! ! ! ! else !if( ((AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) then ! sorate pump kamtar az kick bashad ! !WRITE(*,*) '*****sorate pump kamtar az kick*******' ! ! ! ! ! MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (Ann_KickLoc+1), Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick ! ! ! ! !write(*,*) 'MinKickDv=' , MinKickDv ! ! ! if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund ! !write(*,*) '****4----1 with pump' ! !write(*,*) 'St_Density%Last()=' , St_Density%Last() ! !write(*,*) '((AnnulusFlowRate/60.)*DeltaT_Mudline)=' , ((AnnulusFlowRate/60.)*DeltaT_Mudline) ! !write(*,*) 'Ann_Density%Array(Ann_KickLoc+1)=' , Ann_Density%Array(Ann_KickLoc+1) ! !write(*,*) '(MinKickDv-((AnnulusFlowRate/60.)*DeltaT_Mudline))=' , (MinKickDv-((AnnulusFlowRate/60.)*DeltaT_Mudline)) ! ! ! NewDensity= (St_Density%Last()*((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & ! / (((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + (MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) ! NewVolume= MinKickDv ! ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - (MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline)) ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last ! ! ! ! backheade kick zire mate bashad ! if ( Op_KickLoc>1) then ! ! ! ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! call Op_Density%AddTo (Op_KickLoc,NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! ! endif ! ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== ! write(*,*) '****5-2 with pump' ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! ! call Op_Density%AddToFirst (NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! call Op_MudOrKick%AddToFirst (0) ! ! endif ! ! ! ! elseif ( MinKickDv == Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund ! write(*,*) '****4----2 with pump' ! ! NewDensity= (St_Density%Last()*((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) & ! / (((AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)) ! NewVolume= MinKickDv ! ! call RemoveAnnulusMudArrays(Ann_KickLoc+1) ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! ! Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv ! Op_KickLoc= last ! ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! call Op_Density%AddTo (Op_KickLoc,NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! ! ! endif ! ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! ! call Op_Density%AddToFirst (NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! call Op_MudOrKick%AddToFirst (0) ! ! endif ! ! ! elseif ( MinKickDv == Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod ! write(*,*) '****4----3 with pump b' ! ! NewDensity= St_Density%Last() ! NewVolume= MinKickDv ! ! ! Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc) ! Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc) ! ! ! !Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - MinKickDv farz kardam dast be elemane balaee nazanam ! ! Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1 ! !write(*,*) 'pointer 1' ! call Op_MudDischarged_Volume%Remove (Op_KickLoc) ! Op_KickLoc= last ! call Op_Mud_Backhead_X%Remove (Op_KickLoc) ! call Op_Mud_Backhead_section%Remove (Op_KickLoc) ! call Op_Mud_Forehead_X%Remove (Op_KickLoc) ! call Op_Mud_Forehead_section%Remove (Op_KickLoc) ! call Op_Density%Remove (Op_KickLoc) ! call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc) ! call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc) ! call Op_MudOrKick%Remove (Op_KickLoc) ! ! !write(*,*) 'pointer 2' ! ! ! backheade kick zire mate bashad ! if (Op_KickLoc > 1) then ! ! if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then ! !write(*,*) 'pointer 3' ! ! ! ! ! call Op_Density%AddTo (Op_KickLoc,NewDensity) ! call Op_MudDischarged_Volume%AddTo (Op_KickLoc,NewVolume) ! call Op_Mud_Forehead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddTo (Op_KickLoc,Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddTo (Op_KickLoc,Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddTo (Op_KickLoc,0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddTo (Op_KickLoc,0.0d0) ! call Op_MudOrKick%AddTo (Op_KickLoc,0) ! ! !write(*,*) 'pointer 4' ! ! else !Merge Condition ! ! Op_MudDischarged_Volume%Array (Op_KickLoc-1)= Op_MudDischarged_Volume%Array (Op_KickLoc-1) + NewVolume ! Op_Density%Array (Op_KickLoc-1)= (Op_MudDischarged_Volume%Array (Op_KickLoc-1)*Op_Density%Array (Op_KickLoc-1)+NewVolume*NewDensity) / & ! (Op_MudDischarged_Volume%Array (Op_KickLoc-1)+NewVolume) ! ! endif ! ! else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2=============================== ! !write(*,*) 'pointer 5' ! ! ! !write(*,*) 'pointer 6' ! ! ! call Op_Density%AddToFirst (NewDensity) ! call Op_MudDischarged_Volume%AddToFirst (NewVolume) ! call Op_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X) ! call Op_Mud_Backhead_section%AddToFirst (Old_KickBackHead_Section) ! call Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0) ! call Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0) ! call Op_MudOrKick%AddToFirst (0) ! !write(*,*) 'pointer 7' ! ! endif ! ! ! endif ! ! ! ! endif !( ((AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) ! sorate pump kamtar az kick bashad ! ! ! ! ! endif !======================================================================================== ENDDO ! KickNumber= 1, NewInfluxNumber !write(*,*) 'c)Ann_MudDischarged_Volume%Array(:)=' , sum(Ann_MudDischarged_Volume%Array(:)) end subroutine Kick_Migration