|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181 |
- subroutine Kick_Migration ! is called in subroutine CirculationCodeSelect
-
- Use GeoElements_FluidModule
- USE CMudPropertiesVariables
- USE MudSystemVARIABLES
- USE Pump_VARIABLES
- use CDrillWatchVariables
- use CTanksVariables, TripTankVolume2 => 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= 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 KickNumber= NewInfluxNumber-NoGasPocket+1 , NewInfluxNumber
- !write(*,*) 'KickNumber=' , KickNumber
-
- if (KickFlux .AND. NOT(KickOffBottom) .and. KickNumber == NewInfluxNumber) cycle
-
- if ( KickNumber == 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
-
-
- Op_KickLoc= 0
- Ann_KickLoc= 0
- ChokeLine_KickLoc= 0
-
-
- do i = 1, Op_MudOrKick%Length ()
- if (Op_MudOrKick%Array(i) == KickNumber) then
- Op_KickLoc = i
- exit
- endif
- end do
-
- do i = 1, Ann_MudOrKick%Length ()
- if (Ann_MudOrKick%Array(i) == KickNumber) then
- Ann_KickLoc = i
- exit
- endif
- end do
-
- do i = 1, ChokeLine_MudOrKick%Length ()
- if (ChokeLine_MudOrKick%Array(i) == KickNumber) then
- 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 (Op_KickLoc == Op_MudOrKick%Length () .and. Ann_KickLoc==0 ) then
- !write(*,*) '****3'
-
- iloc= 2
-
- KickDv= Area_OpSectionFt(Op_Mud_Forehead_section%Array(Op_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal
-
-
- MinKickDv= min( KickDv,Ann_MudDischarged_Volume%Array (1), Op_MudDischarged_Volume%Last () )
-
- NewDensity= Ann_Density%Array (1)
- NewVolume= MinKickDv
-
- if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) ham baghi mimund
-
- Ann_MudDischarged_Volume%Array (1)= Ann_MudDischarged_Volume%Array (1) - MinKickDv
-
- call Ann_Density%AddToFirst (Op_Density%Last())
- call Ann_MudDischarged_Volume%AddToFirst (MinKickDv)
- 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
-
- ! backheade kick zire mate bashad
- if (Op_KickLoc > 1) then
- !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
-
- if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) 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 !Op_Density%Array (imudKick-1) == NewDensity
-
- Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
- Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
-
- endif
- else !if Op_KickLoc == 1 (*****Migration Start*****) *3-1===============================
- !write(*,*) '****3-1'
-
-
- 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 (1) ) then ! eleman bala sari baghi nemimund
-
- Ann_Density%Array(1)= Op_Density%Last()
- Ann_MudOrKick%Array(1)= KickNumber
-
- Op_MudDischarged_Volume%Array (Op_KickLoc)= Op_MudDischarged_Volume%Array (Op_KickLoc) - MinKickDv
-
- ! backheade kick zire mate bashad
- if (Op_KickLoc > 1) then
-
- !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
-
- if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) 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 !Op_Density%Array (imudKick-1) == NewDensity
-
- Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
- Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
-
- endif
-
- else !if Op_KickLoc == 1 (*****Migration Start*****) *3-2===============================
- !write(*,*) '****3-2'
-
-
- 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 hazf mishod
-
- Ann_MudDischarged_Volume%Array (1)= Ann_MudDischarged_Volume%Array (1) - MinKickDv
-
- call Ann_Density%AddToFirst (Op_Density%Last())
- call Ann_MudDischarged_Volume%AddToFirst (MinKickDv)
- 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)
-
-
- Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
- Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
-
- call Op_MudDischarged_Volume%Remove (Op_KickLoc)
- 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) /= NewDensity ) then
-
- if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
-
-
-
- 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 !Op_Density%Array (imudKick-1) == NewDensity
-
- Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
- Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
-
- endif
-
- else !if Op_KickLoc == 1 (*****Migration Start*****) *3-3===============================
- !write(*,*) '****3-3'
-
- 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
-
-
-
-
- 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 ( Op_KickLoc>0 .and. Op_KickLoc < Op_MudOrKick%Length () ) then
- !write(*,*) '****1'
- !iloc= 1
-
- KickDv= Area_OpSectionFt(Op_Mud_Forehead_section%Array(Op_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal
-
-
- Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
- Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
-
- if ( KickDv < Op_MudDischarged_Volume%Array (Op_KickLoc+1) ) then !eleman bala sari baghi mimund
-
- !write(*,*) 'cond 11111111111111'
-
- Op_MudDischarged_Volume%Array (Op_KickLoc+1)= Op_MudDischarged_Volume%Array (Op_KickLoc+1) - KickDv
-
- NewDensity= Op_Density%Array (Op_KickLoc+1)
- NewVolume= KickDv
-
- else !KickDv > Op_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund
-
- ! write(*,*) 'cond 22222222222222222'
-
-
- KickDv= Op_MudDischarged_Volume%Array (Op_KickLoc+1)
-
- NewVolume= KickDv
- NewDensity= Op_Density%Array (Op_KickLoc+1)
-
-
-
-
- call Op_MudDischarged_Volume%Remove (Op_KickLoc+1)
- call Op_Mud_Backhead_X%Remove (Op_KickLoc+1)
- call Op_Mud_Backhead_section%Remove (Op_KickLoc+1)
- call Op_Mud_Forehead_X%Remove (Op_KickLoc+1)
- call Op_Mud_Forehead_section%Remove (Op_KickLoc+1)
- call Op_Density%Remove (Op_KickLoc+1)
- call Op_RemainedVolume_in_LastSection%Remove (Op_KickLoc+1)
- call Op_EmptyVolume_inBackheadLocation%Remove (Op_KickLoc+1)
- call Op_MudOrKick%Remove (Op_KickLoc+1)
-
- endif
-
- ! backheade kick zire mate bashad
- if (Op_KickLoc > 1) then
- !if ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
-
- if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
-
-
-
-
- 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 !Op_Density%Array (Op_KickLoc-1) == NewDensity
-
- Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
- Op_MudDischarged_Volume%Array(Op_KickLoc-1)= Op_MudDischarged_Volume%Array(Op_KickLoc-1) + NewVolume
-
- endif
- else !if Op_KickLoc == 1 (*****Migration Start*****) *5-1===============================
- !write(*,*) '****5-1'
-
- 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
-
-
- endif
-
- !========================================================================================
-
- !write(*,*) 'a) density and cutting:' , Ann_Density%Length() , Ann_CuttingMud%Length()
-
-
- !=========================== tamame kick balaye mate bashad *2 ==================================
-
- if ( Ann_KickLoc > 0 .and. Op_KickLoc==0 ) then
- !write(*,*) '****2'
-
- !iloc= 1
-
- KickDv= Area_PipeSectionFt(Ann_Mud_Forehead_section%Array(Ann_KickLoc)) * KickDx * 7.48051948d0 ! ft^3 to gal
-
- NewDensity= Ann_Density%Array (Ann_KickLoc+1)
- NewVolume= KickDv
- CuttingValue= Ann_CuttingMud%Array (Ann_KickLoc+1)
-
- if ( KickDv < Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) ) then !eleman bala sari baghi mimund
-
- Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - KickDv
-
- else !KickDv > Ann_MudDischarged_Volume%Array (imudKick+1) eleman baghi nemimund
-
- KickDv= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)
- NewVolume= KickDv
-
- call Ann_MudDischarged_Volume%Remove (Ann_KickLoc+1)
- call Ann_Mud_Backhead_X%Remove (Ann_KickLoc+1)
- call Ann_Mud_Backhead_section%Remove (Ann_KickLoc+1)
- call Ann_Mud_Forehead_X%Remove (Ann_KickLoc+1)
- call Ann_Mud_Forehead_section%Remove (Ann_KickLoc+1)
- call Ann_Density%Remove (Ann_KickLoc+1)
- call Ann_RemainedVolume_in_LastSection%Remove (Ann_KickLoc+1)
- call Ann_EmptyVolume_inBackheadLocation%Remove (Ann_KickLoc+1)
- call Ann_MudOrKick%Remove (Ann_KickLoc+1)
- call Ann_CuttingMud%Remove (Ann_KickLoc+1)
-
- endif
-
- ! backheade kick balaye mate bashad
-
- if (Ann_KIckLoc > 1) then
- !if ( Ann_Density%Array (Ann_KickLoc-1) /= NewDensity ) then
-
- if ( ABS(Ann_Density%Array (Ann_KickLoc-1) - NewDensity) >= DensityMixTol ) then
-
- Old_KickBackHead_X= Ann_Mud_Backhead_X%Array (Ann_KickLoc)
- Old_KickBackHead_Section= Ann_Mud_Backhead_section%Array (Ann_KickLoc)
-
-
- call Ann_Density%AddTo (Ann_KickLoc,NewDensity)
- call Ann_MudDischarged_Volume%AddTo (Ann_KickLoc,NewVolume)
- call Ann_Mud_Forehead_X%AddTo (Ann_KickLoc,Old_KickBackHead_X)
- call Ann_Mud_Forehead_section%AddTo (Ann_KickLoc,Old_KickBackHead_Section)
- call Ann_Mud_Backhead_X%AddTo (Ann_KickLoc,Old_KickBackHead_X)
- call Ann_Mud_Backhead_section%AddTo (Ann_KickLoc,Old_KickBackHead_Section)
- call Ann_RemainedVolume_in_LastSection%AddTo (Ann_KickLoc,0.0d0)
- call Ann_EmptyVolume_inBackheadLocation%AddTo (Ann_KickLoc,0.0d0)
- call Ann_MudOrKick%AddTo (Ann_KickLoc,0)
- call Ann_CuttingMud%AddTo (Ann_KickLoc,0)
-
- else !Op_Density%Array (imudKick-1) == NewDensity
-
- Ann_Density%Array(Ann_KickLoc-1)= (Ann_Density%Array(Ann_KickLoc-1)*Ann_MudDischarged_Volume%Array(Ann_KickLoc-1)+NewDensity*NewVolume)/(Ann_MudDischarged_Volume%Array(Ann_KickLoc-1)+NewVolume)
- Ann_MudDischarged_Volume%Array(Ann_KickLoc-1)= Ann_MudDischarged_Volume%Array(Ann_KickLoc-1) + NewVolume
-
-
- endif
-
- else !if Ann_KickLoc == 1 *6 ===============================
- !write(*,*) '****6'
-
- Old_KickBackHead_X= Ann_Mud_Backhead_X%Array (Ann_KickLoc)
- Old_KickBackHead_Section= Ann_Mud_Backhead_section%Array (Ann_KickLoc)
-
-
- call Ann_Density%AddToFirst (NewDensity)
- call Ann_MudDischarged_Volume%AddToFirst (NewVolume)
- call Ann_Mud_Forehead_X%AddToFirst (Old_KickBackHead_X)
- call Ann_Mud_Forehead_section%AddToFirst (Old_KickBackHead_Section)
- call Ann_Mud_Backhead_X%AddToFirst (Old_KickBackHead_X)
- call Ann_Mud_Backhead_section%AddToFirst (Old_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 ( Ann_KickLoc > 0 .and. Op_KickLoc > 0 ) then
- !write(*,*) '****4'
-
- 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
-
- NewDensity= Ann_Density%Array (Ann_KickLoc+1)
- NewVolume= MinKickDv
-
- if ( MinKickDv == KickDv ) then !eleman bala sari baghi mimund, paeeni(kick) dar OP ham baghi mimund
- !write(*,*) '****4----1'
-
-
- Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - MinKickDv
-
- 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 ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
-
- if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) 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
-
- Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
- 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'
-
- 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'
-
- call Ann_MudDischarged_Volume%Remove (Ann_KickLoc+1)
- call Ann_Mud_Backhead_X%Remove (Ann_KickLoc+1)
- call Ann_Mud_Backhead_section%Remove (Ann_KickLoc+1)
- call Ann_Mud_Forehead_X%Remove (Ann_KickLoc+1)
- call Ann_Mud_Forehead_section%Remove (Ann_KickLoc+1)
- call Ann_Density%Remove (Ann_KickLoc+1)
- call Ann_RemainedVolume_in_LastSection%Remove (Ann_KickLoc+1)
- call Ann_EmptyVolume_inBackheadLocation%Remove (Ann_KickLoc+1)
- call Ann_MudOrKick%Remove (Ann_KickLoc+1)
- call Ann_CuttingMud%Remove (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 ( Op_Density%Array (Op_KickLoc-1) /= NewDensity ) then
-
- if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) 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 !Op_Density%Array (imudKick-1) == NewDensity
- Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
- 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===============================
-
- 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'
-
-
-
- Ann_MudDischarged_Volume%Array (Ann_KickLoc+1)= Ann_MudDischarged_Volume%Array (Ann_KickLoc+1) - MinKickDv
-
- Ann_MudDischarged_Volume%Array (Ann_KickLoc)= Ann_MudDischarged_Volume%Array (Ann_KickLoc) + MinKickDv ! Ann_KickLoc= 1
-
-
-
- Old_KickBackHead_X= Op_Mud_Backhead_X%Array (Op_KickLoc)
- Old_KickBackHead_Section= Op_Mud_Backhead_section%Array (Op_KickLoc)
-
-
- 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) /= NewDensity ) then
-
- if ( ABS(Op_Density%Array (Op_KickLoc-1) - NewDensity) >= DensityMixTol ) then
-
-
- 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 !Op_Density%Array (imudKick-1) == NewDensity
- Op_Density%Array(Op_KickLoc-1)= (Op_Density%Array(Op_KickLoc-1)*Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewDensity*NewVolume)/(Op_MudDischarged_Volume%Array(Op_KickLoc-1)+NewVolume)
- 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===============================
-
- 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
-
- iloc= 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
|