|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478 |
- module MudSystem
-
- USE MudSystemVARIABLES
- USE PressureDisplayVARIABLES
- USE FricPressDropVars
- USE Fluid_Flow_Startup_Vars
- USE CMudPropertiesVariables
- USE CManifolds
- USE CPumpsVariables
- USE CUnityOutputs
- use CWarningsVariables
- use DynamicIntegerArray
- use CError
- use CLog1
- USE CDataDisplayConsoleVariables
- use CStudentStationVariables , PitGainLossReset=>PitGainLossZero
-
-
- implicit none
-
- real j2,j12,j13,jj2,jj12,jj13
- real A71,A72,A73
- integer j3,B71,B77,B78
- integer j4
- real C71,C77,C78
- integer j5
- integer j6,D71,D80
- integer j7,j8,j9,j10,j11
- real E71,E72,E73
- real F71,F72,F73
- integer j14
- real G82,G83,G84
- integer j15
- real H82,H83,H84
- integer j16,K82,K83,K84,K79,K78
- integer j17,L82,L83,L84,L79,L78
- integer j18
- real M71,M77,M78, Pump1toCh,Pump2toCh,Pump3toCh,Denominator_a
- integer j19
- real N82,N83,N84
- integer j20
- integer j21
- real unityreturn
-
-
-
- real(8) DumpPump1,DumpPump2,DumpCementPump,Denominator
- real(8) Mp1Coef,Mp2Coef,CpCoef
- real(8) PumpPressure1,PumpPressure2,PumpPressure3
- integer Mp1_NoPath,Mp2_NoPath,Cp_NoPath
- real P1toSt,P2toSt,CptoSt
- real(8) MaxWorkingPressure1,MaxWorkingPressure2,MaxWorkingPressure3,MaxWorkingPressure
-
- REAL(8) DumpFromKelly, DumpFromFillupHead
- real(8) AddedVolumeToTank,PUMP1_Flow_Rate_Old,PUMP2_Flow_Rate_Old,PUMP3_Flow_Rate_Old
- real(8) VolumeToActive,VolumeToBellNipple,BellNipple_FlowCoef,ChokeLine_FlowCoef
-
-
- REAL RealJ2,RealJ12,RealJ13,RealJ4,RealJ18
- INTEGER active32,active33,active34,active35,active29
-
- logical condition1, condition2, condition3, condition4, condition5, condition6, condition7, condition8, condition9, condition10, condition11, condition12, condition13, condition14, condition15
- logical condition16,condition17,condition18,condition19,condition20,condition21,condition22,condition23,condition24,condition25,condition26,condition27,condition28,condition29,condition30,condition31
- logical condition32,condition33,condition34,condition35,condition36,condition37,condition38,condition39,condition40,condition41,condition42,condition43,condition44,condition45
- logical condition46,condition47,condition48,condition49,condition50,condition51,condition52,condition53,condition54,condition55,condition56,condition57,condition58
- logical condition59,condition60,condition61
- logical ac32, ac33, ac34, ac35, ac29
- logical ThereIsPathFrom_71_72_73_To_82, ThereIsPathFrom_71_72_73_To_83, ThereIsPathFrom_71_72_73_To_84
- logical DumpFromKelly_Pump1, DumpFromKelly_Pump2, DumpFromKelly_Pump3
- logical DumpFromTopDrive_Pump1,DumpFromTopDrive_Pump2,DumpFromTopDrive_Pump3
- logical DumpFromFillupHead_Pump1, DumpFromFillupHead_Pump2, DumpFromFillupHead_Pump3
- logical State1,State2, State3, State4
- type(DynamicIntegerArrayType) Pump1_Lasts,Pump2_Lasts, Pump3_Lasts
- REAL MP1_Q, MP2_Q, MP3_Q
- real TimePassed
-
- real(8) active_after, active_before, active_increase, total_active_increase,total_decrease,sys_total_injected
- real(8) total_annFlow,total_DeltaVPipe
- contains
-
- subroutine LineupAndPath()
- implicit none
-
- !===========================================================================
- ! MUDLINE CODE
- !===========================================================================
- ! Initialize
- j2=0
- jj2=0
- A71=0
- A72=0
- A73=0
- RealJ2=0.0
-
- j3=0
- B71=0
- B77=0
- B78=0
-
- j4=0
- C71=0.
- C77=0.
- C78=0.
- active32=0
- active33=0
- active34=0
- active35=0
- active29=0
-
-
- j5=0
-
- j6=0
- D71=0
- D80=0
-
- j7=0
-
- j8=0
-
- j9=0
- j10=0
- j11=0
-
- j12=0
- jj12=0
- E71=0
- E72=0
- E73=0
- RealJ12=0.0
-
- j13=0
- jj13=0
- F71=0
- F72=0
- F73=0
- RealJ13=0.0
-
- j14=0
- G82=0
- G83=0
- G84=0
-
- DumpPump1=0.
- DumpPump2=0.
- DumpCementPump=0.
-
- j15=0
- H82=0.0
- H83=0.0
- H84=0.0
-
- Mp1Coef= 0.0
- Mp1Coef= 0.0
- CpCoef= 0.0
-
- Mp1_NoPath= 0
- Mp2_NoPath= 0
- Cp_NoPath= 0
-
- j16=0
- K82=0
- K83=0
- K84=0
- K78=0
- K79=0
-
-
- j17=0
- L82=0
- L83=0
- L84=0
- L78=0
- L79=0
-
- j18=0
- M71=0.
- M77=0.
- M78=0.
- Pump1toCh=0.
- Pump2toCh=0.
- Pump3toCh=0.
-
-
- j19=0
- N82=0
- N83=0
- N84=0
-
- j20=0
-
- j21=0
-
-
-
- !===========================================================================
-
- !===============TanksToMudPump1=================
- if(condition1) then
- j2=j2+1
- A71=1
- jj2=1
- endif
-
- if(condition2) then
- j2=j2+1
- A72=1
- jj2=1
- endif
-
- if(condition3) then
- j2=j2+1
- A73=1
- jj2=1
- endif
-
- !================================================
-
- !============BellNippleToPits-FullWell==============
- if(FirstMudSet== 1 ) then !.and. WellisNOTFull== .false.) then ! Well Must Be Full !Ann_Mud_Forehead_X%Last()==AboveAnnularHeight .and. Ann_Density%Last()/=0.0)
- if(condition4) then
- j3=j3+1
- B71=1
- endif
-
- if(condition5) then
- j3=j3+1
- B77=1
- endif
-
- if(condition6) then
- j3=j3+1
- B78=1
- endif
-
- endif
-
- !================================================
-
- !============WellToChokeManifold(Through 26)==============
- if(condition7) then
- j4=j4+1
- C71=1.
- endif
-
- if(condition8) then
- j4=j4+1
- C77=1.
- endif
-
- if(condition45) then
- j4=j4+1
- C78=1.
- endif
- if (ac32) active32=1
- if (ac33) active33=1
- if (ac34) active34=1
- if (ac35) active35=1
- if (ac29) active29=1 !BYPASS VALVE
-
-
-
- !================================================
-
-
- !============ActiveTankToTripTank==============
- if(condition9) then
- j5=j5+1
- endif
- !================================================
-
- !write(*,*) 'j5====' , j5
- !============TripTankToActiveTank And BellNipple==============
- if(condition10) then
- j6=j6+1
- D71=1
- endif
-
- if(condition11) then
- j6=j6+1
- D80=1
- endif
- !================================================
-
- !============ActiveTankToDump==============
- if(condition12) then
- j7=j7+1
- endif
- !================================================
-
- !============TripTankToDump==============
- if(condition13) then
- j8=j8+1
- endif
- !================================================
-
- !============WellToBellNipple==============
- if(condition14) then
- j9=j9+1
- endif
- !================================================
-
- !============MudBucketToBellNipple==============
- if(condition15) then
- j10=j10+1
- endif
- !================================================
-
- !============BellNippleToWell-NonFullWell==============
-
-
- if(condition16 .and. FirstMudSet== 1 .and. BellNippleVolume > 0.0001 .and. WellisNOTFull) then
-
- write(*,*) 'MUD(7)%Q=' , MUD(7)%Q
- write(*,*) 'BellNippleVolume=' , BellNippleVolume
-
-
- write(*,*) 'MudVolume_InjectedFromAnn-WellToBellNipple=' , MudVolume_InjectedFromAnn
-
- write(*,*) 'int:::=' , (Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight)
- write(*,*) 'Ann_Mud_Forehead_X%Last()=' , Ann_Mud_Forehead_X%Last()
- write(*,*) 'AboveAnnularHeight=' , BopStackSpecification%AboveAnnularHeight
- write(*,*) 'Ann_Density%Last()=' , Ann_Density%Last()
- CALL ErrorStop('error stop1')
-
- j11=j11+1
- endif
- !================================================
-
- !===============TanksToMudPump2===================
-
- if(condition17) then
- j12=j12+1
- E71=1
- jj12=1
- endif
-
- if(condition18) then
- j12=j12+1
- E72=1
- jj12=1
- endif
-
- if(condition19) then
- j12=j12+1
- E73=1
- jj12=1
- endif
-
- !================================================
-
- !===============TanksToCementPump===================
- if(condition20) then
- j13=j13+1
- F71=1
- jj13=1
- endif
-
- if(condition21) then
- j13=j13+1
- F72=1
- jj13=1
- endif
-
- if(condition22) then
- j13=j13+1
- F73=1
- jj13=1
- endif
-
- !================================================
-
- !===============PumpsToString===================
- if(condition23) then
- j14=j14+1
- G82=1
- endif
-
- if(condition24) then
- j14=j14+1
- G83=1
- endif
-
- if(condition25) then
- j14=j14+1
- G84=1
- endif
- !================================================
-
-
- !===============PumpsToDump===================
- if(condition26) then
- DumpPump1=1.0
- endif
-
- if(condition27) then
- DumpPump2=1.0
- endif
-
- if(condition28) then
- DumpCementPump=1.0
- endif
- !================================================
-
-
- !=======MudPumps1&2ToActiveTank_Through65&66==========
- if(condition29) then
- !write(*,*) 'condition 29'
- j15=j15+1
- H82=1.0
- endif
-
- if(condition30) then
- j15=j15+1
- H83=1.0
- endif
-
- !================================================
-
-
- !=======CementPumpToActiveTank_Through65==========
-
- if(condition31) then
-
- H84=1.0
-
- endif
- !================================================
-
- !write(*,*) 'condition32===' , condition32
-
- !============MudPump1HasNoPath===================
- if(condition32Final) then
- !write(*,*) 'MudPump1HasNoPath'
- Mp1_NoPath = 1
- endif
- !================================================
-
- !============MudPump2HasNoPath===================
- if(condition33Final) then
- !write(*,*) 'MudPump2HasNoPath'
- Mp2_NoPath = 1
- endif
- !================================================
-
-
- !============CementPumpHasNoPath===================
- if(condition34Final) then
- Cp_NoPath = 1
- endif
- !================================================
-
- !===============PathsToGauge75===================
- if(condition35) then !Pump1 to Gauge75
- j16=j16+1
- K82=1
- endif
-
- if(condition36) then !Pump2 to Gauge75
- j16=j16+1
- K83=1
- endif
-
- if(condition37) then !Pump3 to Gauge75
- j16=j16+1
- K84=1
- endif
-
- if(condition38) then !String to Gauge75
- j16=j16+1
- K79=1
- endif
-
- if(condition39) then !Dump to Gauge75
- j16=j16+1
- K78=1
- endif
-
- !================================================
- !write(*,*) '****j16=' , j16
- !===============PathsToGauge76===================
- if(condition40) then !Pump1 to Gauge76
- j17=j17+1
- L82=1
- endif
-
- if(condition41) then !Pump2 to Gauge76
- j17=j17+1
- L83=1
- endif
-
- if(condition42) then !Pump3 to Gauge76
- j17=j17+1
- L84=1
- endif
-
- if(condition43) then !String to Gauge76
- j17=j17+1
- L79=1
- endif
-
- if(condition44) then !Dump to Gauge76
- j17=j17+1
- L78=1
- endif
-
- !================================================
-
- !====Pump1-StandPipeManifoldToChokeManifold-Through ChokeLine====
- if(condition46) then
- j18=j18+1
- M71=1.
- Pump1toCh= 1.
- endif
-
- if(condition47) then
- j18=j18+1
- M77=1.
- Pump1toCh= 1.
- endif
-
- if(condition48) then
- j18=j18+1
- M78=1.
- Pump1toCh= 1.
- endif
- !=================================================================
-
-
- !====Pump2-StandPipeManifoldToChokeManifold-Through ChokeLine====
- if(condition49) then
- j18=j18+1
- M71=1.
- Pump2toCh= 1.
- endif
-
- if(condition50) then
- j18=j18+1
- M77=1.
- Pump2toCh= 1.
- endif
-
- if(condition51) then
- j18=j18+1
- M78=1.
- Pump2toCh= 1.
- endif
- !=================================================================
-
-
- !====Pump3-StandPipeManifoldToChokeManifold-Through ChokeLine====
- if(condition52) then
- j18=j18+1
- M71=1.
- Pump3toCh= 1.
- endif
-
- if(condition53) then
- j18=j18+1
- M77=1.
- Pump3toCh= 1.
- endif
-
- if(condition54) then
- j18=j18+1
- M78=1.
- Pump3toCh= 1.
- endif
- !=================================================================
-
-
- !===============PumpsToWell_KillLine============
- if(condition55) then
- j19=j19+1
- N82=1
- endif
-
- if(condition56) then
- j19=j19+1
- N83=1
- endif
-
- if(condition57) then
- j19=j19+1
- N84=1
- endif
- !================================================
-
- !===============WellToChokeLineGauge============
- if(condition58) then
- j20=j20+1
- endif
-
- if (j20>0) then
- WellToChokeLineGauge= .true.
- else
- WellToChokeLineGauge= .false.
- endif
- !================================================
-
-
- !============ChokeLineGaugeToTanks===============
- if(condition59) then
- j21=j21+1
- endif
-
- if(condition60) then
- j21=j21+1
- endif
-
- if(condition61) then
- j21=j21+1
- endif
-
- if (j21>0) then
- ChokeLineGaugeToTanks= .true.
- else
- ChokeLineGaugeToTanks= .false.
- endif
- !================================================
-
-
- end subroutine
-
- subroutine main
- Use GeoElements_FluidModule
- USE Pumps_VARIABLES
- USE CHOKEVARIABLES
- USE CDataDisplayConsoleVariables
- use CDrillWatchVariables
- use CHOKEVARIABLES
- use CChokeManifoldVariables
- use CTanksVariables
- Use KickVariables
- Use CHoistingVariables
- use CSimulationVariables
-
- implicit none
- Integer I
-
- MudSys_timeCounter = MudSys_timeCounter + 1
- if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
- MudSys_timeCounter= 0
- endif
-
- !WRITE (*,*) 'MudSys_timeCounter', MudSys_timeCounter
- if (PumpsSpecification%MudPump1ReliefValveIsSet==.false.) PumpsSpecification%MudPump1ReliefValvePressure=6000.
- if (PumpsSpecification%MudPump2ReliefValveIsSet==.false.) PumpsSpecification%MudPump2ReliefValvePressure=6000.
- if (PumpsSpecification%CementPumpReliefValveIsSet==.false.) PumpsSpecification%CementPumpReliefValvePressure=6000.
- !===========================================================================================================================
- !===========================================================================================================================
- ! >>> Should Be on Top of Other Codes <<<
-
-
- !ActiveTankVolume= ActiveMudVolumeGal ! update from student input
- !ActiveTankDensity= ActiveDensity ! update from student input
- !ReserveTankVolume= ReserveMudVolumeGal ! update from student input
- !ReserveTankDensity= ReserveDensity ! update from student input
- if (j7 > 0) then !ActiveTankToDump
- ActiveTankDensity= 0.
- ActiveTankVolume= 0.
- endif
-
-
- if (j8 > 0) then !TripTankToDump
- TripTankDensityCalc= 0.
- TripTankVolumeCalc= 0.
- endif
- !===========================================================================================================================
- !===========================================================================================================================
- if (j15 > 0) then !MudPumps1&2ToActiveTank_Through65&66
- !write(*,*) 'j15 is open'
- ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >>
-
-
- if (j2>0) Mp1Coef= 1.0
- if (j12>0) Mp2Coef= 1.0
-
-
- if (j2 /= 0 .or. j12/= 0) then
-
-
- ActiveTankDensity = (ActiveTankDensity*ActiveTankVolume+ Mp1Coef*Mp1Density*(PUMP(1)%Flow_Rate*DeltaT_Mudline/60.) + Mp2Coef*Mp2Density*(PUMP(2)%Flow_Rate*DeltaT_Mudline/60.))/ &
- (ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*DeltaT_Mudline/60.))
-
- ActiveTankVolume= ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*DeltaT_Mudline/60.
- !write(*,*) 'active by j15'
- endif
-
-
- ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
- !if ActiveTankVolume is higher, excess amount is dumped
-
- endif
-
-
- if (H84 > 0.0) then !CementPumpToCementTank_Through67
-
- if (j13>0) CpCoef= 1.0
-
-
- CementTankDensityCalc= (CementTankDensityCalc*CementTankVolumeCalc+ CpCoef*Mp3Density*(PUMP(3)%Flow_Rate*DeltaT_Mudline/60.) ) / &
- (CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*DeltaT_Mudline/60.))
-
- CementTankVolumeCalc= CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*DeltaT_Mudline/60.)
-
-
- endif
-
- !===========================================================================================================================
- !===========================================================================================================================
- ! DUMP Path
- PumpsDumpVolume= PumpsDumpVolume+ (jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate) *DeltaT_Mudline/60.
- PumpsDumpFlowRate= jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate
- !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate
-
- if (Hoisting%DriveType==1 .and. PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then
- !write(*,*) 'Set_FlowFromKelly(.TRUE.)'
- call Activate_PumpWithKellyDisconnected()
- !write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate
- CALL Set_FlowFromKelly(min(PumpsDumpFlowRate/6.,100.)) ! .TRUE. before
- elseif (Hoisting%DriveType==1) then
- call Deactivate_PumpWithKellyDisconnected()
- CALL Set_FlowFromKelly(0.0) ! .FALSE. before
- !write(*,*) 'Set_FlowFromKelly(.FALSE.)'
-
- endif
- !write(*,*) 'DumpFromFillupHead_Pump1=' , DumpFromFillupHead_Pump1
-
-
- if (Hoisting%DriveType==0 .and. PumpsDumpFlowRate > 0.0 .and. (DumpFromTopDrive_Pump1 .or. DumpFromTopDrive_Pump2 .or. DumpFromTopDrive_Pump3)) then
- !write(*,*) 'Set_FlowFromKelly(.TRUE.)'
- call Activate_PumpWithTopdriveDisconnected()
- CALL Set_FlowFromKelly(min(PumpsDumpFlowRate/6.,100.)) ! .TRUE. before
- elseif (Hoisting%DriveType==0) then
- call Deactivate_PumpWithTopdriveDisconnected()
- CALL Set_FlowFromKelly(0.0) ! .FALSE. before
- !write(*,*) 'Set_FlowFromKelly(.FALSE.)'
-
- endif
-
-
-
- if (PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then
-
- !call Activate_PumpWithKellyDisconnected()
- CALL Set_FlowFromFillupHead(min(PumpsDumpFlowRate/6.,100.)) ! .TRUE. before
- else
- !call Deactivate_PumpWithKellyDisconnected()
- CALL Set_FlowFromFillupHead(0.0) ! .FALSE. before
-
- endif
- !####C_Program -----> DriveType =
- ! = 0 TopDrive_DriveType
- ! = 1 Kelly_DriveType
- !===========================================================================================================================
- !===========================================================================================================================
- ! ****** Calculating Maximum Working Pressure
- if (PumpsSpecification%MudPump1ReliefValveIsSet) then
- MaxWorkingPressure1= PumpsSpecification%MudPump1ReliefValvePressure
- else
- MaxWorkingPressure1= 6000. !psi
- endif
-
-
- if (PumpsSpecification%MudPump2ReliefValveIsSet) then
- MaxWorkingPressure2= PumpsSpecification%MudPump2ReliefValvePressure
- else
- MaxWorkingPressure2= 6000. !psi
- endif
-
- if (PumpsSpecification%CementPumpReliefValveIsSet) then
- MaxWorkingPressure3= PumpsSpecification%CementPumpReliefValveIsSet
- else
- MaxWorkingPressure3= 6000. !psi
- endif
-
-
- if (State1) then
- MaxWorkingPressure= min(MaxWorkingPressure1 , MaxWorkingPressure2 , MaxWorkingPressure3)
- MaxWorkingPressure1= MaxWorkingPressure
- MaxWorkingPressure2= MaxWorkingPressure
- MaxWorkingPressure3= MaxWorkingPressure
- endif
-
-
- if (State2) then
- MaxWorkingPressure= min(MaxWorkingPressure1 , MaxWorkingPressure2)
- MaxWorkingPressure1= MaxWorkingPressure
- MaxWorkingPressure2= MaxWorkingPressure
- endif
-
- if (State3) then
- MaxWorkingPressure= min(MaxWorkingPressure1 , MaxWorkingPressure3)
- MaxWorkingPressure1= MaxWorkingPressure
- MaxWorkingPressure3= MaxWorkingPressure
- endif
-
-
- if (State4) then
- MaxWorkingPressure= min(MaxWorkingPressure2 , MaxWorkingPressure3)
- MaxWorkingPressure2= MaxWorkingPressure
- MaxWorkingPressure3= MaxWorkingPressure
- endif
- ! Calculating Maximum Working Pressure ******
-
- !===========================================================================================================================
- !===========================================================================================================================
-
-
- ! ****** Blown Conditions
-
- !G: PumpsToString Coefficient
- !jJ2,Jj12,Jj13: TanksToMudPump Coefficient
- !H: Pumps To Tank_Through65 or 67 Coefficient
-
- !write(*,*) 'j12=' , j12
- !write(*,*) 'H83=' , H83
- !write(*,*) 'DumpPump2=' , DumpPump2
- !write(*,*) 'G83=' , G83
- PumpPressure1= jj2*(1-H82)*(1-DumpPump1)*G82* PressureGauges(1)
- PumpPressure2= jj12*(1-H83)*(1-DumpPump2)*G83* PressureGauges(1)
- PumpPressure3= jj13*(1-H84)*(1-DumpCementPump)*G84* PressureGauges(1)
- !
- !write(*,*) 'jj2 , H82 , DumpPump1 , G82,PresCsureGauges(1)=' , jj2 , H82 , DumpPump1 , G82,PressureGauges(1)
- !write(*,*) '1)PumpPressure1=' , PumpPressure1
-
- !write(*,*) 'PumpPressure2=' , PumpPressure2
-
- PumpToManifoldMudVol = 3.0 * 42.0
- !PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP1_Q / ConvMinToSec * dt
- !PumpToManifoldDeltaPDueToCompressibility = PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol)
-
- IF(Mp1_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_82 .and. MP1_Q > 0.0) then
- PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP1_Q / ConvMinToSec * dt
- PumpPressure1= PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol)
- write(*,*) '21)PumpPressure1=' , PumpPressure1
-
- WRITE (*,*) ' valve 1 ', Manifold%Valve(1)%Status
- WRITE (*,*) ' valve 4 ', Manifold%Valve(4)%Status
- WRITE (*,*) ' valve 6 ', Manifold%Valve(6)%Status
- WRITE (*,*) ' valve 7 ', Manifold%Valve(7)%Status
- WRITE (*,*) ' valve 8 ', Manifold%Valve(8)%Status
- WRITE (*,*) ' valve 9 ', Manifold%Valve(9)%Status
- WRITE (*,*) ' valve 13 ', Manifold%Valve(13)%Status
- WRITE (*,*) ' valve 68 ', Manifold%Valve(68)%Status
- WRITE (*,*) ' valve 69 ', Manifold%Valve(69)%Status
- WRITE (*,*) ' valve 48 ', Manifold%Valve(48)%Status
-
- !call DisplayOpenPathsWrite()
-
- ENDIF
-
- IF(Mp2_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_83 .and. MP2_Q > 0.0 ) then
- PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP2_Q / ConvMinToSec * dt
- PumpPressure2= PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol)
- write(*,*) '22)PumpPressure1=' , PumpPressure2
-
- WRITE (*,*) ' -valve 1 ', Manifold%Valve(1)%Status
- WRITE (*,*) ' -valve 4 ', Manifold%Valve(4)%Status
- WRITE (*,*) ' -valve 6 ', Manifold%Valve(6)%Status
- WRITE (*,*) ' -valve 7 ', Manifold%Valve(7)%Status
- WRITE (*,*) ' -valve 8 ', Manifold%Valve(8)%Status
- WRITE (*,*) ' -valve 9 ', Manifold%Valve(9)%Status
- WRITE (*,*) ' -valve 13 ', Manifold%Valve(13)%Status
- WRITE (*,*) ' -valve 68 ', Manifold%Valve(68)%Status
- WRITE (*,*) ' -valve 69 ', Manifold%Valve(69)%Status
- WRITE (*,*) ' -valve 48 ', Manifold%Valve(48)%Status
-
- !call DisplayOpenPathsWrites()
- ENDIF
-
- IF(Cp_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_84 .AND. MP3_Q > 0.0 ) then
- PumpToManifoldCompressedMudVol = PumpToManifoldCompressedMudVol + MP3_Q / ConvMinToSec * dt
- PumpPressure3= PumpToManifoldCompressedMudVol / (MudCompressibility * PumpToManifoldMudVol)
- ENDIF
-
- !*****************************************************************************
-
-
- !if(((Mp1_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_82) .or. ( PumpPressure1 >= MaxWorkingPressure1 ) &
- !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array)))) .and. MP1_Q > 0.0 ) then
- !write(*,*) ' failurrrrre '
-
- if (PumpPressure1 >= MaxWorkingPressure1 .and. MP1_Q > 0.0) then
- write(*,*) 'mp1,if=' , PumpPressure1 , MaxWorkingPressure1 , MP1_Q
- Pump1BlownCount = Pump1BlownCount + 1
- !if (Pump1BlownStarted == .FALSE.) then
- ! write(*,*) 'if (Pump1BlownStarted == .FALSE. ) then'
- ! Pump1BlownInTimeStep = SimulationTime + BlownThresholdInSecond
- ! Pump1BlownStarted = .TRUE.
- !endif
- !write(*,*) 'SimulationTime===', SimulationTime, Pump1BlownInTimeStep
- if(PumpsSpecification%MudPump1ReliefValveIsSet .and. Pump1BlownCount >= BlownThreshold) then
- write(*,*) 'valve 65 open, BLOWN'
- call ChangeValve(65, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- Pump1BlownCount = 0
- !Pump1BlownStarted = .FALSE.
- !else
- ! write(*,*) 'PumpPressure1= 6000 psi'
- ! PumpPressure1= 6000. !psi
- endif
- !else
- !Pump1BlownInTimeStep = 0
- !Pump1BlownStarted = .FALSE.
- !write(*,*) 'Pump1BlownStarted = .FALSE.'
- endif
-
- !write(*,*) ' valve 65=' , Valve(65)%Status
-
-
-
- !if(((Mp2_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_83) .or. PumpPressure2 >= MaxWorkingPressure2 &
- !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array))) ) .and. MP2_Q > 0.0 ) then
-
- if(PumpPressure2 >= MaxWorkingPressure2 .and. MP2_Q > 0.0 ) then
-
- write(*,*) 'mp2,if=' , PumpPressure2 , MaxWorkingPressure2 , MP2_Q
- Pump2BlownCount = Pump2BlownCount + 1
- !if (Pump2BlownStarted == .FALSE. ) then
- ! Pump2BlownInTimeStep = SimulationTime + BlownThresholdInSecond
- ! Pump2BlownStarted = .TRUE.
- !endif
- !if (MudPump2ReliefValveIsSet .and. SimulationTime >= Pump2BlownInTimeStep .and. Pump2BlownStarted) then
- if (PumpsSpecification%MudPump2ReliefValveIsSet .and. Pump2BlownCount >= BlownThreshold) then
- write(*,*) 'valve 66 open, BLOWN'
- call ChangeValve(66, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- Pump2BlownCount = 0
- !Pump2BlownInTimeStep = 0
- !Pump2BlownStarted = .FALSE.
- !else
- ! PumpPressure2= 6000. !psi
- endif
- !else
- !Pump2BlownInTimeStep = 0
- !Pump2BlownStarted = .FALSE.
- endif
-
- !if(((Cp_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_84) .or. PumpPressure3 >= MaxWorkingPressure3 &
- !.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array)))) .and. MP3_Q > 0.0 ) then
-
- if(PumpPressure3 >= MaxWorkingPressure3 .and. MP3_Q > 0.0 ) then
- Pump3BlownCount = Pump3BlownCount + 1
- if (PumpsSpecification%CementPumpReliefValveIsSet .and. Pump3BlownCount >= BlownThreshold) then
- !write(*,*) 'valve 67 open, BLOWN'
- call ChangeValve(67, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- Pump3BlownCount = 0
- !else
- ! PumpPressure3= 6000. !psi
- endif
- !else
- !Pump3BlownInTimeStep = 0
- !Pump3BlownStarted = .FALSE.
- endif
-
- !write(*,*) '3)PumpPressure1=' , PumpPressure1
-
- if (PumpPressure1>= 6000.) then
- Pump1BlownCount = Pump1BlownCount + 1
- if(Pump1BlownCount >= BlownThreshold) then
- call ChangeValve(65, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- call Activate_Pump1Failure()
- Pump1OffFailure= .true.
- Pump1BlownCount = 0
- endif
- !else
- !Pump1BlownInTimeStep = 0
- !Pump1BlownStarted = .FALSE.
- endif
-
- if (PumpPressure2>= 6000.) then
- Pump2BlownCount = Pump2BlownCount + 1
- if(Pump2BlownCount >= BlownThreshold) then
- call ChangeValve(66, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- call Activate_Pump2Failure()
- Pump2OffFailure= .true.
- Pump2BlownCount = 0
- endif
- !else
- !Pump2BlownInTimeStep = 0
- !Pump2BlownStarted = .FALSE.
- endif
-
- if (PumpPressure3>= 6000.) then
- Pump3BlownCount = Pump3BlownCount + 1
- if(Pump3BlownCount >= BlownThreshold) then
- call ChangeValve(67, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- call Activate_Pump3Failure()
- Pump3OffFailure= .true.
- Pump3BlownCount = 0
- endif
- !else
- !Pump3BlownInTimeStep = 0
- !Pump3BlownStarted = .FALSE.
- endif
- ! Blown Conditions ********
- !===========================================================================================================================
- !===========================================================================================================================
- if (j9 > 0 ) then !.and. WellisNOTFull== .false.) then !WellToBellNipple
- !write(*,*) 'j9 is open'
-
-
- !MUD(7)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline
- MUD(7)%Q= ( MudVolume_InjectedFromAnn + Ann_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud
-
-
- if (j4 > 0) then
- BellNipple_FlowCoef= 13.625/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch)
- MUD(7)%Q= BellNipple_FlowCoef * MUD(7)%Q
- endif
-
- !total_annFlow= total_annFlow+(AnnulusFlowRateFinal/600.d0)
- !total_DeltaVPipe= total_DeltaVPipe + DeltaVolumePipe
- !write(*,*) 'total_annFlow,total_DeltaVPipe' , total_annFlow,total_DeltaVPipe
-
-
-
- if (MUD(7)%Q < 0.0 ) MUD(7)%Q= 0.0 !.or. WellisNOTFull== .true.) MUD(7)%Q= 0.0
- !!AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in
-
- !write(*,*) 'MUD(7)%Q=' , MUD(7)%Q
- !write(*,*) 'MudVolume_InjectedFromAnn-WellToBellNipple=' , MudVolume_InjectedFromAnn
- !write(*,*) 'Ann_Kick_Saved_Volume=' , Ann_Kick_Saved_Volume
-
- sys_total_injected= sys_total_injected+ MudVolume_InjectedFromAnn
-
-
- if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
- sys_total_injected= 0.
- endif
-
- !write(*,*) 'sys_total_injected=' , sys_total_injected
-
-
-
-
-
- !WellOutletDensity= Ann_Density%Last() ! (ppg) <<< in CirculationCodeSelect Code
-
-
- if ((BellNippleVolume+((MUD(7)%Q/60.)*DeltaT_Mudline)) /= 0.0) then
-
- BellNippleDensity= ((BellNippleDensity*BellNippleVolume)+(WellOutletDensity*(MUD(7)%Q/60.)*DeltaT_Mudline))/(BellNippleVolume+((MUD(7)%Q/60.)*DeltaT_Mudline))
- else
- BellNippleDensity= 0.0
- endif
-
-
- !IF (WellisNOTFull== .false.) THEN ! well must be full to do this order
- BellNippleVolume= BellNippleVolume+ ((MUD(7)%Q/60.)*DeltaT_Mudline)
- !ENDIF
-
-
- VolumeToBellNipple= VolumeToBellNipple + BellNippleVolume
- !write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple
-
- !write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q
- endif
-
- if (j9 == 0 ) then !.or. WellisNOTFull== .true.) then
- !write(*,*) 'WellisNOTFull=' , WellisNOTFull
- MUD(7)%Q=0.0 ! for normal circulation input
- endif
-
- if (j9 > 0) then
- WellToPitsOpen= .true.
- else
- WellToPitsOpen= .false.
- endif
-
-
- !===========================================================================================================================
- !===========================================================================================================================
-
-
- if (j10 > 0) then !MudBucketToBellNipple
- !write(*,*) 'j10 is open'
- !MudBucketVolume= 0.
- !MudBucketDensity= 0.
- ! MudBucketVolume gets value in DisconnectingPipe subroutine
- BellNippleVolume= BellNippleVolume+ MudBucketVolume
- BellNippleDensity= ActiveTankDensity
- MudBucketVolume= 0.
- endif
-
- !===========================================================================================================================
- !===========================================================================================================================
-
- if (j6 > 0) then !TripTankToActiveTank And BellNipple
- !write(*,*) 'j6 is open'
- !write(*,*) 'active by j6'
- MUD(6)%Q= 300. ! constant flow rate(gpm)
-
-
- TripTankVolumeCalc= TripTankVolumeCalc - ((MUD(6)%Q/60.)*DeltaT_Mudline)
-
-
- !write(*,*) 'ActiveTankVolume before=', ActiveTankVolume
-
-
- if (j6 == 1 .and. D71==1) then
- !write(*,*) 'add to active'
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(TripTankDensityCalc*(MUD(6)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((MUD(6)%Q/60.)*DeltaT_Mudline))
- ActiveTankVolume= ActiveTankVolume+ ((MUD(6)%Q/60.)*DeltaT_Mudline)
- !write(*,*) 'ActiveTankVolume after=', ActiveTankVolume
-
- endif
-
- if (j6 == 1 .and. D80==1) then
- BellNippleDensity= ((BellNippleDensity*BellNippleVolume)+(TripTankDensityCalc*(MUD(6)%Q/60.)*DeltaT_Mudline))/(BellNippleVolume+((MUD(6)%Q/60.)*DeltaT_Mudline))
- BellNippleVolume= BellNippleVolume+ ((MUD(6)%Q/60.)*DeltaT_Mudline)
- endif
-
- if (j6 == 2) then
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((0.5*MUD(6)%Q/60.)*DeltaT_Mudline))
- BellNippleDensity= ((BellNippleDensity*BellNippleVolume)+(TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*DeltaT_Mudline))/(BellNippleVolume+((0.5*MUD(6)%Q/60.)*DeltaT_Mudline))
-
- ActiveTankVolume= ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*DeltaT_Mudline)
- BellNippleVolume= BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*DeltaT_Mudline)
- endif
-
-
-
- ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
- !if ActiveTankVolume is higher, excess amount is dumped
-
- endif
-
- if (j6 == 0) then
- MUD(6)%Q=0.0
- endif
-
- !===========================================================================================================================
- !===========================================================================================================================
-
- CALL Set_FlowFromReturnLine(.false.)
-
-
- if (j3 > 0) then !BellNippleToPits-FullWell - must be after **WellToBellNipple(j9)**
- !write(*,*) 'j3 is open'
-
- !write(*,*) 'active by j3'
- !BellNipple flow rate= sum flow rate (well+ mudbucket+ triptank)
-
- !Well to BellNipple: BellNippleVolume
- !MudBucket to BellNipple: BellNippleVolume
- !TripTnak to BellNipple: BellNippleVolume
- MUD(3)%Q = (BellNippleVolume/DeltaT_Mudline)*60.d0 ! (gpm)
-
-
- !write(*,*) 'BellNippleVolume in j3 =' , BellNippleVolume
-
- !write(*,*) 'MUD(3)%Q =' , MUD(3)%Q
-
- call Set_FlowRate(real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8)) ! for unity display
- unityreturn = real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8)
-
- !write(*,*) 'unity return=' , real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8)
-
-
-
-
- if (MUD(3)%Q > PedalMeter .and. B78==0) then
- BellNippleDumpVolume= BellNippleDumpVolume + ((MUD(3)%Q/60.)*DeltaT_Mudline - (PedalMeter/60.)*DeltaT_Mudline)
-
- !BellNippleDumpRate= MUD(3)%Q - PedalMeter
-
- CALL Set_FlowFromReturnLine(.TRUE.) ! for unity display
-
- endif
-
- !VolumeToActive = VolumeToActive + BellNippleVolume
- !write(*,*) 'VolumeToActive*******=' , VolumeToActive
-
-
- active_before= ActiveTankVolume
-
-
- BellNippleVolume= BellNippleVolume- ((MUD(3)%Q/60.)*DeltaT_Mudline) ! to be 0.
-
- if ( BellNippleDensity > 1.0) then
- if (j3 == 1 .and. B71==1) then !(volumes in galon)
-
-
- MUD(3)%Q = min(MUD(3)%Q , PedalMeter)
- !write(*,*) 'MUD(3)%Q=' , MUD(3)%Q
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
-
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(BellNippleDensity*(MUD(3)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((MUD(3)%Q/60.)*DeltaT_Mudline))
- ActiveTankVolume= ActiveTankVolume+ ((MUD(3)%Q/60.)*DeltaT_Mudline)
-
- !write(*,*) 'active increase bell 1=' , ((MUD(3)%Q/60.)*DeltaT_Mudline)
-
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity > ActiveTankDensity) THEN
-
-
- ActiveTankVolume= ActiveTankVolume+ ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed cutting density = 20.8 ppg
- !write(*,*) 'active increase bell 2=' , ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline)
- ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity < 5.0) THEN
-
- ActiveTankVolume= ActiveTankVolume+ ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- !write(*,*) 'active increase bell 3=' , ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < BellNippleDensity .and. BellNippleDensity <= ActiveTankDensity) THEN
- !write(*,*) ' Auto true 3'
-
-
- ActiveTankVolume= ActiveTankVolume+ ((MUD(3)%Q/60.d0)*DeltaT_Mudline)
- !write(*,*) 'active increase bell 4=' , ((MUD(3)%Q/60.d0)*DeltaT_Mudline)
-
- ENDIF
- endif
-
- if (j3 == 1 .and. B77==1) then
-
- MUD(3)%Q = min(MUD(3)%Q , PedalMeter)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
-
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(BellNippleDensity*(MUD(3)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+((MUD(3)%Q/60.)*DeltaT_Mudline))
- TripTankVolumeCalc= TripTankVolumeCalc+ (MUD(3)%Q/60.)*DeltaT_Mudline
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity > ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity < 5.0) THEN
-
- AddedVolumeToTank= ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < BellNippleDensity .and. BellNippleDensity <= ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((MUD(3)%Q/60.d0)*DeltaT_Mudline)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ENDIF
-
- endif
-
-
- if (j3 == 1 .and. B78==1) then
-
- BellNippleDumpVolume= BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*DeltaT_Mudline
-
- !BellNippleDumpRate= MUD(3)%Q
-
- endif
-
-
-
- if (j3 == 2) then !78 is not allowded in this position
-
- MUD(3)%Q = min(MUD(3)%Q , PedalMeter)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
-
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(BellNippleDensity*(0.5*MUD(3)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+((0.5*MUD(3)%Q/60.)*DeltaT_Mudline))
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(BellNippleDensity*(0.5*MUD(3)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+((0.5*MUD(3)%Q/60.)*DeltaT_Mudline))
-
- ActiveTankVolume= ActiveTankVolume+ ((0.5*MUD(3)%Q/60.)*DeltaT_Mudline)
- TripTankVolumeCalc= TripTankVolumeCalc+ ((0.5*MUD(3)%Q/60.)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. BellNippleDensity > ActiveTankDensity) THEN
-
-
- AddedVolumeToTank= ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*DeltaT_Mudline)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < BellNippleDensity .and. BellNippleDensity <= ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((MUD(3)%Q/60.d0)*DeltaT_Mudline)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
-
- ENDIF
-
-
- endif
-
- endif !( BellNippleDensity > 1.0) then
-
- active_after= ActiveTankVolume
-
- active_increase = active_after - active_before
-
- total_active_increase= total_active_increase + active_increase
-
- if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
- total_active_increase= 0.
- endif
-
- !write(*,*) 'total_active_increase=' , total_active_increase
-
-
-
- !write(*,*) 'ReturnFlowRate=MUD(3)%Q= after' , MUD(3)%Q
-
- ReturnFlowRate = MUD(3)%Q
-
- TripTankVolumeCalc = min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal
- !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped
-
- ActiveTankVolume = min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal - MudProperties%ActiveSettledContentsGal)
- !if ActiveTankVolume is higher, excess amount is dumped
- !write(*,*) 'BellNippleDensity=' , BellNippleDensity
-
- !MudWeightOut2 = BellNippleDensity !for drillwatch display
- !write(*,*) 'MudWeightOut2=' , MudWeightOut2
-
- !write(*,*)
-
-
- endif
-
- if (j3 == 0) then
- MUD(3)%Q=0.0 ! for normal circulation input
- call Set_FlowRate(0d0)
- endif
-
-
-
- !===========================================================================================================================
- !===========================================================================================================================
-
-
-
- if (j11 > 0 .and. MudChecked== .true.) then !BellNippleToWell-NonFullWell ( FillingWell_By_BellNipple subroutine is called for this state )
- !write(*,*) 'j11 is open'
- MudChecked= .false. !to be sure that well is not full after arranging muds
- !WellToPitsOpen = .TRUE.
-
- !BellNipple flow rate= sum flow rate (well+ mudbucket+ triptank)
-
- !Well to BellNipple: BellNippleVolume
- !MudBucket to BellNipple: BellNippleVolume
- !TripTnak to BellNipple: BellNippleVolume
-
- MUD(8)%Q = (BellNippleVolume/DeltaT_Mudline)*60.
- !write(*,*) 'MUD(8)%Q=' , MUD(8)%Q
-
-
- BellNippleVolume= BellNippleVolume- ((MUD(8)%Q/60.)*DeltaT_Mudline) ! to be 0.
- !write(*,*) 'BellNippleVolume-2nd Mode=' , BellNippleVolume
-
- !BellNippleDensity
- !
- !
- !BellNippleDensity , MUD(8)%Q be code gel dade beshe
- !shart: j11 > 0 , MUD(8)%Q > 0.0
-
-
- endif
-
- if (j11 == 0) then
- MUD(8)%Q=0.0 ! for normal circulation input
- !WellToPitsOpen= .false.
- endif
-
-
-
- !===========================================================================================================================
- !===========================================================================================================================
-
-
-
- !WRITE (*,*) 'choke condition', j4, ChokeLineNOTFull
- if (j4 > 0 .and. ChokeLineNOTFull== .false.) then !WellToChokeManifold(Through 26)
- !write(*,*) 'j4 is open'
- !write(*,*) 'active by j4'
-
-
-
- !MUD(4)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline
- MUD(4)%Q= ( MudVolume_InjectedFromAnn + Ann_Kick_Saved_Volume )*60.d0/DeltaT_Mudline !Injected is referred only to Mud
-
-
- !if ( WellisNOTFull== .true. ) MUD(4)%Q= 0.0
-
-
- if (j9 > 0) then
- ChokeLine_FlowCoef= BopStackSpecification%ChokeLineId/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch)
- MUD(4)%Q= ChokeLine_FlowCoef * MUD(4)%Q
- endif
-
-
- !call Log_1('MUD(4)%Q=', MUD(4)%Q)
-
- ChokeOutletDensity= ChokeLine_Density%Last() ! <<< in CirculationCodeSelect Code
-
-
- !MudWeightOut2= ChokeOutletDensity !for drillwatch display
- !
- !AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in
-
-
-
-
-
- RealJ4= real(j4)
-
- !C71: Active Tank C77: Trip Tank C78: ChokeManifoldDump
-
- if ( BellNippleDensity > 1.0) then
- ! IN ALL CONDITIONS EFFECT OF 78 IS COMPUTED BY RealJ4
- if (C71==1 .and. C77==0) then !(volumes in galon) RealJ4: 1 OR 2(IF 78 IS OPEN)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
-
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))
- ActiveTankVolume= ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
- !write(*,*) 'active increase choke1=' , (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity > ActiveTankDensity) THEN
-
-
- ActiveTankVolume= ActiveTankVolume+ ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed cutting density = 20.8 ppg
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
- !write(*,*) 'active increase choke2=' , ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity < 5.0) THEN
-
- ActiveTankVolume= ActiveTankVolume+ ((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
- !write(*,*) 'active increase choke3=' ,((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ChokeOutletDensity .and. ChokeOutletDensity <= ActiveTankDensity) THEN
- !write(*,*) ' Auto true 3'
-
-
- ActiveTankVolume= ActiveTankVolume+ (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- !write(*,*) 'active increase choke4=' , (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- ENDIF
-
-
-
- endif
-
- if (C77==1 .and. C71==0) then !RealJ4: 1 OR 2(IF 78 IS OPEN)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))
- TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity > ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity < 5.0) THEN
-
- AddedVolumeToTank= ((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ChokeOutletDensity .and. ChokeOutletDensity <= ActiveTankDensity) THEN
-
- AddedVolumeToTank= (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- ENDIF
-
-
-
- endif
-
- if (C71==1 .and. C77==1) then !RealJ4: 2 OR 3(IF 78 IS OPEN)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline))
-
- ActiveTankVolume= ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
- TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. ChokeOutletDensity > ActiveTankDensity) THEN
-
-
- AddedVolumeToTank= ((20.8d0-ChokeOutletDensity)/(20.8d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((2.d0-ChokeOutletDensity)/(2.d0-ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < ChokeOutletDensity .and. ChokeOutletDensity <= ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((1.d0/RealJ4)*MUD(4)%Q/60.d0)
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*AddedVolumeToTank))/(TripTankVolumeCalc+AddedVolumeToTank)
-
- ActiveTankVolume= ActiveTankVolume+ AddedVolumeToTank
- TripTankVolumeCalc= TripTankVolumeCalc+ AddedVolumeToTank
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*DeltaT_Mudline)
-
-
- ENDIF
-
-
- endif
-
-
- if (C71==0 .and. C77==0 .and. C78==1) then !RealJ4: 1
- ! autodensity niaz nadarad
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
-
- endif
-
-
-
- endif ! if ( BellNippleDensity > 1.0) then
-
-
- TripTankVolumeCalc=min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal
- !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped
-
- ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
- !if ActiveTankVolume is higher, excess amount is dumped
-
- endif
-
-
-
-
-
- if (j4 == 0 .or. ChokeLineNOTFull== .true.) then
- !Pressure_BeforeChokes=0.0 ! for normal circulation input
- MUD(4)%Q=0.0 ! for CirculationCodeSelect input.
- endif
-
-
- if (j4 > 0) then
- WellToChokeManifoldOpen= .true.
- else
- WellToChokeManifoldOpen= .false.
- endif
-
- !===========================================================================================================================
- !===========================================================================================================================
-
- if (j18 > 0) then !StandPipeManifoldToChokeManifold-Through ChokeLine
- !write(*,*) 'j18 is open'
- !write(*,*) 'active by j18'
-
- ! STEP 1: REDUCTION FROM PUMPS STEP 1: REDUCTION FROM PUMPS STEP 1: REDUCTION FROM PUMPS (SAME TO PumpsToString LINE)
- ! (NOT NEEDED)
-
-
-
- ! STEP 2: ADD TO TANKS STEP 2: ADD TO TANKS STEP 2: ADD TO TANKS STEP 2: ADD TO TANKS (SAME TO WellToChokeManifold LINE)
-
- !Pump1toCh: PumpsToChokeManifold Coefficient
- !Jj2,Jj12,Jj13: TanksToMudPump Coefficient
- !H: Pumps To Tank_Through65 or 67 Coefficient
-
- MUD(9)%Q= jj2*(1-H82)*(1-DumpPump1)*Pump1toCh*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*Pump2toCh*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*Pump3toCh*PUMP(3)%Flow_Rate
-
-
-
- Denominator_a= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*PUMP(3)%Flow_Rate)
-
- if (Denominator_a /= 0.) then
- Density_Ch= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*Mp3Density*PUMP(3)%Flow_Rate)/ &
- Denominator_a
- !write(*,*) 'Density_Ch=' , Density_Ch
- !
- ! else
- !Density_Ch= 0.0
- endif
-
-
- RealJ18= M71+M77+M78
-
- !C71: Active Tank C77: Trip Tank C78: ChokeManifoldDump
-
-
- ! IN ALL CONDITIONS EFFECT OF 78 IS COMPUTED BY RealJ18
- if (M71==1 .and. M77==0) then !(volumes in galon) RealJ18: 1 OR 2(IF 78 IS OPEN)
-
- ! autodensity niaz nadarad
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))
- ActiveTankVolume= ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
-
- endif
-
- if (M77==1 .and. M71==0) then !RealJ18: 1 OR 2(IF 78 IS OPEN)
-
- ! autodensity niaz nadarad
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))
- TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
-
- endif
-
- if (M71==1 .and. M77==1) then !RealJ18: 2 OR 3(IF 78 IS OPEN)
-
- ! autodensity niaz nadarad
- ActiveTankDensity= ((ActiveTankDensity*ActiveTankVolume)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline))
-
- ActiveTankVolume= ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
- TripTankVolumeCalc= TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
-
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
-
- endif
-
-
- if (M71==0 .and. M77==0 .and. M78==1) then !RealJ18: 1
- ! autodensity niaz nadarad
- ChokeManifoldDumpVolume= ChokeManifoldDumpVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*DeltaT_Mudline)
-
- endif
-
-
-
-
-
-
-
-
- TripTankVolumeCalc=min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal
- !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped
-
- ActiveTankVolume=min(ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
- !if ActiveTankVolume is higher, excess amount is dumped
-
- endif
-
-
- if (j18 == 0) then
- MUD(9)%Q=0.0
- endif
-
-
- !===========================================================================================================================
- !===========================================================================================================================
-
- if (j5 > 0 .and. (ActiveTankVolume/ActiveTankFloorArea) > (TripTankVolumeCalc/TripTankFloorArea)) then !ActiveTankToTripTank
- ! second condition is for Utube flow
- !write(*,*) 'j5 is open'
-
- ! ActiveTankVolume/ActiveTankFloorArea... means tank height
- MUD(5)%Q= 300. ! constant flow rate(gpm)
-
-
- ActiveTankVolume= ActiveTankVolume - ((MUD(5)%Q/60.)*DeltaT_Mudline)
- TripTankVolumeCalc= TripTankVolumeCalc + ((MUD(5)%Q/60.)*DeltaT_Mudline)
-
- TripTankDensityCalc= ((TripTankDensityCalc*TripTankVolumeCalc)+(ActiveTankDensity*(MUD(5)%Q/60.)*DeltaT_Mudline))/(TripTankVolumeCalc+((MUD(5)%Q/60.)*DeltaT_Mudline))
-
-
-
- TripTankVolumeCalc=min(TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal
- !if TripTankVolumeCalc>50, excess value(TripTankVolumeCalc-50) is dumped
-
- endif
-
- if (j5 == 0) then
- MUD(5)%Q=0.0
- endif
-
- !===========================================================================================================================
- !===========================================================================================================================
-
- if (j16 > 0) then !PathsToGauge75
-
- if (K79 == 1) then
-
- PressureGauge75= PressureGauges(1) !String to Gauge75
-
- elseif (K82 == 1 .and. k83 == 0 .and. k84 == 0 .and. k78 == 0) then
- PressureGauge75= PumpPressure1
- elseif (K82 == 0 .and. k83 == 1 .and. k84 == 0 .and. k78 == 0) then
- PressureGauge75= PumpPressure2
- elseif (K82 == 0 .and. k83 == 0 .and. k84 == 1 .and. k78 == 0) then
- PressureGauge75= PumpPressure3
- elseif (K82 == 0 .and. k83 == 0 .and. k84 == 0 .and. k78 == 1) then
- PressureGauge75= 0.
- endif
-
- !if (K82 == 1) PressureGauge75= PumpPressure1 !Pump1 to Gauge75'
- !if (K83 == 1) PressureGauge75= PumpPressure2 !Pump2 to Gauge75
- !if (K84 == 1) PressureGauge75= PumpPressure3 !Pump3 to Gauge75
- !if (K78 == 1) PressureGauge75= 0. !Dump to Gauge75
-
- endif
-
-
- StandPipeManifold%StandPipeGauge1= (1 - StandPipeGauge1Malf) * PressureGauge75 ! for STManifold Display
- !write(*,*) 'PressureGauge75=' , PressureGauge75
- !P1toSt= jj2*(1-H82)*(1-DumpPump1)*G82
- !P2toSt= jj12*(1-H83)*(1-DumpPump2)*G83
- !CptoSt= jj13*(1-H84)*(1-DumpCementPump)*G84
- !===========================================================================================================================
- !===========================================================================================================================
-
- if (j17 > 0) then !PumpsToGauge76
-
- if (L79 == 1) then
-
- PressureGauge76= PressureGauges(1) !String to Gauge76
-
- elseif (L82 == 1 .and. L83 == 0 .and. L84 == 0 .and. L78 == 0) then
- PressureGauge76= PumpPressure1
- elseif (L82 == 0 .and. L83 == 1 .and. L84 == 0 .and. L78 == 0) then
- PressureGauge76= PumpPressure2
- elseif (L82 == 0 .and. L83 == 0 .and. L84 == 1 .and. L78 == 0) then
- PressureGauge76= PumpPressure3
- elseif (L82 == 0 .and. L83 == 0 .and. L84 == 0 .and. L78 == 1) then
- PressureGauge76= 0.
- endif
-
-
- !if (L79 == 1) PressureGauge76= PressureGauges(1) !String to Gauge76
- !if (L82 == 1) PressureGauge76= PumpPressure1 !Pump1 to Gauge76
- !if (L83 == 1) PressureGauge76= PumpPressure2 !Pump2 to Gauge76
- !if (L84 == 1) PressureGauge76= PumpPressure3 !Pump3 to Gauge76
- !if (L78 == 1) PressureGauge76= 0. !Dump to Gauge76
-
- endif
- StandPipeManifold%StandPipeGauge2= (1 - StandPipeGauge2Malf) * PressureGauge76 ! for STManifold Display
- !===========================================================================================================================
- !===========================================================================================================================
- !
- !if (PressureGauge75 == PressureGauges(1)) then ! means: 75 goes to string
- ! PumpPressureDW= PressureGauges(1) !for DrillWatch Display
- ! CALL Set_StandPipePressure(real(PressureGauges(1) , 8)) !for Data Display Console
- !endif
- !
- !
- !if (PressureGauge76 == PressureGauges(1)) then ! means: 76 goes to string
- ! PumpPressureDW= PressureGauges(1) !for DrillWatch Display
- ! CALL Set_StandPipePressure(real(PressureGauges(1) , 8)) !for Data Display Console
- !endif
- !
- !if (PressureGauge75 /= PressureGauges(1) .and. PressureGauge76 /= PressureGauges(1)) then ! means: non of gauges go to string
- ! PumpPressureDW= max(PressureGauge75,PressureGauge76) !for DrillWatch Display
- ! !StandPipePressureGauge= max(PressureGauge75,PressureGauge76) !for Data Display Console
- ! CALL Set_StandPipePressure(real(max(PressureGauge75,PressureGauge76) , 8)) !for Data Display Console
- !endif
- !write(*,*) 'TapSelector=' , TapSelector
-
-
- if (TapSelector == .false.) then
-
- DrillingWatch%PumpPressure= PressureGauge75 !for DrillWatch Display
- CALL Set_StandPipePressure(real((1-DrillPipePressureMalf)*PressureGauge75 , 8)) !for Data Display Console
- else
- DrillingWatch%PumpPressure= PressureGauge76 !for DrillWatch Display
- CALL Set_StandPipePressure(real((1-DrillPipePressureMalf)*PressureGauge76 , 8)) !for Data Display Console
- endif
-
- !===========================================================================================================================
- !===========================================================================================================================
- ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem
-
- if (j2 > 0) then !TanksToMudPump1
-
-
- !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate
-
-
- RealJ2= real(j2)
-
- if (A71==1 .and. (ActiveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- A71= 0
- RealJ2= RealJ2-1
- write(*,*) 'ActiveTank Level Warning'
- call Activate_ActiveTankUnderVolume()
- endif
-
- if (A72==1 .and. (ReserveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- A72= 0
- RealJ2= RealJ2-1
- write(*,*) 'ReserveTank Level Warning'
- endif
-
- if (A71==3 .and. (CementTankVolumeCalc-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- A73= 0
- RealJ2= RealJ2-1
- write(*,*) 'CementTank Level Warning'
- endif
-
-
- if(RealJ2> 0.0) then
-
- ActiveTankVolume= ActiveTankVolume- A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)
- ReserveTankVolume= ReserveTankVolume- A72*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)
- CementTankVolumeCalc= CementTankVolumeCalc- A73*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)
- !write(*,*) 'Active-decline=' , A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)
- total_decrease= total_decrease+ A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*DeltaT_Mudline)
-
- if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
- total_decrease= 0.
- endif
- !write(*,*) 'total_decrease=' , total_decrease
-
-
- Mp1Density= (A71*ActiveTankDensity+A72*ReserveTankDensity+A73*CementTankDensityCalc)/RealJ2
- else
- write(*,*) 'stop'
- endif
-
-
-
- endif
-
-
- !===========================================================================================================================
- !===========================================================================================================================
- ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem
-
- if (j12 > 0) then !TanksToMudPump2
-
-
- !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate
-
- RealJ12= real(J12)
-
- if (E71==1 .and. (ActiveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- E71= 0
- RealJ12= RealJ12-1
- write(*,*) 'ActiveTank Level Warning'
- endif
-
- if (E72==1 .and. (ReserveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- E72= 0
- RealJ12= RealJ12-1
- write(*,*) 'ReserveTank Level Warning'
- endif
-
- if (E71==3 .and. (CementTankVolumeCalc-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- E73= 0
- RealJ12= RealJ12-1
- write(*,*) 'CementTank Level Warning'
- endif
-
-
- if(RealJ12> 0.0) then
-
- ActiveTankVolume= ActiveTankVolume- E71*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)
- ReserveTankVolume= ReserveTankVolume- E72*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)
- CementTankVolumeCalc= CementTankVolumeCalc- E73*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*DeltaT_Mudline)
-
-
-
- Mp2Density= (E71*ActiveTankDensity+E72*ReserveTankDensity+E73*CementTankDensityCalc)/RealJ12
- else
- write(*,*) 'stop'
- endif
-
-
- endif
-
-
- !===========================================================================================================================
- !===========================================================================================================================
- ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem
-
- if (j13 > 0) then !TanksToCementPump
-
-
- !Relief= 0: deactive 1: active PUMP(1)%Flow_Rate , PUMP(2)%Flow_Rate
-
-
- RealJ13= real(J13)
-
- if (F71==1 .and. (ActiveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- F71= 0
- RealJ13= RealJ13-1
- write(*,*) 'ActiveTank Level Warning'
- endif
-
- if (F72==1 .and. (ReserveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- F72= 0
- RealJ13= RealJ13-1
- write(*,*) 'ReserveTank Level Warning'
- endif
-
- if (F71==3 .and. (CementTankVolumeCalc-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)) < 0.0) then
- F73= 0
- RealJ13= RealJ13-1
- write(*,*) 'CementTank Level Warning'
- endif
-
-
- if(RealJ13> 0.0) then
-
- ActiveTankVolume= ActiveTankVolume- F71*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)
- ReserveTankVolume= ReserveTankVolume- F72*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)
- CementTankVolumeCalc= CementTankVolumeCalc- F73*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*DeltaT_Mudline)
-
-
- Mp3Density= (F71*ActiveTankDensity+F72*ReserveTankDensity+F73*CementTankDensityCalc)/RealJ13
- else
- write(*,*) 'stop'
- endif
-
-
- endif
-
-
-
- !===========================================================================================================================
- !===========================================================================================================================
- ! SHOULD BE AT LAST TO HAVE THE CORRECT DENSITIES FOR Suction_Density_MudSystem
-
- if (j14 > 0) then !PumpsToString Suction_Density_MudSystem is used for Mud Circulation Code
- !write(*,*) 'j14 is open'
- !call Log_1('j14 is open')
-
- ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >>
-
- ! pump flow rate1 be sharti be samte string miravad ke masire j2 bar gharar bashad
- ! pump flow rate2 be sharti be samte string miravad ke masire j12 bar gharar bashad
- ! pump flow rate3 be sharti be samte string miravad ke masire j13 bar gharar bashad
-
- !G: PumpsToString Coefficient
- !Jj2,Jj12,Jj13: TanksToMudPump Coefficient
- !H: Pumps To Tank_Through65 or 67 Coefficient
- !
- !write(*,*) 'jj2=' , jj2
- !write(*,*) 'jj12=' , jj12
- !write(*,*) 'jj13=' , jj13
- !write(*,*) 'H82=' , H82
- !write(*,*) 'H83=' , H83
- !write(*,*) 'H84=' , H84
- !write(*,*) 'DumpPump1=' , DumpPump1
- !write(*,*) 'DumpPump2=' , DumpPump2
- !write(*,*) 'DumpCementPump=' , DumpCementPump
- !write(*,*) 'G82=' , G82
- !write(*,*) 'G83=' , G83
- !write(*,*) 'G84=' , G84
- !write(*,*) 'Mp1Density=' , Mp1Density
- !write(*,*) 'Mp2Density=' , Mp2Density
- !write(*,*) 'Mp3Density=' , Mp3Density
- !
- !
-
-
-
- !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate
-
- Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*PUMP(3)%Flow_Rate)
-
- if (Denominator /= 0.) then
- Suction_Density_MudSystem= (jj2*(1.-H82)*(1.-DumpPump1)*G82*Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*Mp3Density*PUMP(3)%Flow_Rate)/ &
- Denominator
- endif
-
- CompressedMudDensity= Suction_Density_MudSystem
-
- DrillingWatch%MudWeightIn= Suction_Density_MudSystem !for drillwatch display
-
-
- MUD(2)%Q= jj2*(1-H82)*(1-DumpPump1)*G82*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*G83*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*G84*PUMP(3)%Flow_Rate
-
- !write(*,*) 'MUD(2)%Q=' , MUD(2)%Q
-
-
-
- !jj2*(1-H82)*(1-DumpPump1)*G82 :if ==1, Pump1 to String is open
- !jj12*(1-H83)*(1-DumpPump2)*G83 :if ==1, Pump2 to String is open
- !jj13*(1-H84)*(1-DumpCementPump)*G84 :if ==1, Cement to String is open
-
-
-
- endif
-
- if (j14 == 0) then ! for normal circulation input
- MUD(2)%Q=0.0
- !PumpPressure1= 0.0
- !PumpPressure2= 0.0
- !PumpPressure3= 0.0
- endif
-
-
-
- !===========================================================================================================================
- !===========================================================================================================================
-
- if (j19 > 0 .and. MudChecked== .true.) then !PumpsToWell_KillLine Suction_Density_PumpsToWell is used for Mud Circulation Code
- !write(*,*) 'j19 is open'
- MudChecked= .false. !to be sure that well is not full after arranging muds
-
- ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >>
-
- ! pump flow rate1 be sharti be samte well miravad ke masire j2 bar gharar bashad
- ! pump flow rate2 be sharti be samte well miravad ke masire j12 bar gharar bashad
- ! pump flow rate3 be sharti be samte well miravad ke masire j13 bar gharar bashad
-
- !G: PumpsToString Coefficient
- !Jj2,Jj12,Jj13: TanksToMudPump Coefficient
- !H: Pumps To Tank_Through65 or 67 Coefficient
- !
- !write(*,*) 'jj2=' , jj2
- !write(*,*) 'jj12=' , jj12
- !write(*,*) 'jj13=' , jj13
- !write(*,*) 'H82=' , H82
- !write(*,*) 'H83=' , H83
- !write(*,*) 'H84=' , H84
- !write(*,*) 'DumpPump1=' , DumpPump1
- !write(*,*) 'DumpPump2=' , DumpPump2
- !write(*,*) 'DumpCementPump=' , DumpCementPump
- !write(*,*) 'G82=' , G82
- !write(*,*) 'G83=' , G83
- !write(*,*) 'G84=' , G84
- !write(*,*) 'Mp1Density=' , Mp1Density
- !write(*,*) 'Mp2Density=' , Mp2Density
- !write(*,*) 'Mp3Density=' , Mp3Density
- !
- !
-
-
-
- !PumpsDumpVolume= PumpsDumpVolume+ jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate
-
- Denominator= (jj2*(1.-H82)*(1.-DumpPump1)*N82*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*PUMP(3)%Flow_Rate)
-
- if (Denominator /= 0.) then
- Suction_Density_PumpsToWell= (jj2*(1.-H82)*(1.-DumpPump1)*N82*Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*Mp3Density*PUMP(3)%Flow_Rate)/ &
- Denominator
- endif
-
-
-
-
-
- MUD(10)%Q= jj2*(1-H82)*(1-DumpPump1)*N82*PUMP(1)%Flow_Rate + jj12*(1-H83)*(1-DumpPump2)*N83*PUMP(2)%Flow_Rate + jj13*(1-H84)*(1-DumpCementPump)*N84*PUMP(3)%Flow_Rate
-
-
-
-
-
-
- endif
-
- if (j19 == 0) then ! for normal circulation input
- MUD(10)%Q=0.0
- !PumpPressure1= 0.0
- !PumpPressure2= 0.0
- !PumpPressure3= 0.0
- endif
- !===========================================================================================================================
- !===========================================================================================================================
-
-
-
- !AnnulusFlowRateFinal = 0.d0 ! this is a reset for calculated flow rate in UTUBES,TRIPIN,TRIPOUT codes
-
-
-
-
-
-
-
-
-
-
-
-
-
- !!======================================================================
- !! Well Head Condition Determination
- !!======================================================================
-
-
- if ( WellToChokeManifoldOpen .or. WellToPitsOpen) then
- WellHeadIsOpen= .true.
- else
- WellHeadIsOpen= .false.
- endif
-
-
-
-
-
-
-
- !!======================================================================
- !! WARNINGS
- !!======================================================================
-
-
- IF (Manifold%Valve(65)%Status == .TRUE.) call Activate_Pump1PopOffValveBlown() !Pump1PopOffValveBlown= .TRUE.
- IF (Manifold%Valve(66)%Status == .TRUE.) call Activate_Pump2PopOffValveBlown() ! Pump2PopOffValveBlown= .TRUE.
- IF (Manifold%Valve(67)%Status == .TRUE.) call Activate_Pump3PopOffValveBlown() !Pump2PopOffValveBlown= .TRUE.
-
-
- IF (ActiveTankVolume >= (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)) THEN
- ActiveTankVolume = (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
- call Activate_ActiveTankOverflow()
- ELSE
- call Deactivate_ActiveTankOverflow()
- ENDIF
-
-
-
- !!======================================================================
- !! UPDATING TANKS DENSITIES & Volumes FOR MUD CIRCULATION
- !!======================================================================
-
- !write(*,*) 'ReserveTankVolume=' , real(ReserveTankVolume)
-
- call Set_ActiveMudVolume_StudentStation(real(ActiveTankVolume/42.,8)) ! 42: gal to bbl
- call Set_ActiveDensity_StudentStation(real(ActiveTankDensity,8))
- call Set_ReserveMudVolume_StudentStation(real(ReserveTankVolume/42.,8)) ! 42: gal to bbl
- call Set_ReserveDensity_StudentStation(real(ReserveTankDensity,8))
- DrillingWatch%KillMudVolume= ReserveTankVolume/42. ! for DrillWatch
- !PitGainLose=
-
-
- !!======================================================================
- !! DRILLING DATA DISPLAY
- !!======================================================================
-
-
- IF (DataDisplayConsole%TotalStrokeCounterResetSwitch == 1) then !for drilling data display
- TotalStrokesPump1=0.
- TotalStrokesPump2=0.
- ENDIF
-
- TotalStrokesPump1=TotalStrokesPump1+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline !for drilling data display
- TotalStrokesPump2=TotalStrokesPump2+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline !for drilling data display
- GraphTotalStrokes=GraphTotalStrokes+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline
-
-
- total_pumps%Total_Stroke_Counter_For_Plot = total_pumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * DeltaT_Mudline
-
- CALL SetTotalStrokes(INT(total_pumps%Total_Stroke_Counter_For_Plot))
-
- DataDisplayConsole%TotalStrokeCounter= real(nint(TotalStrokesPump1+TotalStrokesPump2)) !for drilling data display
-
- !===========================================================================
- ! MUD PUMP STROKES
- ! & TOTAL STROKE- CHOKE CONTROL PANEL
- !===========================================================================
- !write(*,*) 'a)))' , ChokePanelStrokeResetSwitch
- if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
- IF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN
- !write(*,*) '1 reset'
- Choke%TotalStrokes1 =0.
- elseif (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN
- !write(*,*) '2 reset'
- Choke%TotalStrokes2 =0.
- else
- !write(*,*) 'both reset'
-
- Choke%TotalStrokes1 =0.
- Choke%TotalStrokes2 =0.
- endif
- endif
-
- !write(*,*) 'b)))' , ChokePanelStrokeResetSwitch
-
-
- Choke%TotalStrokes1= Choke%TotalStrokes1+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline
- Choke%TotalStrokes2= Choke%TotalStrokes2+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline
-
-
-
- IF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 1) THEN
- ChokeControlPanel%ChokePanelSPMCounter = real(nint(DataDisplayConsole%MP1SPMGauge))
- ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes1))
- ELSEIF (ChokeControlPanel%ChokePanelPumpSelectorSwitch == 2) THEN
- ChokeControlPanel%ChokePanelSPMCounter = real(nint(DataDisplayConsole%MP2SPMGauge))
- ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes2))
- ELSE
- ChokeControlPanel%ChokePanelSPMCounter= real(nint(DataDisplayConsole%MP1SPMGauge+DataDisplayConsole%MP2SPMGauge))
- ChokeControlPanel%ChokePanelTotalStrokeCounter = real(nint(Choke%TotalStrokes1+Choke%TotalStrokes2))
- ENDIF
-
- ! ChokePanelStrokeResetSwitch = 0
- !======================================================================
-
- !!======================================================================
- !! MUD VOLUME TOTALIZER DISPLAY VALUES
- !!======================================================================
-
-
- DrillingWatch%PitVolume= ActiveTankVolume/42.d0 !(bbl) For DrillWatch Display
-
- !write(*,*) 'PitVolume,ActiveTankVolume=' ,PitVolume,ActiveTankVolume
-
-
- MudTank1_vol= ActiveTankVolume/3. ! (gal)
- MudTank2_vol= ActiveTankVolume/3. ! (gal)
- MudTank3_vol= ActiveTankVolume/3. ! (gal)
- MudTank4_vol= TripTankVolumeCalc
-
-
-
-
-
- IF (DataDisplayConsole%MVTPowerSwitch==1) THEN
- DataDisplayConsole%MudTanksVolumeGauge= (1 - MudTanksVolumeGaugeMalf) *((MudTank1_vol*DataDisplayConsole%MudTank1Switch)+(MudTank2_vol*DataDisplayConsole%MudTank2Switch)+ &
- (MudTank3_vol*DataDisplayConsole%MudTank3Switch)+(MudTank4_vol*DataDisplayConsole%MudTank4Switch)+ActiveTankSettled) !(gal)
- ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN
- DataDisplayConsole%MudTanksVolumeGauge= (1 - MudTanksVolumeGaugeMalf) *0.
- ENDIF
-
- !!======================================================================
- !! MUD VOLUME TOTALIZER
- !!======================================================================
-
-
-
-
- ! IF (DataDisplayConsole%MVTPowerSwitch==1 .and. IsPortable==.false.) THEN
-
-
-
- ! IF (DataDisplayConsole%MVTSetAlarmSwitch==0) THEN
-
- ! DataDisplayConsole%PitGainLossGauge= ( ((ActiveTankVolume/42.) - RefrencePitVolume)) - PitGainLossGaugeMalf*(( ((ActiveTankVolume/42.) - RefrencePitVolume))+50) !(bbl)
-
- ! ELSEIF (DataDisplayConsole%MVTSetAlarmSwitch==-1) THEN
-
-
- ! MVT_MinVol_Allowded= PitGainLossZero+ MIN(0.,(DataDisplayConsole%MVTSetAlarmLowKnob-50))-0.1
- ! DataDisplayConsole%PitGainLossGauge= MVT_MinVol_Allowded - PitGainLossGaugeMalf*(MVT_MinVol_Allowded+50)
- ! ! - PitGainLossGaugeMalf*(MVT_MinVol_Allowded+50) : Malf effect
- ! !PitGainLose=(MVT_MinVol_Allowded) ! DrillWatch (incorrect)
- ! !RefrencePitVolume= ActiveTankVolume/42. !(bbl)
-
- ! ELSE !(MVTSetAlarmSwitch==1)
-
- ! MVT_MaxVol_Allowded= PitGainLossZero+ MAX(0., (DataDisplayConsole%MVTSetAlarmHighKnob-50.))+0.1
- ! DataDisplayConsole%PitGainLossGauge= MVT_MaxVol_Allowded - PitGainLossGaugeMalf*(MVT_MaxVol_Allowded+50)
- ! ! - PitGainLossGaugeMalf*(MVT_MaxVol_Allowded+50) : Malf effect
- ! !PitGainLose=(MVT_MaxVol_Allowded) ! DrillWatch (incorrect)
- ! !RefrencePitVolume= ActiveTankVolume/42. !(bbl)
- ! ENDIF
-
- ! !PitGainLossZero_Old= PitGainLossZero
- ! !MVTCoarseKnob_Old= MVTCoarseKnob
- ! !MVTFineKnob_Old= MVTFineKnob
- ! !FirstSet_Time= .false.
-
-
-
- ! IF ( ActiveTankVolume/42. < (RefrencePitVolume-ABS(MVT_MinVol_Allowded)) .OR. ActiveTankVolume/42. > (RefrencePitVolume+ABS(MVT_MaxVol_Allowded)) ) THEN
-
- ! DataDisplayConsole%MVTAlarmLED = 1 !(blinking)
- ! IF (DataDisplayConsole%MVTHornSwitch) THEN
- ! DataDisplayConsole%Buzzer2= .TRUE.
- ! ELSE
- ! DataDisplayConsole%Buzzer2= .FALSE.
- ! ENDIF
-
- ! ELSE
- ! DataDisplayConsole%MVTAlarmLED = 0 !(OFF)
- ! DataDisplayConsole%Buzzer2= .false.
- ! ENDIF
-
-
-
- ! ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN
- ! !MudTanksVolumeGauge= 0.
- ! DataDisplayConsole%PitGainLossGauge= -50
- ! DataDisplayConsole%MVTAlarmLED= 0
- ! DataDisplayConsole%Buzzer2= .false.
-
-
- ! ENDIF
-
- !!======================================================================
- !! RETURN CALCULATIONS
- !!======================================================================
-
-
-
-
- DrillingWatch%PercentFlow= (ReturnFlowRate/PedalMeter) *100. !(percent) ! for DrillWatch display
- if (abs(DrillingWatch%PercentFlow - unityreturn) > 1.0) then
-
- write(*,*) 'PercentFlow,ReturnFlowRate,PedalMeter=' , DrillingWatch%PercentFlow,ReturnFlowRate,PedalMeter
- write(*,*) 'unityreturn=' , unityreturn
- endif
-
-
- ! ReturnFlowRate=800. set in startup as initial value
- ReturnFlowPercent= (ReturnFlowRate/PedalMeter) *100. !(percent)
- !write(*,*) 'ReturnFlowPercent,ReturnFlowRate=' , ReturnFlowPercent,ReturnFlowRate
- ! if ReturnFlowRate>PedalMeter, excess value(ReturnFlowRate-PedalMeter) is dumped in the code before
-
-
- !!======================================================================
- !! DRILL WATCH
- !!======================================================================
-
- DrillingWatch%PitGainLose= ((ActiveTankVolume/42.) - RefrencePitVolume_DrillWatch) ! DrillWatch
- !write(*,*) 'PitGainLose galon' , PitGainLose*42.
-
-
- ! if (IsPortable) then
-
- ! MVT_MinVol_Allowded= DataDisplayConsole%PitAlarmLow
- ! MVT_MaxVol_Allowded= DataDisplayConsole%PitAlarmHigh
-
- ! IF ( ActiveTankVolume/42. < (RefrencePitVolume-ABS(MVT_MinVol_Allowded)) .OR. ActiveTankVolume/42. > (RefrencePitVolume+ABS(MVT_MaxVol_Allowded)) ) THEN
-
- ! DataDisplayConsole%MVTAlarmLED = 1 !(blinking)
- ! IF (DataDisplayConsole%MVTHornSwitch) THEN
- ! DataDisplayConsole%Buzzer2= .TRUE.
- ! ELSE
- ! DataDisplayConsole%Buzzer2= .FALSE.
- ! ENDIF
-
- ! ELSE
- ! DataDisplayConsole%MVTAlarmLED = 0 !(OFF)
- ! DataDisplayConsole%Buzzer2= .false.
- ! ENDIF
-
- ! endif
-
-
- if (PitGainLossReset) then
-
- DrillingWatch%PitGainLose= 0.d0 !DrillWatch
- RefrencePitVolume_DrillWatch= ActiveTankVolume/42. !(bbl) !DrillWatch
- !*********************************************
-
- DataDisplayConsole%PitGainLossGauge= 0. !MFF Indicator
- RefrencePitVolume= ActiveTankVolume/42. !(bbl) !MFF Indicator
-
- endif
-
-
-
-
-
-
-
- !!======================================================================
- !! MUD FLOW-FILL INDICATOR
- !!======================================================================
-
- IF (DataDisplayConsole%MFFIPowerSwitch==1 ) THEN !.and. IsPortable==.false.
-
-
- !====================TotalStrokes Reset and Calculate======================
- if (DataDisplayConsole%MFFIResetTotalStrokes == 1) then
- IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN
- TotalStrokes1MFFI =0.
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN
- TotalStrokes2MFFI =0.
- else
- TotalStrokes1MFFI =0.
- TotalStrokes2MFFI =0.
- endif
- endif
- TotalStrokes1MFFI= TotalStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline
- TotalStrokes2MFFI= TotalStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline
-
- !==================FillStrokes Reset and Calculate=========================
- if (DataDisplayConsole%MFFIResetFillCounter == 1) then
- IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN
- TotalFillStrokes1MFFI =0.
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN
- TotalFillStrokes2MFFI =0.
- else
- TotalFillStrokes1MFFI =0.
- TotalFillStrokes2MFFI =0.
- endif
- endif
-
-
- TotalFillStrokes1MFFI= TotalFillStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*DeltaT_Mudline
- TotalFillStrokes2MFFI= TotalFillStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*DeltaT_Mudline
- !===================================================================
-
-
- if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then
- DataDisplayConsole%MFFITotalStrokeCounter = real(nint(TotalStrokes1MFFI)) !TotalStroke LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then
- DataDisplayConsole%MFFITotalStrokeCounter = real(nint(TotalStrokes2MFFI)) !TotalStroke LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then
- DataDisplayConsole%MFFITotalStrokeCounter = real(nint(TotalStrokes1MFFI+TotalStrokes2MFFI)) !TotalStroke LED
- endif
-
-
- IF (DataDisplayConsole%MFFIFillSPMSelectorSwitch== .false.) THEN !(spm mode)
- if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then
- DataDisplayConsole%FillStrokeCounter = real(nint(DataDisplayConsole%MP1SPMGauge)) !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then
- DataDisplayConsole%FillStrokeCounter = real(nint(DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then
- DataDisplayConsole%FillStrokeCounter= real(nint(DataDisplayConsole%MP1SPMGauge+DataDisplayConsole%MP2SPMGauge)) !Fill or SPM LED
- endif
-
- ELSE ! (MFFIFillSPMSelectorSwitch== .true.) then !(fill mode)
- if (ReturnFlowRate== 0) then
- if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then
- DataDisplayConsole%FillStrokeCounter = real(nint(TotalFillStrokes1MFFI)) !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then
- DataDisplayConsole%FillStrokeCounter = real(nint(TotalFillStrokes2MFFI)) !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then
- DataDisplayConsole%FillStrokeCounter= real(nint(TotalFillStrokes1MFFI+TotalFillStrokes2MFFI)) !Fill or SPM LED
- endif
-
-
- TotalFilledStrokesBy1MFFI = real(nint(TotalFillStrokes1MFFI))! for values=fix on LED after the well filled
- TotalFilledStrokesBy2MFFI = real(nint(TotalFillStrokes2MFFI))! for values=fix on LED after the well filled
- TotalFilledStrokesBy1and2MFFI= real(nint(TotalFillStrokes1MFFI+TotalFillStrokes2MFFI))! for values=fix on LED after the well filled
-
-
-
- else !(ReturnFlowRate>0)
-
- ! these values=fix on LED after the well filled
- if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then
- DataDisplayConsole%FillStrokeCounter = TotalFilledStrokesBy1MFFI !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then
- DataDisplayConsole%FillStrokeCounter = TotalFilledStrokesBy2MFFI !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then
- DataDisplayConsole%FillStrokeCounter= TotalFilledStrokesBy1and2MFFI !Fill or SPM LED
- endif
- endif
-
-
- ENDIF
-
-
-
- !===================================================================================
-
-
-
-
- if (ReturnFlowRate>0) then
- DataDisplayConsole%MFFIPumpLED=1 !(Returns Lamp)
- else
- DataDisplayConsole%MFFIPumpLED=0 !(Returns Lamp)
- endif
-
-
-
- IF (DataDisplayConsole%MFFISetAlarmSwitch==0) THEN
-
- DataDisplayConsole%ReturnMudFlowGauge= (1 - ReturnMudFlowGaugeMalf)*ReturnFlowPercent !(percent)
-
- ELSEIF (DataDisplayConsole%MFFISetAlarmSwitch==-1) THEN
- MFFI_MinPercent_Allowded=DataDisplayConsole%MFFISetAlarmLowKnob
- DataDisplayConsole%ReturnMudFlowGauge= (1 - ReturnMudFlowGaugeMalf)*MFFI_MinPercent_Allowded
-
- ELSE !(MFFISetAlarmSwitch==1)
-
- MFFI_MaxPercent_Allowded=DataDisplayConsole%MFFISetAlarmHighKnob
- DataDisplayConsole%ReturnMudFlowGauge= (1 - ReturnMudFlowGaugeMalf)*MFFI_MaxPercent_Allowded
- ENDIF
-
-
- IF (ReturnFlowPercent<MFFI_MinPercent_Allowded .OR. ReturnFlowPercent>MFFI_MaxPercent_Allowded) THEN
- !write(*,*) 'alarm return:' , ReturnFlowRate
- DataDisplayConsole%MFFIAlarmLED = 2 !(blinking)
- IF (DataDisplayConsole%MFFIHornSwitch) THEN
- DataDisplayConsole%Buzzer3= .true.
- ELSE
- DataDisplayConsole%Buzzer3= .FALSE.
- ENDIF
- ELSE
- DataDisplayConsole%MFFIAlarmLED = 0 !(OFF)
- DataDisplayConsole%Buzzer3= .false.
- ENDIF
- !===================================================================================
-
-
- ELSEIF (DataDisplayConsole%MFFIPowerSwitch==0) THEN
- DataDisplayConsole%ReturnMudFlowGauge= 0.
- DataDisplayConsole%FillStrokeCounter= 0
- DataDisplayConsole%MFFITotalStrokeCounter= 0
- DataDisplayConsole%MFFIAlarmLED= 0
- DataDisplayConsole%Buzzer3= .false.
- ENDIF
-
-
- ! if ( IsPortable ) then
-
- ! MFFI_MinPercent_Allowded=DataDisplayConsole%RetFlowAlarmLow
- ! MFFI_MaxPercent_Allowded=DataDisplayConsole%RetFlowAlarmHigh
-
-
- ! IF (ReturnFlowPercent<MFFI_MinPercent_Allowded .OR. ReturnFlowPercent>MFFI_MaxPercent_Allowded) THEN
-
- ! DataDisplayConsole%MFFIAlarmLED = 1 !(blinking)
- ! IF (DataDisplayConsole%MFFIHornSwitch) THEN
- ! DataDisplayConsole%Buzzer3= .true.
- ! ELSE
- ! DataDisplayConsole%Buzzer3= .FALSE.
- ! ENDIF
- ! ELSE
- ! DataDisplayConsole%MFFIAlarmLED = 0 !(OFF)
- ! DataDisplayConsole%Buzzer3= .false.
- ! ENDIF
-
- ! endif
-
-
- !!======================================================================
- !! TRIP TANK PANEL DISPLAY VALUES
- !!======================================================================
-
- Tank%TripTankVolume = TripTankVolumeCalc/42. !(Drill Watch display)
- Tank%TripTankDensity= TripTankDensityCalc !(display)
-
-
- IF (DataDisplayConsole%TripTankPowerSwitch==1 ) THEN !.and. IsPortable==.false.
-
- IF (DataDisplayConsole%TripTankSetAlarmSwitch==0) THEN
-
- DataDisplayConsole%TripTankGauge= (1 - TripTankPressure_DataDisplayMalf) * TripTankVolumeCalc ! (gal)
- ELSEIF (DataDisplayConsole%TripTankSetAlarmSwitch==-1) THEN
-
- TripTank_MinVol_Allowded= DataDisplayConsole%TripTankSetAlarmLow/2. ! 2: because knob input is 0-100 but gauge is 0-50
- DataDisplayConsole%TripTankGauge= (1 - TripTankPressure_DataDisplayMalf) * TripTank_MinVol_Allowded
-
- ELSE !(TripTankSetAlarmSwitch==1)
- TripTank_MaxVol_Allowded= DataDisplayConsole%TripTankSetAlarmHigh/2. ! 2: because knob input is 0-100 but gauge is 0-50
- DataDisplayConsole%TripTankGauge= (1 - TripTankPressure_DataDisplayMalf) * TripTank_MaxVol_Allowded
- ENDIF
-
-
-
- IF ((TripTankVolumeCalc < TripTank_MinVol_Allowded) .OR. (TripTankVolumeCalc > TripTank_MaxVol_Allowded)) THEN
- DataDisplayConsole%TripTankAlarmLED = 2 !(blinking)
- IF (DataDisplayConsole%TripTankHornSwitch) THEN
- DataDisplayConsole%Buzzer1= .true.
- ELSE
- DataDisplayConsole%Buzzer1= .false.
- ENDIF
- ELSE
- DataDisplayConsole%TripTankAlarmLED = 0 !(OFF)
- DataDisplayConsole%Buzzer1= .false.
- ENDIF
-
- DataDisplayConsole%TripTankPumpLED= DataDisplayConsole%TripTankPumpSwitch
-
-
- ELSEIF (DataDisplayConsole%TripTankPowerSwitch==0) THEN
- DataDisplayConsole%TripTankGauge= 0. !(gal)
- DataDisplayConsole%TripTankAlarmLED= 0
- DataDisplayConsole%TripTankPumpLED= 0
- DataDisplayConsole%Buzzer1= .false.
- ENDIF
-
-
- ! if ( IsPortable ) then
-
- ! TripTank_MinVol_Allowded= DataDisplayConsole%TripAlarmLow
- ! TripTank_MaxVol_Allowded= DataDisplayConsole%TripAlarmHigh
-
-
- ! IF ((TripTankVolumeCalc < TripTank_MinVol_Allowded) .OR. (TripTankVolumeCalc > TripTank_MaxVol_Allowded)) THEN
- ! DataDisplayConsole%TripTankAlarmLED = 1 !(blinking)
- ! IF (DataDisplayConsole%TripTankHornSwitch) THEN
- ! DataDisplayConsole%Buzzer1= .true.
- ! ELSE
- ! DataDisplayConsole%Buzzer1= .false.
- ! ENDIF
- ! ELSE
- ! DataDisplayConsole%TripTankAlarmLED = 0 !(OFF)
- ! DataDisplayConsole%Buzzer1= .false.
- ! ENDIF
-
- ! endif
-
-
-
-
- !write(*,*) '====================================================================='
-
-
-
- ! if (IsStopped) return
-
- end subroutine main
-
-
-
-
- !===================================================================================================================
- !===================================================================================================================
- !===================================================================================================================
-
- subroutine ActiveMudVolumeChanged(v)
- !use CLog4
- implicit none
- real(8), intent (in) :: v
- !call Log_4('ActiveMudVolumeChanged=', v)
- ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! update from student input
- end subroutine
-
- subroutine ActiveDensityChanged(v)
- !use CLog4
- implicit none
- real(8), intent (in) :: v
- !call Log_4('ActiveDensityChanged=', v)
- ActiveTankDensity= MudProperties%ActiveDensity ! update from student input
- end subroutine
-
- subroutine ReserveMudVolumeChanged(v)
- !use CLog4
- implicit none
- real(8), intent (in) :: v
- !call Log_4('ReserveMudVolumeChanged=', v)
- ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! update from student input
- end subroutine
-
- subroutine ReserveDensityChanged(v)
- !use CLog4
- implicit none
- real(8), intent (in) :: v
- !call Log_4('ReserveDensityChanged=', v)
- ReserveTankDensity= MudProperties%ReserveDensity ! update from student input
- end subroutine
-
- subroutine SetupMudSystem()
- use CPathChangeEvents
- use CMudPropertiesVariables
- implicit none
-
- call BeforeTraverse%Add(InitialVarsBeforePathsChanges)
- call AfterTraverse%Add(AfterPathsChanges)
- call OnPathOpen%Add(WhenPathOpen)
-
-
- call OnActiveMudVolumeChange%Add(ActiveMudVolumeChanged)
- call OnActiveDensityChange%Add(ActiveDensityChanged)
- call OnReserveMudVolumeChange%Add(ReserveMudVolumeChanged)
- call OnReserveDensityChange%Add(ReserveDensityChanged)
-
- end subroutine
-
- subroutine AfterPathsChanges()
- implicit none
- integer i
-
- if(Pump1_Lasts%Length() <= 0) return
- do i = 1, Pump1_Lasts%Length()
- if(Pump2_Lasts%Length() <= 0) cycle
- if(any(Pump2_Lasts%Array == Pump1_Lasts%Array(i))) then
- State2 = .true. ! Pumps 1 & 2 have same destination
- !print*, 'State2 = .true.'
- endif
- if(Pump3_Lasts%Length() <= 0) cycle
- if(any(Pump3_Lasts%Array == Pump1_Lasts%Array(i))) then
- State3 = .true. ! Pumps 1 & 3 have same destination
- !print*, 'State3 = .true.'
- endif
- enddo
-
- if(Pump2_Lasts%Length() <= 0) return
- do i = 1, Pump2_Lasts%Length()
- if(Pump3_Lasts%Length() <= 0) cycle
- if(any(Pump3_Lasts%Array == Pump2_Lasts%Array(i))) then
- State4 = .true. ! Pumps 2 & 3 have same destination
- !print*, 'State4 = .true.'
- endif
- enddo
-
- State1 = State2 .and. State3 ! Pumps 1 & 2 & 3 have same destination
- !if(State1) print*, 'State1 = .true.'
-
- end subroutine
-
- subroutine InitialVarsBeforePathsChanges()
- implicit none
-
- condition1 = .false.
- condition2 = .false.
- condition3 = .false.
- condition4 = .false.
- condition5 = .false.
- condition6 = .false.
- condition7 = .false.
- condition8 = .false.
- condition9 = .false.
- condition10 = .false.
- condition11 = .false.
- condition12 = .false.
- condition13 = .false.
- condition14 = .false.
- condition15 = .false.
- condition16 = .false.
- condition17 = .false.
- condition18 = .false.
- condition19 = .false.
- condition20 = .false.
- condition21 = .false.
- condition22 = .false.
- condition23 = .false.
- condition24 = .false.
- condition25 = .false.
- condition26 = .false.
- condition27 = .false.
- condition28 = .false.
- condition29 = .false.
- condition30 = .false.
- condition31 = .false.
- condition32 = .true.
- condition33 = .true.
- condition34 = .true.
- condition35 = .false.
- condition36 = .false.
- condition37 = .false.
- condition38 = .false.
- condition39 = .false.
- condition40 = .false.
- condition41 = .false.
- condition42 = .false.
- condition43 = .false.
- condition44 = .false.
- condition45 = .false.
- condition46 = .false.
- condition47 = .false.
- condition48 = .false.
- condition49 = .false.
- condition50 = .false.
- condition51 = .false.
- condition52 = .false.
- condition53 = .false.
- condition54 = .false.
- condition55 = .false.
- condition56 = .false.
- condition57 = .false.
- condition58 = .false.
- condition59= .false.
- condition60= .false.
- condition61= .false.
-
-
-
-
-
-
-
- !ThereIsPathFrom82 = .false.
- !!print*, "ThereIsPathFrom82=",ThereIsPathFrom82
- !ThereIsPathFrom83 = .false.
- !!print*, "ThereIsPathFrom82=",ThereIsPathFrom82
- !ThereIsPathFrom84 = .false.
- !!print*, "ThereIsPathFrom82=",ThereIsPathFrom82
-
- ThereIsPathFrom_71_72_73_To_82 = .false.
- !print*, "ThereIsPathFrom_71_72_73_To_82=",ThereIsPathFrom_71_72_73_To_82
- ThereIsPathFrom_71_72_73_To_83 = .false.
- !print*, "ThereIsPathFrom_71_72_73_To_83=",ThereIsPathFrom_71_72_73_To_83
- ThereIsPathFrom_71_72_73_To_84 = .false.
- !print*, "ThereIsPathFrom_71_72_73_To_84=",ThereIsPathFrom_71_72_73_To_84
-
- DumpFromKelly_Pump1 = .false.
- DumpFromFillupHead_Pump1 = .false.
- DumpFromTopDrive_Pump1 = .false.
-
-
- DumpFromKelly_Pump2 = .false.
- DumpFromFillupHead_Pump2 = .false.
- DumpFromTopDrive_Pump2 = .false.
-
-
- DumpFromKelly_Pump3 = .false.
- DumpFromFillupHead_Pump3 = .false.
- DumpFromTopDrive_Pump3 = .false.
-
-
-
- State1 = .false.
- State2 = .false.
- State3 = .false.
- State4 = .false.
-
- call Pump1_Lasts%Empty()
- call Pump2_Lasts%Empty()
- call Pump3_Lasts%Empty()
-
-
-
-
-
- ac32 = .false.
- ac33 = .false.
- ac34 = .false.
- ac35 = .false.
- ac29 = .false.
-
- end subroutine
-
- subroutine WhenPathOpen(valves)
- use Pumps_VARIABLES
- implicit none
- integer, allocatable, intent (in) :: valves(:)
- integer :: first, last
- if (.not.allocated(valves)) return
- if(size(valves) <= 0) return
-
- if ( any(valves == 32)) ac32 = .true.
- if ( any(valves == 33)) ac33 = .true.
- if ( any(valves == 34)) ac34 = .true.
- if ( any(valves == 35)) ac35 = .true.
- if ( any(valves == 29)) ac29 = .true.
-
-
- first = 1
- last = size(valves)
-
- MP1_Q = PUMP(1)%Flow_Rate
- MP2_Q = PUMP(2)%Flow_Rate
- MP3_Q = PUMP(3)%Flow_Rate
-
-
-
- if(valves(first) == 82) call Pump1_Lasts%Add(valves(last))
- if(valves(first) == 83) call Pump2_Lasts%Add(valves(last))
- if(valves(first) == 84) call Pump3_Lasts%Add(valves(last))
-
- !print*, '=============================================='
- !do i = 1, Pump1_Lasts%Length()
- ! print*, 'mp1=', Pump1_Lasts%Array(i)
- !enddo
- !
- !print*, '-------------------------------'
- !
- !do i = 1, Pump2_Lasts%Length()
- ! print*, 'mp2=', Pump2_Lasts%Array(i)
- !enddo
- !
- !print*, '-------------------------------'
- !
- !
- !do i = 1, Pump3_Lasts%Length()
- ! print*, 'mp3=', Pump3_Lasts%Array(i)
- !enddo
- !
- !print*, '=============================================='
-
-
- !if(valves(first)==82 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71)) then
- ! ThereIsPathFrom82 = .true.
- ! !print*, "ThereIsPathFrom82=",ThereIsPathFrom82
- !endif
- !
- !if(valves(first)==83 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71)) then
- ! ThereIsPathFrom83 = .true.
- ! !print*, "ThereIsPathFrom83=",ThereIsPathFrom83
- !endif
- !
- !if(valves(first)==84 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71)) then
- ! ThereIsPathFrom84 = .true.
- ! !print*, "ThereIsPathFrom84=",ThereIsPathFrom84
- !endif
-
- if(valves(last)==82 .and. (valves(first)==71 .or. valves(first)==72 .or. valves(first)==73)) then
- ThereIsPathFrom_71_72_73_To_82 = .true.
- !print*, "ThereIsPathFrom_71_72_73_To_82=",ThereIsPathFrom_71_72_73_To_82
- endif
-
- if(valves(last)==83 .and. (valves(first)==71 .or. valves(first)==72 .or. valves(first)==73)) then
- ThereIsPathFrom_71_72_73_To_83 = .true.
- !print*, "ThereIsPathFrom_71_72_73_To_83=",ThereIsPathFrom_71_72_73_To_83
- endif
-
- if(valves(last)==84 .and. (valves(first)==71 .or. valves(first)==72 .or. valves(first)==73)) then
- ThereIsPathFrom_71_72_73_To_84 = .true.
- !print*, "ThereIsPathFrom_71_72_73_To_84=",ThereIsPathFrom_71_72_73_To_84
- endif
-
- !if (.not.allocated(OpenPaths)) exit
- !===============TanksToMudPump1===================
- if(valves(last)==82) then
- if(valves(first)==71) then
- !j2=j2+1
- !A71=1
- condition1 = .true.
- endif
-
- if(valves(first)==72) then
- !j2=j2+1
- !A72=1
- condition2 = .true.
- endif
-
- if(valves(first)==73) then
- !j2=j2+1
- !A73=1
- condition3 = .true.
- endif
-
- endif
- !================================================
-
-
- !============BellNippleToPits-FullWell(MLnumber=3)==============
-
- if ( Manifold%Valve(41)%Status == .false. .and. Manifold%Valve(42)%Status == .false. ) then
- call ChangeValve(60, .TRUE.)
- else
- call ChangeValve(60, .FALSE.)
- endif
-
- if(valves(first)==80 .and. valves(last)==71 .and. any(valves == 42)) condition4 = .true.
- if(valves(first)==80 .and. valves(last)==77 .and. any(valves == 41)) condition5 = .true.
- if(valves(first)==80 .and. valves(last)==78) condition6 = .true.
-
- !================================================
-
-
- !============WellToChokeManifold(Through 26)==============
- if(valves(first)==79 .and. any(valves == 26)) then
- if(valves(last)==71) then
- !j4=j4+1
- !C71=1.
- condition7 = .true.
- endif
-
- if(valves(last)==77) then
- !j4=j4+1
- !C77=1.
- condition8 = .true.
- endif
-
- if(valves(last)==78) then
- !j4=j4+1
- !C78=1.
- condition45 = .true.
- endif
-
- endif
-
- !================================================
-
-
- !============ActiveTankToTripTank==============
- if(valves(first)==71 .and. valves(last)==77) then
- !j5=j5+1
- condition9 = .true.
- endif
- !================================================
-
-
-
- !============TripTankToActiveTank And BellNipple==============
- if(valves(first)==77) then
- if(valves(last)==71) then
- !j6=j6+1
- !D71=1
- condition10 = .true.
- endif
-
- if(valves(last)==80) then
- !j6=j6+1
- !D80=1
- condition11 = .true.
- endif
-
- endif
- !================================================
-
-
- !============ActiveTankToDump==============
- if(valves(first)==71 .and. valves(last)==78) then
- !j7=j7+1
- condition12 = .true.
- endif
- !================================================
-
-
- !============TripTankToDump==============
- if(valves(first)==77 .and. valves(last)==78) then
- !j8=j8+1
- condition13 = .true.
- endif
- !================================================
-
-
- !============WellToBellNipple==============
- if(valves(first)==79 .and. valves(last)==80) then
- !j9=j9+1
- condition14 = .true.
- endif
- !================================================
-
- !============MudBucketToBellNipple==============
- if(valves(first)==81 .and. valves(last)==80) then
- !j10=j10+1
- condition15 = .true.
- endif
- !================================================
-
-
- !============BellNippleToWell-NonFullWell==============
- if(valves(first)==80 .and. valves(last)==79) then ! Well is NOT Full
- !j11=j11+1
- condition16 = .true.
- endif
- !================================================
-
- !===============TanksToMudPump2===================
- if(valves(last)==83) then
- if(valves(first)==71) then
- !j12=j12+1
- !E71=1
- condition17 = .true.
- endif
-
- if(valves(first)==72) then
- !j12=j12+1
- !E72=1
- condition18 = .true.
- endif
-
- if(valves(first)==73) then
- !j12=j12+1
- !E73=1
- condition19 = .true.
- endif
-
- endif
- !================================================
-
-
- !===============TanksToCementPump===================
- if(valves(last)==84) then
- if(valves(first)==71) then
- !j13=j13+1
- !F71=1
- condition20 = .true.
- endif
-
- if(valves(first)==72) then
- !j13=j13+1
- !F72=1
- condition21 = .true.
- endif
-
- if(valves(first)==73) then
- !j13=j13+1
- !F73=1
- condition22 = .true.
- endif
-
- endif
- !================================================
-
- !===============PumpsToString===================
- if(valves(last)==79) then
- if(valves(first)==82) then
- !j14=j14+1
- !G82=1
- condition23 = .true.
- endif
-
- if(valves(first)==83) then
- !j14=j14+1
- !G83=1
- condition24 = .true.
- endif
-
- if(valves(first)==84) then
- !j14=j14+1
- !G84=1
- condition25 = .true.
- endif
-
- endif
- !================================================
-
-
-
-
-
- !============MudPump1HasPath===================
- if(ThereIsPathFrom_71_72_73_To_82 .and. (valves(first)==82 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71))) then
- !Mp1_NoPath= 0
- condition32 = .false.
- endif
- condition32Final = condition32
- !================================================
-
-
- !============MudPump2HasPath===================
- if(ThereIsPathFrom_71_72_73_To_83 .and. (valves(first)==83 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71))) then
- !write(*,*) 'condition33 ******'
- !Mp2_NoPath= 0
- condition33 = .false.
- endif
- condition33Final= condition33
- !================================================
-
-
- !============CementPumpHasNoPath===================
- if(ThereIsPathFrom_71_72_73_To_84 .and. (valves(first)==84 .and. (valves(last)==79 .or. valves(last)==78 .or. valves(last)==77 .or. valves(last)==71))) then
- !Cp_NoPath= 1
- condition34 = .false.
- endif
- condition34Final = condition34
- !================================================
-
-
-
-
- !===============PumpsToDump===================
- !DumpFromKelly = 0.0
- !DumpFromFillupHead= 0.0
-
- if(valves(last)==78) then
- if(valves(first)==82) then
- !DumpPump1=1
- condition26 = .true.
- IF(any(valves == 56)) DumpFromKelly_Pump1 = .true.
- IF(any(valves == 14)) DumpFromFillupHead_Pump1 = .true.
- IF(any(valves == 70)) DumpFromTopDrive_Pump1 = .true.
-
-
- endif
-
-
- if(valves(first)==83) then
- !DumpPump2=1
- print*, "THERE IS DUMP"
- condition27 = .true.
- IF(any(valves == 56)) DumpFromKelly_Pump2 = .true.
- IF(any(valves == 14)) DumpFromFillupHead_Pump2 = .true.
- IF(any(valves == 70)) DumpFromTopDrive_Pump2 = .true.
-
- endif
-
-
- if(valves(first)==84) then
- !DumpCementPump=1
- condition28 = .true.
- IF(any(valves == 56)) DumpFromKelly_Pump3 = .true.
- IF(any(valves == 14)) DumpFromFillupHead_Pump3 = .true.
- IF(any(valves == 70)) DumpFromTopDrive_Pump3 = .true.
-
- endif
-
- ! DumpFromKelly
- !if (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3) then
- ! DumpFromKelly = 1.0
- !else
- ! DumpFromKelly = 0.0
- !endif
-
-
- ! DumpFromFillupHead
- if (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3) then
- DumpFromFillupHead = 1.0
- else
- DumpFromFillupHead = 0.0
- endif
-
- endif
-
-
-
- !================================================
-
-
- !=======MudPumps1&2ToActiveTank_Through65&66==========
-
- ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >>
-
-
- if(valves(last)==71) then
- if(valves(first)==82 .and. any(valves == 65)) then
- !j15=j15+1
- !H82=1.0
- condition29 = .true.
- endif
-
- if(valves(first)==83 .and. any(valves == 66)) then
- !j15=j15+1
- !H83=1.0
- condition30 = .true.
- endif
-
- endif
- !================================================
-
- !=======CementPumpToCementTank_Through67==========
-
- ! << if H82 or H83 or H4 are open, no flow goes to other parts of system >>
-
-
- if(valves(last)==73 .and. valves(first)==84 .and. any(valves == 67)) then
-
- !H84=1.0
- condition31 = .true.
-
- endif
- !================================================
-
-
-
- !===============PathsToGauge75===================
- if(valves(last)==75) then
- if(valves(first)==82) then !Pump1 to Gauge75
- !j16=j16+1
- !K82=1
- condition35 = .true.
- endif
-
- if(valves(first)==83) then !Pump2 to Gauge75
- !j16=j16+1
- !K83=1
- condition36 = .true.
- endif
-
- if(valves(first)==84) then !Pump3 to Gauge75
- !j16=j16+1
- !K84=1
- condition37 = .true.
- endif
-
- if(valves(first)==79) then !String to Gauge75
- !j16=j16+1
- !K79=1
- condition38 = .true.
- endif
-
- if(valves(first)==78) then !Dump to Gauge75
- !j16=j16+1
- !K78=1
- condition39 = .true.
- endif
-
- endif
- !================================================
-
- !===============PathsToGauge76===================
- if(valves(last)==76) then
- if(valves(first)==82) then !Pump1 to Gauge76
- !j17=j17+1
- !L82=1
- condition40 = .true.
- endif
-
- if(valves(first)==83) then !Pump2 to Gauge76
- !j17=j17+1
- !L83=1
- condition41 = .true.
- endif
-
- if(valves(first)==84) then !Pump3 to Gauge76
- !j17=j17+1
- !L84=1
- condition42 = .true.
- endif
-
- if(valves(first)==79) then !String to Gauge76
- !j17=j17+1
- !L79=1
- condition43 = .true.
- endif
-
- if(valves(first)==78) then !Dump to Gauge76
- !j17=j17+1
- !L78=1
- condition44 = .true.
- endif
-
- endif
- !================================================
-
-
- !====Pump1-StandPipeManifoldToChokeManifold-Through ChokeLine====
- if(valves(first)==82 .and. any(valves == 2)) then
- if(valves(last)==71) then
- !j18=j18+1
- !M71=1.
- !Pump1toCh= 1.
- condition46 = .true.
- endif
-
- if(valves(last)==77) then
- !j18=j18+1
- !M77=1.
- !Pump1toCh= 1.
- condition47 = .true.
- endif
-
- if(valves(last)==78) then
- !j18=j18+1
- !M78=1.
- !Pump1toCh= 1.
- condition48 = .true.
- endif
-
- endif
- !=================================================================
-
-
- !====Pump2-StandPipeManifoldToChokeManifold-Through ChokeLine====
- if(valves(first)==83 .and. any(valves == 2)) then
- if(valves(last)==71) then
- !j18=j18+1
- !M71=1.
- !Pump2toCh= 1.
- condition49 = .true.
- endif
-
- if(valves(last)==77) then
- !j18=j18+1
- !M77=1.
- !Pump2toCh= 1.
- condition50 = .true.
- endif
-
- if(valves(last)==78) then
- !j18=j18+1
- !M78=1.
- !Pump2toCh= 1.
- condition51 = .true.
- endif
-
- endif
- !=================================================================
-
-
- !====Pump3-StandPipeManifoldToChokeManifold-Through ChokeLine====
- if(valves(first)==84 .and. any(valves == 2)) then
- if(valves(last)==71) then
- !j18=j18+1
- !M71=1.
- !Pump3toCh= 1.
- condition52 = .true.
- endif
-
- if(valves(last)==77) then
- !j18=j18+1
- !M77=1.
- !Pump3toCh= 1.
- condition53 = .true.
- endif
-
- if(valves(last)==78) then
- !j18=j18+1
- !M78=1.
- !Pump3toCh= 1.
- condition54 = .true.
- endif
-
- endif
- !=================================================================
-
-
-
-
- !===============PumpsToWell_KillLine============
- if(valves(last)==79) then
- if(valves(first)==82) then
- !j19=j19+1
- !N82=1
- condition55 = .true.
- endif
-
- if(valves(first)==83) then
- !j19=j19+1
- !N83=1
- condition56 = .true.
- endif
-
- if(valves(first)==84) then
- !j19=j19+1
- !N84=1
- condition57 = .true.
- endif
-
- endif
- !================================================
-
- !===============WellToChokeLineGauge============
- if(valves(first)==79 .and. valves(last)==85) then
- !j20=j20+1
- condition58 = .true.
- endif
- !================================================
-
-
- !============ChokeLineGaugeToTanks===============
- if(valves(first)==85) then
- if(valves(last)==71) then
- !j21=j21+1
- condition59 = .true.
- endif
-
- if(valves(last)==77) then
- !j21=j21+1
- condition60 = .true.
- endif
-
- if(valves(last)==78) then
- !j21=j21+1
- condition61 = .true.
- endif
-
- endif
- !================================================
-
-
-
-
-
-
-
-
-
- end subroutine
-
-
-
-
- end module MudSystem
|