|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176 |
- 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,kickNumber
- integer jopelement,jopmud,jopsection,CuttingValue
-
-
- !MUD(2)%Q= MPumps%Total_Pump_GPM
- !MudSystem%StringFlowRate= MUD(2)%Q
- !MudSystem%AnnulusFlowRate= MUD(2)%Q
- !
- !if (NewPipeFilling == 0) then
- ! MudSystem%StringFlowRate= 0.
- ! MudSystem%AnnulusFlowRate= 0.
- !endif
-
- !StringFlowRateFinal= MudSystem%StringFlowRate
- !AnnulusFlowRateFinal= MudSystem%AnnulusFlowRate
-
-
-
- !write(*,*) 'MUD(2)%Q=====' , MUD(2)%Q
- !write(*,*) 'Kick Migration,NewInfluxNumber:' , NewInfluxNumber
-
-
-
- !FirstSetKickMigration
- !write(*,*) 'NewInfluxNumber=' , NewInfluxNumber
- DO KickNumber= MudSystem%NewInfluxNumber-NoGasPocket+1 , MudSystem%NewInfluxNumber
- !write(*,*) 'KickNumber=' , KickNumber
- if (KickFlux .AND. NOT(KickOffBottom) .and. KickNumber == MudSystem%NewInfluxNumber) cycle
- if ( KickNumber == MudSystem%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
-
-
- MudSystem%Op_KickLoc= 0
- MudSystem%Ann_KickLoc= 0
- MudSystem%ChokeLine_KickLoc= 0
-
- do i = 1, MudSystem%Op_MudOrKick%Length ()
- if (MudSystem%Op_MudOrKick%Array(i) == KickNumber) then
- MudSystem%Op_KickLoc = i
- exit
- endif
- end do
-
- do i = 1, MudSystem%Ann_MudOrKick%Length ()
- if (MudSystem%Ann_MudOrKick%Array(i) == KickNumber) then
- MudSystem%Ann_KickLoc = i
- exit
- endif
- end do
-
- do i = 1, MudSystem%ChokeLine_MudOrKick%Length ()
- if (MudSystem%ChokeLine_MudOrKick%Array(i) == KickNumber) then
- MudSystem%ChokeLine_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 (MudSystem%Op_KickLoc == MudSystem%Op_MudOrKick%Length () .and. MudSystem%Ann_KickLoc==0 ) then
- !write(*,*) '****3'
-
- MudSystem%iLoc= 2
-
- MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal
-
-
- MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (1), MudSystem%Op_MudDischarged_Volume%Last () )
-
- MudSystem%NewDensity= MudSystem%Ann_Density%Array (1)
- MudSystem%NewVolume= MudSystem%MinKickDv
-
- if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund
-
- MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv
-
- call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last())
- call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv)
- call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1))
- call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1)
- call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1))
- call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1)
- call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber)
- call MudSystem%Ann_CuttingMud%AddToFirst (0)
-
- MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv
-
- ! backheade kick zire mate bashad
- if (MudSystem%Op_KickLoc > 1) then
- !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
- call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0)
-
-
- else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity
-
- MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume
-
- endif
- else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1===============================
- !write(*,*) '****3-1'
-
-
- call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Op_MudOrKick%AddToFirst (0)
-
- endif
-
-
-
- elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (1) ) then ! eleman bala sari baghi nemimund
-
- MudSystem%Ann_Density%Array(1)= MudSystem%Op_Density%Last()
- MudSystem%Ann_MudOrKick%Array(1)= KickNumber
-
- MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv
-
- ! backheade kick zire mate bashad
- if (MudSystem%Op_KickLoc > 1) then
-
- !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
- call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0)
-
-
- else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity
-
- MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume
-
- endif
-
- else !if Op_KickLoc == 1 (*****Migration Start*****) *3-2===============================
- !write(*,*) '****3-2'
-
-
- call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Op_MudOrKick%AddToFirst (0)
-
- endif
-
-
- !
- elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick hazf mishod
-
- MudSystem%Ann_MudDischarged_Volume%Array (1)= MudSystem%Ann_MudDischarged_Volume%Array (1) - MudSystem%MinKickDv
-
- call MudSystem%Ann_Density%AddToFirst (MudSystem%Op_Density%Last())
- call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%MinKickDv)
- call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1))
- call MudSystem%Ann_Mud_Forehead_section%AddToFirst (F_Counts%StringIntervalCounts+1)
- call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Xstart_PipeSection(F_Counts%StringIntervalCounts+1))
- call MudSystem%Ann_Mud_Backhead_section%AddToFirst (F_Counts%StringIntervalCounts+1)
- call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Ann_MudOrKick%AddToFirst (KickNumber)
- call MudSystem%Ann_CuttingMud%AddToFirst (0)
-
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
- call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc)
-
-
- ! backheade kick zire mate bashad
- if (MudSystem%Op_KickLoc > 1) then
- !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
-
-
- call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0)
-
-
- else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity
-
- MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume
-
- endif
-
- else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3===============================
- !write(*,*) '****3-3'
-
- call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%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. MudSystem%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= ((MudSystem%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_Counts%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 ( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) then ! sorate pump bishtar az kick bashad
- ! !
- ! ! KickDv= ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)
- !
- !
- !
- ! ! BackHead:
- ! if ( Op_Density%Array (Op_KickLoc-1) /=MudSystem%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_KickLocMudSystem%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) == MudSystem%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 ( MudSystem%Op_KickLoc>0 .and. MudSystem%Op_KickLoc < MudSystem%Op_MudOrKick%Length () ) then
- !write(*,*) '****1'
- !iloc= 1
-
- MudSystem%KickDv= MudSystem%Area_OpSectionFt(MudSystem%Op_Mud_Forehead_section%Array(MudSystem%Op_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal
-
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
- if ( MudSystem%KickDv < MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) ) then !eleman bala sari baghi mimund
-
- !write(*,*) 'cond 11111111111111'
-
- MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1) - MudSystem%KickDv
-
- MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1)
- MudSystem%NewVolume= MudSystem%KickDv
-
- else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund
-
- ! write(*,*) 'cond 22222222222222222'
-
-
- MudSystem%KickDv= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc+1)
-
- MudSystem%NewVolume= MudSystem%KickDv
- MudSystem%NewDensity= MudSystem%Op_Density%Array (MudSystem%Op_KickLoc+1)
-
-
-
-
- call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc+1)
- call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc+1)
-
- endif
-
- ! backheade kick zire mate bashad
- if (MudSystem%Op_KickLoc > 1) then
- !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
-
-
-
- call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0)
-
- else !Op_Density%Array (Op_KickLoc-1) == MudSystem%NewDensity
-
- MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume
-
- endif
- else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1===============================
- !write(*,*) '****5-1'
-
- call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Op_MudOrKick%AddToFirst (0)
-
- endif
-
-
- endif
-
- !========================================================================================
-
- !write(*,*) 'a) density and cutting:' , Ann_Density%Length() , Ann_CuttingMud%Length()
-
-
- !=========================== tamame kick balaye mate bashad *2 ==================================
-
- if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc==0 ) then
- !write(*,*) '****2'
-
- !iloc= 1
-
- MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal
-
- MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1)
- MudSystem%NewVolume= MudSystem%KickDv
- CuttingValue= MudSystem%Ann_CuttingMud%Array (MudSystem%Ann_KickLoc+1)
-
- if ( MudSystem%KickDv < MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then !eleman bala sari baghi mimund
-
- MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%KickDv
-
- else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund
-
- MudSystem%KickDv= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)
- MudSystem%NewVolume= MudSystem%KickDv
-
- call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1)
-
- endif
-
- ! backheade kick balaye mate bashad
-
- if (MudSystem%Ann_KickLoc > 1) then
- !if ( Ann_Density%Array (Ann_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
- MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc)
-
-
- call MudSystem%Ann_Density%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewDensity)
- call MudSystem%Ann_MudDischarged_Volume%AddTo (MudSystem%Ann_KickLoc,MudSystem%NewVolume)
- call MudSystem%Ann_Mud_Forehead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Ann_Mud_Forehead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Ann_Mud_Backhead_X%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Ann_Mud_Backhead_section%AddTo (MudSystem%Ann_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Ann_RemainedVolume_in_LastSection%AddTo (MudSystem%Ann_KickLoc,0.0d0)
- call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Ann_KickLoc,0.0d0)
- call MudSystem%Ann_MudOrKick%AddTo (MudSystem%Ann_KickLoc,0)
- call MudSystem%Ann_CuttingMud%AddTo (MudSystem%Ann_KickLoc,0)
-
- else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity
-
- MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)= (MudSystem%Ann_Density%Array(MudSystem%Ann_KickLoc-1)*MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1)= MudSystem%Ann_MudDischarged_Volume%Array(MudSystem%Ann_KickLoc-1) + MudSystem%NewVolume
-
-
- endif
-
- else !if Ann_KickLoc == 1 *6 ===============================
- !write(*,*) '****6'
-
- MudSystem%Old_KickBackHead_X= MudSystem%Ann_Mud_Backhead_X%Array (MudSystem%Ann_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Ann_Mud_Backhead_section%Array (MudSystem%Ann_KickLoc)
-
-
- call MudSystem%Ann_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Ann_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Ann_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Ann_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Ann_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Ann_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Ann_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Ann_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Ann_MudOrKick%AddToFirst (0)
- call MudSystem%Ann_CuttingMud%AddToFirst (CuttingValue)
-
- endif
-
- endif
-
- !========================================================================================
-
-
-
-
-
-
-
- !============================== kick 2 tarafe mate bashad *4 ==============================
-
- if ( MudSystem%Ann_KickLoc > 0 .and. MudSystem%Op_KickLoc > 0 ) then
- !write(*,*) '****4'
-
- MudSystem%iLoc= 2
-
- MudSystem%KickDv= MudSystem%Area_PipeSectionFt(MudSystem%Ann_Mud_Forehead_section%Array(MudSystem%Ann_KickLoc)) * MudSystem%KickDx * 7.48051948d0 ! ft^3 to gal
-
-
- MudSystem%MinKickDv= min( MudSystem%KickDv,MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1), MudSystem%Op_MudDischarged_Volume%Last () ) ! Ann_KickLoc+1=2 Op_MudDischarged_Volume%Last ()=kick
-
- MudSystem%NewDensity= MudSystem%Ann_Density%Array (MudSystem%Ann_KickLoc+1)
- MudSystem%NewVolume= MudSystem%MinKickDv
-
- if ( MudSystem%MinKickDv == MudSystem%KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund
- !write(*,*) '****4----1'
-
-
- MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv
-
- MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1
-
- MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last
-
-
- ! backheade kick zire mate bashad
- if ( MudSystem%Op_KickLoc>1) then
-
- !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
- call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0)
-
-
- else ! merge
-
- MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume
-
- endif
-
- else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2===============================
- !write(*,*) '****5-2'
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
-
- call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Op_MudOrKick%AddToFirst (0)
-
- endif
-
-
-
- elseif ( MudSystem%MinKickDv == MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) ) then ! eleman bala sari baghi nemimund
- !write(*,*) '****4----2'
-
- call MudSystem%Ann_MudDischarged_Volume%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Backhead_X%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Backhead_section%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Forehead_X%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Mud_Forehead_section%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_Density%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_RemainedVolume_in_LastSection%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_EmptyVolume_inBackheadLocation%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_MudOrKick%Remove (MudSystem%Ann_KickLoc+1)
- call MudSystem%Ann_CuttingMud%Remove (MudSystem%Ann_KickLoc+1)
-
- MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1
-
- MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc)= MudSystem%Op_MudDischarged_Volume%Array (MudSystem%Op_KickLoc) - MudSystem%MinKickDv ! Op_KickLoc= last
-
- ! backheade kick zire mate bashad
- if (MudSystem%Op_KickLoc > 1) then
-
- !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
- call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0)
-
-
- else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity
- MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume
-
- endif
-
- else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2===============================
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
-
- call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Op_MudOrKick%AddToFirst (0)
-
- endif
-
-
- elseif ( MudSystem%MinKickDv == MudSystem%Op_MudDischarged_Volume%Last () ) then ! eleman balaee baghi mimund, kick az OP kamel kharej mishod
- !write(*,*) '****4----3'
-
-
-
- MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc+1) - MudSystem%MinKickDv
-
- MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc)= MudSystem%Ann_MudDischarged_Volume%Array (MudSystem%Ann_KickLoc) + MudSystem%MinKickDv ! Ann_KickLoc= 1
-
-
-
- MudSystem%Old_KickBackHead_X= MudSystem%Op_Mud_Backhead_X%Array (MudSystem%Op_KickLoc)
- MudSystem%Old_KickBackHead_Section= MudSystem%Op_Mud_Backhead_section%Array (MudSystem%Op_KickLoc)
-
-
- call MudSystem%Op_MudDischarged_Volume%Remove (MudSystem%Op_KickLoc) ! Op_KickLoc= last
- call MudSystem%Op_Mud_Backhead_X%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Mud_Backhead_section%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Mud_Forehead_X%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Mud_Forehead_section%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_Density%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_RemainedVolume_in_LastSection%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%Remove (MudSystem%Op_KickLoc)
- call MudSystem%Op_MudOrKick%Remove (MudSystem%Op_KickLoc)
-
- ! backheade kick zire mate bashad
- if (MudSystem%Op_KickLoc > 1) then
-
- !if ( Op_Density%Array (Op_KickLoc-1) /= MudSystem%NewDensity ) then
-
- if ( ABS(MudSystem%Op_Density%Array (MudSystem%Op_KickLoc-1) - MudSystem%NewDensity) >= MudSystem%DensityMixTol ) then
-
-
- call MudSystem%Op_Density%AddTo (MudSystem%Op_KickLoc,MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddTo (MudSystem%Op_KickLoc,MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddTo (MudSystem%Op_KickLoc,MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddTo (MudSystem%Op_KickLoc,0.0d0)
- call MudSystem%Op_MudOrKick%AddTo (MudSystem%Op_KickLoc,0)
-
- else !Op_Density%Array (imudKick-1) == MudSystem%NewDensity
- MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)= (MudSystem%Op_Density%Array(MudSystem%Op_KickLoc-1)*MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewDensity*MudSystem%NewVolume)/(MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)+MudSystem%NewVolume)
- MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1)= MudSystem%Op_MudDischarged_Volume%Array(MudSystem%Op_KickLoc-1) + MudSystem%NewVolume
-
- endif
-
- else !if Op_KickLoc == 1 (*****Migration Start*****) *5-2===============================
-
- call MudSystem%Op_Density%AddToFirst (MudSystem%NewDensity)
- call MudSystem%Op_MudDischarged_Volume%AddToFirst (MudSystem%NewVolume)
- call MudSystem%Op_Mud_Forehead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Forehead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_Mud_Backhead_X%AddToFirst (MudSystem%Old_KickBackHead_X)
- call MudSystem%Op_Mud_Backhead_section%AddToFirst (MudSystem%Old_KickBackHead_Section)
- call MudSystem%Op_RemainedVolume_in_LastSection%AddToFirst (0.0d0)
- call MudSystem%Op_EmptyVolume_inBackheadLocation%AddToFirst (0.0d0)
- call MudSystem%Op_MudOrKick%AddToFirst (0)
-
- endif
-
- MudSystem%iLoc= 1 ! ok
-
- endif
-
-
- endif
-
- !========================================================================================
-
-
-
- !============================== kick 2 tarafe mate bashad *4 with pump ==============================
-
- !
- !if ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 .and. MudSystem%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
- ! !
- ! !MudSystem%NewDensity= Ann_Density%Array (Ann_KickLoc+1)
- ! !NewVolume= MinKickDv
- !
- !
- ! if ( ((MudSystem%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= ((MudSystem%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) /=MudSystem%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_KickLocMudSystem%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) == MudSystem%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 MudSystem%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) + ((MudSystem%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) /=MudSystem%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_KickLocMudSystem%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) == MudSystem%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 MudSystem%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 ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) >= KickDv ) ! sorate pump bishtar az kick bashad
- !
- !
- !
- !
- ! else !if( ((MudSystem%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(*,*) MudSystem%St_Density%Last()=' ,MudSystem%St_Density%Last()
- ! !write(*,*) '((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)=' , ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline)
- ! !write(*,*) 'Ann_Density%Array(Ann_KickLoc+1)=' , Ann_Density%Array(Ann_KickLoc+1)
- ! !write(*,*) '(MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline))=' , (MinKickDv-((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline))
- !
- !
- ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) &
- ! / (((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + (MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline)))
- ! NewVolume= MinKickDv
- !
- !
- ! Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - (MinKickDv-((MudSystem%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) - MudSystem%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,MudSystem%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*MudSystem%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 (MudSystem%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'
- !
- ! MudSystem%NewDensity= MudSystem%St_Density%Last()*((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline) + Ann_Density%Array(Ann_KickLoc+1)*(MinKickDv-((MudSystem%AnnulusFlowRate/60.0d0)*DeltaT_Mudline))) &
- ! / (((MudSystem%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) - MudSystem%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,MudSystem%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*MudSystem%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 (MudSystem%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'
- !
- ! MudSystem%NewDensity=MudSystem%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) - MudSystem%NewDensity) > DensityMixTol) then ! .OR. (Op_MudDischarged_Volume%Array (Op_KickLoc-1)>42.) ) then
- ! !write(*,*) 'pointer 3'
- !
- !
- !
- !
- ! call Op_Density%AddTo (Op_KickLoc,MudSystem%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*MudSystem%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 (MudSystem%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 !( ((MudSystem%AnnulusFlowRate/60.)*DeltaT_Mudline) < KickDv ) ! sorate pump kamtar az kick bashad
- !
- !
- !
- !
- ! endif
-
- !========================================================================================
-
- ENDDO ! KickNumber= 1, NewInfluxNumber
- MudSystem%KickNumber = kickNumber
-
- !write(*,*) 'c)Ann_MudDischarged_Volume%Array(:)=' , sum(Ann_MudDischarged_Volume%Array(:))
-
-
-
- end subroutine Kick_Migration
|