|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467 |
- module MudSystemModule
-
- 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(MudSystem%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. MudSystem%FirstMudSet== 1 .and. MudSystem%BellNippleVolume > 0.0001 .and. MudSystem%WellisNOTFull) then
-
- write(*,*) 'MUD(7)%Q=' , MUD(7)%Q
- write(*,*) 'BellNippleVolume=' , MudSystem%BellNippleVolume
-
-
- write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn
-
- write(*,*) 'int:::=' , (MudSystem%Ann_Mud_Forehead_X%Last() - BopStackSpecification%AboveAnnularHeight)
- write(*,*) 'Ann_Mud_Forehead_X%Last()=' , MudSystem%Ann_Mud_Forehead_X%Last()
- write(*,*) 'AboveAnnularHeight=' , BopStackSpecification%AboveAnnularHeight
- write(*,*) 'Ann_Density%Last()=' , MudSystem%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(MudSystem%condition32Final) then
- !write(*,*) 'MudPump1HasNoPath'
- Mp1_NoPath = 1
- endif
- !================================================
-
- !============MudPump2HasNoPath===================
- if(MudSystem%condition33Final) then
- !write(*,*) 'MudPump2HasNoPath'
- Mp2_NoPath = 1
- endif
- !================================================
-
-
- !============CementPumpHasNoPath===================
- if(MudSystem%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
- MudSystem%WellToChokeLineGauge= .true.
- else
- MudSystem%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
- MudSystem%ChokeLineGaugeToTanks= .true.
- else
- MudSystem%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
-
- MudSystem%MudSys_timeCounter = MudSystem%MudSys_timeCounter + 1
- if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
- MudSystem%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
- MudSystem%ActiveTankDensity= 0.
- MudSystem%ActiveTankVolume= 0.
- endif
-
-
- if (j8 > 0) then !TripTankToDump
- MudSystem%TripTankDensityCalc= 0.
- MudSystem%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
-
-
- MudSystem%ActiveTankDensity = (MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume+ Mp1Coef*MudSystem%Mp1Density*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*MudSystem%Mp2Density*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))/ &
- (MudSystem%ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.
- !write(*,*) 'active by j15'
- endif
-
-
- MudSystem%ActiveTankVolume=min(MudSystem%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
-
-
- MudSystem%CementTankDensityCalc= (MudSystem%CementTankDensityCalc*MudSystem%CementTankVolumeCalc+ CpCoef*MudSystem%Mp3Density*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) ) / &
- (MudSystem%CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))
-
- MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)
-
-
- endif
-
- !===========================================================================================================================
- !===========================================================================================================================
- ! DUMP Path
- MudSystem%PumpsDumpVolume= MudSystem%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) *MudSystem%DeltaT_Mudline/60.
- MudSystem%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. MudSystem%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(MudSystem%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. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromTopDrive_Pump1 .or. DumpFromTopDrive_Pump2 .or. DumpFromTopDrive_Pump3)) then
- !write(*,*) 'Set_FlowFromKelly(.TRUE.)'
- call Activate_PumpWithTopdriveDisconnected()
- CALL Set_FlowFromKelly(min(MudSystem%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 (MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then
-
- !call Activate_PumpWithKellyDisconnected()
- CALL Set_FlowFromFillupHead(min(MudSystem%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
- MudSystem%Pump1BlownCount = MudSystem%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. MudSystem%Pump1BlownCount >= BlownThreshold) then
- write(*,*) 'valve 65 open, BLOWN'
- call ChangeValve(65, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- MudSystem%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
- MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1
- !if (Pump2BlownStarted == .FALSE. ) then
- ! Pump2BlownInTimeStep = SimulationTime + BlownThresholdInSecond
- ! Pump2BlownStarted = .TRUE.
- !endif
- !if (MudPump2ReliefValveIsSet .and. SimulationTime >= Pump2BlownInTimeStep .and. Pump2BlownStarted) then
- if (PumpsSpecification%MudPump2ReliefValveIsSet .and. MudSystem%Pump2BlownCount >= BlownThreshold) then
- write(*,*) 'valve 66 open, BLOWN'
- call ChangeValve(66, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- MudSystem%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
- MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1
- if (PumpsSpecification%CementPumpReliefValveIsSet .and. MudSystem%Pump3BlownCount >= BlownThreshold) then
- !write(*,*) 'valve 67 open, BLOWN'
- call ChangeValve(67, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- MudSystem%Pump3BlownCount = 0
- !else
- ! PumpPressure3= 6000. !psi
- endif
- !else
- !Pump3BlownInTimeStep = 0
- !Pump3BlownStarted = .FALSE.
- endif
-
- !write(*,*) '3)PumpPressure1=' , PumpPressure1
-
- if (PumpPressure1>= 6000.) then
- MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1
- if(MudSystem%Pump1BlownCount >= BlownThreshold) then
- call ChangeValve(65, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- call Activate_Pump1Failure()
- MudSystem%Pump1OffFailure= .true.
- MudSystem%Pump1BlownCount = 0
- endif
- !else
- !Pump1BlownInTimeStep = 0
- !Pump1BlownStarted = .FALSE.
- endif
-
- if (PumpPressure2>= 6000.) then
- MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1
- if(MudSystem%Pump2BlownCount >= BlownThreshold) then
- call ChangeValve(66, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- call Activate_Pump2Failure()
- MudSystem%Pump2OffFailure= .true.
- MudSystem%Pump2BlownCount = 0
- endif
- !else
- !Pump2BlownInTimeStep = 0
- !Pump2BlownStarted = .FALSE.
- endif
-
- if (PumpPressure3>= 6000.) then
- MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1
- if(MudSystem%Pump3BlownCount >= BlownThreshold) then
- call ChangeValve(67, .TRUE.)
- PumpToManifoldCompressedMudVol= 0.0
- call Activate_Pump3Failure()
- MudSystem%Pump3OffFailure= .true.
- MudSystem%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= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%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(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn
- !write(*,*) 'Ann_Kick_Saved_Volume=' , Ann_Kick_Saved_Volume
-
- sys_total_injected= sys_total_injected+ MudSystem%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 ((MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)) /= 0.0) then
-
- MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%WellOutletDensity*(MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline))
- else
- MudSystem%BellNippleDensity= 0.0
- endif
-
-
- !IF (WellisNOTFull== .false.) THEN ! well must be full to do this order
- MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)
- !ENDIF
-
-
- VolumeToBellNipple= VolumeToBellNipple + MudSystem%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
- MudSystem%WellToPitsOpen= .true.
- else
- MudSystem%WellToPitsOpen= .false.
- endif
-
-
- !===========================================================================================================================
- !===========================================================================================================================
-
-
- if (j10 > 0) then !MudBucketToBellNipple
- !write(*,*) 'j10 is open'
- !MudBucketVolume= 0.
- !MudBucketDensity= 0.
- ! MudBucketVolume gets value in DisconnectingPipe subroutine
- MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ MudSystem%MudBucketVolume
- MudSystem%BellNippleDensity= MudSystem%ActiveTankDensity
- MudSystem%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)
-
-
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc - ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
-
-
- !write(*,*) 'ActiveTankVolume before=', ActiveTankVolume
-
-
- if (j6 == 1 .and. D71==1) then
- !write(*,*) 'add to active'
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
- !write(*,*) 'ActiveTankVolume after=', ActiveTankVolume
-
- endif
-
- if (j6 == 1 .and. D80==1) then
- MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
- endif
-
- if (j6 == 2) then
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
- endif
-
-
-
- MudSystem%ActiveTankVolume=min(MudSystem%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 = (MudSystem%BellNippleVolume/MudSystem%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,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8)) ! for unity display
- unityreturn = real(100.*min(MUD(3)%Q,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8)
-
- !write(*,*) 'unity return=' , real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8)
-
-
-
-
- if (MUD(3)%Q > MudSystem%PedalMeter .and. B78==0) then
- MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume + ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline - (MudSystem%PedalMeter/60.)*MudSystem%DeltaT_Mudline)
-
- !BellNippleDumpRate= MUD(3)%Q - PedalMeter
-
- CALL Set_FlowFromReturnLine(.TRUE.) ! for unity display
-
- endif
-
- !VolumeToActive = VolumeToActive + BellNippleVolume
- !write(*,*) 'VolumeToActive*******=' , VolumeToActive
-
-
- active_before= MudSystem%ActiveTankVolume
-
-
- MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) ! to be 0.
-
- if ( MudSystem%BellNippleDensity > 1.0) then
- if (j3 == 1 .and. B71==1) then !(volumes in galon)
-
-
- MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter)
- !write(*,*) 'MUD(3)%Q=' , MUD(3)%Q
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
-
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- !write(*,*) 'active increase bell 1=' , ((MUD(3)%Q/60.)*DeltaT_Mudline)
-
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN
-
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%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. MudSystem%BellNippleDensity < 5.0) THEN
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%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 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN
- !write(*,*) ' Auto true 3'
-
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.d0)*MudSystem%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 , MudSystem%PedalMeter)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
-
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN
-
- AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- ENDIF
-
- endif
-
-
- if (j3 == 1 .and. B78==1) then
-
- MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*MudSystem%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 , MudSystem%PedalMeter)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
-
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ ((0.5*MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN
-
-
- AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((0.5d0*MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
-
- ENDIF
-
-
- endif
-
- endif !( BellNippleDensity > 1.0) then
-
- active_after= MudSystem%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
-
- MudSystem%ReturnFlowRate = MUD(3)%Q
-
- MudSystem%TripTankVolumeCalc = min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal
- !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped
-
- MudSystem%ActiveTankVolume = min(MudSystem%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. MudSystem%MudChecked== .true.) then !BellNippleToWell-NonFullWell ( FillingWell_By_BellNipple subroutine is called for this state )
- !write(*,*) 'j11 is open'
- MudSystem%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 = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60.
- !write(*,*) 'MUD(8)%Q=' , MUD(8)%Q
-
-
- MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(8)%Q/60.)*MudSystem%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. MudSystem%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= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%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)
-
- MudSystem%ChokeOutletDensity= MudSystem%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 ( MudSystem%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
-
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
- !write(*,*) 'active increase choke1=' , (((1./RealJ4)*MUD(4)%Q/60.)*DeltaT_Mudline)
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN
-
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.d0)*MudSystem%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. MudSystem%ChokeOutletDensity < 5.0) THEN
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%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 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN
- !write(*,*) ' Auto true 3'
-
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%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
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
-
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity < 5.0) THEN
-
- AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= (((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
-
- ENDIF
-
-
-
- endif
-
- if (C71==1 .and. C77==1) then !RealJ4: 2 OR 3(IF 78 IS OPEN)
-
- IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ChokeOutletDensity*((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline))
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%ChokeOutletDensity > MudSystem%ActiveTankDensity) THEN
-
-
- AddedVolumeToTank= ((20.8d0-MudSystem%ChokeOutletDensity)/(20.8d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((2.d0-MudSystem%ChokeOutletDensity)/(2.d0-MudSystem%ActiveTankDensity))*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
-
- ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%ChokeOutletDensity .and. MudSystem%ChokeOutletDensity <= MudSystem%ActiveTankDensity) THEN
-
- AddedVolumeToTank= ((1.d0/RealJ4)*MUD(4)%Q/60.d0)
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ AddedVolumeToTank
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1.d0/RealJ4)*MUD(4)%Q/60.d0)*MudSystem%DeltaT_Mudline)
-
-
- ENDIF
-
-
- endif
-
-
- if (C71==0 .and. C77==0 .and. C78==1) then !RealJ4: 1
- ! autodensity niaz nadarad
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ4)*MUD(4)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- endif
-
-
-
- endif ! if ( BellNippleDensity > 1.0) then
-
-
- MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal
- !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped
-
- MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
- !if ActiveTankVolume is higher, excess amount is dumped
-
- endif
-
-
-
-
-
- if (j4 == 0 .or. MudSystem%ChokeLineNOTFull== .true.) then
- !Pressure_BeforeChokes=0.0 ! for normal circulation input
- MUD(4)%Q=0.0 ! for CirculationCodeSelect input.
- endif
-
-
- if (j4 > 0) then
- MudSystem%WellToChokeManifoldOpen= .true.
- else
- MudSystem%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
- MudSystem%Density_Ch= (jj2*(1.-H82)*(1.-DumpPump1)*Pump1toCh*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*Pump2toCh*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*Pump3toCh*MudSystem%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
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- endif
-
- if (M77==1 .and. M71==0) then !RealJ18: 1 OR 2(IF 78 IS OPEN)
-
- ! autodensity niaz nadarad
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- endif
-
- if (M71==1 .and. M77==1) then !RealJ18: 2 OR 3(IF 78 IS OPEN)
-
- ! autodensity niaz nadarad
- MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%Density_Ch*((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline))
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ C78*(((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- endif
-
-
- if (M71==0 .and. M77==0 .and. M78==1) then !RealJ18: 1
- ! autodensity niaz nadarad
- MudSystem%ChokeManifoldDumpVolume= MudSystem%ChokeManifoldDumpVolume+ (((1./RealJ18)*MUD(9)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- endif
-
-
-
-
-
-
-
-
- MudSystem%TripTankVolumeCalc=min(MudSystem%TripTankVolumeCalc,50.*42.) !50. BBL *42. gal/BBL = gal
- !if TripTankVolumeCalc>50 BBl, excess value(TripTankVolumeCalc-50) is dumped
-
- MudSystem%ActiveTankVolume=min(MudSystem%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. (MudSystem%ActiveTankVolume/MudSystem%ActiveTankFloorArea) > (MudSystem%TripTankVolumeCalc/MudSystem%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)
-
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume - ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc + ((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline)
-
- MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*(MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(5)%Q/60.)*MudSystem%DeltaT_Mudline))
-
-
-
- MudSystem%TripTankVolumeCalc=min(MudSystem%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
-
- MudSystem%PressureGauge75= PressureGauges(1) !String to Gauge75
-
- elseif (K82 == 1 .and. k83 == 0 .and. k84 == 0 .and. k78 == 0) then
- MudSystem%PressureGauge75= PumpPressure1
- elseif (K82 == 0 .and. k83 == 1 .and. k84 == 0 .and. k78 == 0) then
- MudSystem%PressureGauge75= PumpPressure2
- elseif (K82 == 0 .and. k83 == 0 .and. k84 == 1 .and. k78 == 0) then
- MudSystem%PressureGauge75= PumpPressure3
- elseif (K82 == 0 .and. k83 == 0 .and. k84 == 0 .and. k78 == 1) then
- MudSystem%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 - MudSystem%StandPipeGauge1Malf) * MudSystem%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
-
- MudSystem%PressureGauge76= PressureGauges(1) !String to Gauge76
-
- elseif (L82 == 1 .and. L83 == 0 .and. L84 == 0 .and. L78 == 0) then
- MudSystem%PressureGauge76= PumpPressure1
- elseif (L82 == 0 .and. L83 == 1 .and. L84 == 0 .and. L78 == 0) then
- MudSystem%PressureGauge76= PumpPressure2
- elseif (L82 == 0 .and. L83 == 0 .and. L84 == 1 .and. L78 == 0) then
- MudSystem%PressureGauge76= PumpPressure3
- elseif (L82 == 0 .and. L83 == 0 .and. L84 == 0 .and. L78 == 1) then
- MudSystem%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 - MudSystem%StandPipeGauge2Malf) * MudSystem%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 (StudentStation%TapSelector == .false.) then
-
- DrillingWatch%PumpPressure= MudSystem%PressureGauge75 !for DrillWatch Display
- CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%PressureGauge75 , 8)) !for Data Display Console
- else
- DrillingWatch%PumpPressure= MudSystem%PressureGauge76 !for DrillWatch Display
- CALL Set_StandPipePressure(real((1-MudSystem%DrillPipePressureMalf)*MudSystem%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. (MudSystem%ActiveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- A71= 0
- RealJ2= RealJ2-1
- write(*,*) 'ActiveTank Level Warning'
- call Activate_ActiveTankUnderVolume()
- endif
-
- if (A72==1 .and. (MudSystem%ReserveTankVolume-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- A72= 0
- RealJ2= RealJ2-1
- write(*,*) 'ReserveTank Level Warning'
- endif
-
- if (A71==3 .and. (MudSystem%CementTankVolumeCalc-(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- A73= 0
- RealJ2= RealJ2-1
- write(*,*) 'CementTank Level Warning'
- endif
-
-
- if(RealJ2> 0.0) then
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- A71*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- A72*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- A73*(((1./RealJ2)*PUMP(1)%Flow_Rate/60.)*MudSystem%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.)*MudSystem%DeltaT_Mudline)
-
- if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
- total_decrease= 0.
- endif
- !write(*,*) 'total_decrease=' , total_decrease
-
-
- MudSystem%Mp1Density= (A71*MudSystem%ActiveTankDensity+A72*MudSystem%ReserveTankDensity+A73*MudSystem%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. (MudSystem%ActiveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- E71= 0
- RealJ12= RealJ12-1
- write(*,*) 'ActiveTank Level Warning'
- endif
-
- if (E72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- E72= 0
- RealJ12= RealJ12-1
- write(*,*) 'ReserveTank Level Warning'
- endif
-
- if (E71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- E73= 0
- RealJ12= RealJ12-1
- write(*,*) 'CementTank Level Warning'
- endif
-
-
- if(RealJ12> 0.0) then
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- E71*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- E72*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- E73*(((1/RealJ12)*PUMP(2)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
-
-
-
- MudSystem%Mp2Density= (E71*MudSystem%ActiveTankDensity+E72*MudSystem%ReserveTankDensity+E73*MudSystem%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. (MudSystem%ActiveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- F71= 0
- RealJ13= RealJ13-1
- write(*,*) 'ActiveTank Level Warning'
- endif
-
- if (F72==1 .and. (MudSystem%ReserveTankVolume-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- F72= 0
- RealJ13= RealJ13-1
- write(*,*) 'ReserveTank Level Warning'
- endif
-
- if (F71==3 .and. (MudSystem%CementTankVolumeCalc-(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)) < 0.0) then
- F73= 0
- RealJ13= RealJ13-1
- write(*,*) 'CementTank Level Warning'
- endif
-
-
- if(RealJ13> 0.0) then
-
- MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume- F71*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%ReserveTankVolume= MudSystem%ReserveTankVolume- F72*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
- MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc- F73*(((1/RealJ13)*PUMP(3)%Flow_Rate/60.)*MudSystem%DeltaT_Mudline)
-
-
- MudSystem%Mp3Density= (F71*MudSystem%ActiveTankDensity+F72*MudSystem%ReserveTankDensity+F73*MudSystem%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
- MudSystem%Suction_Density_MudSystem= (jj2*(1.-H82)*(1.-DumpPump1)*G82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*G83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*G84*MudSystem%Mp3Density*PUMP(3)%Flow_Rate)/ &
- Denominator
- endif
-
- MudSystem%CompressedMudDensity= MudSystem%Suction_Density_MudSystem
-
- DrillingWatch%MudWeightIn= MudSystem%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. MudSystem%MudChecked== .true.) then !PumpsToWell_KillLine Suction_Density_PumpsToWell is used for Mud Circulation Code
- !write(*,*) 'j19 is open'
- MudSystem%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
- MudSystem%Suction_Density_PumpsToWell= (jj2*(1.-H82)*(1.-DumpPump1)*N82*MudSystem%Mp1Density*PUMP(1)%Flow_Rate + jj12*(1.-H83)*(1.-DumpPump2)*N83*MudSystem%Mp2Density*PUMP(2)%Flow_Rate + jj13*(1.-H84)*(1.-DumpCementPump)*N84*MudSystem%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 ( MudSystem%WellToChokeManifoldOpen .or. MudSystem%WellToPitsOpen) then
- MudSystem%WellHeadIsOpen= .true.
- else
- MudSystem%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 (MudSystem%ActiveTankVolume >= (MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)) THEN
- MudSystem%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(MudSystem%ActiveTankVolume/42.,8)) ! 42: gal to bbl
- call Set_ActiveDensity_StudentStation(real(MudSystem%ActiveTankDensity,8))
- call Set_ReserveMudVolume_StudentStation(real(MudSystem%ReserveTankVolume/42.,8)) ! 42: gal to bbl
- call Set_ReserveDensity_StudentStation(real(MudSystem%ReserveTankDensity,8))
- DrillingWatch%KillMudVolume= MudSystem%ReserveTankVolume/42. ! for DrillWatch
- !PitGainLose=
-
-
- !!======================================================================
- !! DRILLING DATA DISPLAY
- !!======================================================================
-
-
- IF (DataDisplayConsole%TotalStrokeCounterResetSwitch == 1) then !for drilling data display
- MudSystem%TotalStrokesPump1=0.
- MudSystem%TotalStrokesPump2=0.
- ENDIF
-
- MudSystem%TotalStrokesPump1=MudSystem%TotalStrokesPump1+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display
- MudSystem%TotalStrokesPump2=MudSystem%TotalStrokesPump2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline !for drilling data display
- MudSystem%GraphTotalStrokes=MudSystem%GraphTotalStrokes+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline
-
-
- MPumps%Total_Stroke_Counter_For_Plot = MPumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * MudSystem%DeltaT_Mudline
-
- CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot))
-
- DataDisplayConsole%TotalStrokeCounter= real(nint(MudSystem%TotalStrokesPump1+MudSystem%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.)*MudSystem%DeltaT_Mudline
- Choke%TotalStrokes2= Choke%TotalStrokes2+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%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= MudSystem%ActiveTankVolume/42.d0 !(bbl) For DrillWatch Display
-
- !write(*,*) 'PitVolume,ActiveTankVolume=' ,PitVolume,ActiveTankVolume
-
-
- MudSystem%MudTank1_vol= MudSystem%ActiveTankVolume/3. ! (gal)
- MudSystem%MudTank2_vol= MudSystem%ActiveTankVolume/3. ! (gal)
- MudSystem%MudTank3_vol= MudSystem%ActiveTankVolume/3. ! (gal)
- MudSystem%MudTank4_vol= MudSystem%TripTankVolumeCalc
-
-
-
-
-
- IF (DataDisplayConsole%MVTPowerSwitch==1) THEN
- DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%MudTanksVolumeGaugeMalf) *((MudSystem%MudTank1_vol*DataDisplayConsole%MudTank1Switch)+(MudSystem%MudTank2_vol*DataDisplayConsole%MudTank2Switch)+ &
- (MudSystem%MudTank3_vol*DataDisplayConsole%MudTank3Switch)+(MudSystem%MudTank4_vol*DataDisplayConsole%MudTank4Switch)+MudSystem%ActiveTankSettled) !(gal)
- ELSEIF (DataDisplayConsole%MVTPowerSwitch==0) THEN
- DataDisplayConsole%MudTanksVolumeGauge= (1 - MudSystem%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= (MudSystem%ReturnFlowRate/MudSystem%PedalMeter) *100. !(percent) ! for DrillWatch display
- if (abs(DrillingWatch%PercentFlow - unityreturn) > 1.0) then
-
- write(*,*) 'PercentFlow,ReturnFlowRate,PedalMeter=' , DrillingWatch%PercentFlow,MudSystem%ReturnFlowRate,MudSystem%PedalMeter
- write(*,*) 'unityreturn=' , unityreturn
- endif
-
-
- ! ReturnFlowRate=800. set in startup as initial value
- MudSystem%ReturnFlowPercent= (MudSystem%ReturnFlowRate/MudSystem%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= ((MudSystem%ActiveTankVolume/42.) - MudSystem%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 (StudentStation%PitGainLossZero) then
-
- DrillingWatch%PitGainLose= 0.d0 !DrillWatch
- MudSystem%RefrencePitVolume_DrillWatch= MudSystem%ActiveTankVolume/42. !(bbl) !DrillWatch
- !*********************************************
-
- DataDisplayConsole%PitGainLossGauge= 0. !MFF Indicator
- MudSystem%RefrencePitVolume= MudSystem%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
- MudSystem%TotalStrokes1MFFI =0.
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN
- MudSystem%TotalStrokes2MFFI =0.
- else
- MudSystem%TotalStrokes1MFFI =0.
- MudSystem%TotalStrokes2MFFI =0.
- endif
- endif
- MudSystem%TotalStrokes1MFFI= MudSystem%TotalStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline
- MudSystem%TotalStrokes2MFFI= MudSystem%TotalStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline
-
- !==================FillStrokes Reset and Calculate=========================
- if (DataDisplayConsole%MFFIResetFillCounter == 1) then
- IF (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) THEN
- MudSystem%TotalFillStrokes1MFFI =0.
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) THEN
- MudSystem%TotalFillStrokes2MFFI =0.
- else
- MudSystem%TotalFillStrokes1MFFI =0.
- MudSystem%TotalFillStrokes2MFFI =0.
- endif
- endif
-
-
- MudSystem%TotalFillStrokes1MFFI= MudSystem%TotalFillStrokes1MFFI+((DataDisplayConsole%MP1SPMGauge)/60.)*MudSystem%DeltaT_Mudline
- MudSystem%TotalFillStrokes2MFFI= MudSystem%TotalFillStrokes2MFFI+((DataDisplayConsole%MP2SPMGauge)/60.)*MudSystem%DeltaT_Mudline
- !===================================================================
-
-
- if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then
- DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI)) !TotalStroke LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then
- DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes2MFFI)) !TotalStroke LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then
- DataDisplayConsole%MFFITotalStrokeCounter = real(nint(MudSystem%TotalStrokes1MFFI+MudSystem%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 (MudSystem%ReturnFlowRate== 0) then
- if (DataDisplayConsole%MFFIPumpSelectorSwitch == 1) then
- DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes1MFFI)) !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then
- DataDisplayConsole%FillStrokeCounter = real(nint(MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then
- DataDisplayConsole%FillStrokeCounter= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%TotalFillStrokes2MFFI)) !Fill or SPM LED
- endif
-
-
- MudSystem%TotalFilledStrokesBy1MFFI = real(nint(MudSystem%TotalFillStrokes1MFFI))! for values=fix on LED after the well filled
- MudSystem%TotalFilledStrokesBy2MFFI = real(nint(MudSystem%TotalFillStrokes2MFFI))! for values=fix on LED after the well filled
- MudSystem%TotalFilledStrokesBy1and2MFFI= real(nint(MudSystem%TotalFillStrokes1MFFI+MudSystem%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 = MudSystem%TotalFilledStrokesBy1MFFI !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 2) then
- DataDisplayConsole%FillStrokeCounter = MudSystem%TotalFilledStrokesBy2MFFI !Fill or SPM LED
- elseif (DataDisplayConsole%MFFIPumpSelectorSwitch == 3) then
- DataDisplayConsole%FillStrokeCounter= MudSystem%TotalFilledStrokesBy1and2MFFI !Fill or SPM LED
- endif
- endif
-
-
- ENDIF
-
-
-
- !===================================================================================
-
-
-
-
- if (MudSystem%ReturnFlowRate>0) then
- DataDisplayConsole%MFFIPumpLED=1 !(Returns Lamp)
- else
- DataDisplayConsole%MFFIPumpLED=0 !(Returns Lamp)
- endif
-
-
-
- IF (DataDisplayConsole%MFFISetAlarmSwitch==0) THEN
-
- DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%ReturnFlowPercent !(percent)
-
- ELSEIF (DataDisplayConsole%MFFISetAlarmSwitch==-1) THEN
- MudSystem%MFFI_MinPercent_Allowded=DataDisplayConsole%MFFISetAlarmLowKnob
- DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MinPercent_Allowded
-
- ELSE !(MFFISetAlarmSwitch==1)
-
- MudSystem%MFFI_MaxPercent_Allowded=DataDisplayConsole%MFFISetAlarmHighKnob
- DataDisplayConsole%ReturnMudFlowGauge= (1 - MudSystem%ReturnMudFlowGaugeMalf)*MudSystem%MFFI_MaxPercent_Allowded
- ENDIF
-
-
- IF (MudSystem%ReturnFlowPercent<MudSystem%MFFI_MinPercent_Allowded .OR. MudSystem%ReturnFlowPercent>MudSystem%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 = MudSystem%TripTankVolumeCalc/42. !(Drill Watch display)
- Tank%TripTankDensity= MudSystem%TripTankDensityCalc !(display)
-
-
- IF (DataDisplayConsole%TripTankPowerSwitch==1 ) THEN !.and. IsPortable==.false.
-
- IF (DataDisplayConsole%TripTankSetAlarmSwitch==0) THEN
-
- DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTankVolumeCalc ! (gal)
- ELSEIF (DataDisplayConsole%TripTankSetAlarmSwitch==-1) THEN
-
- MudSystem%TripTank_MinVol_Allowded= DataDisplayConsole%TripTankSetAlarmLow/2. ! 2: because knob input is 0-100 but gauge is 0-50
- DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MinVol_Allowded
-
- ELSE !(TripTankSetAlarmSwitch==1)
- MudSystem%TripTank_MaxVol_Allowded= DataDisplayConsole%TripTankSetAlarmHigh/2. ! 2: because knob input is 0-100 but gauge is 0-50
- DataDisplayConsole%TripTankGauge= (1 - MudSystem%TripTankPressure_DataDisplayMalf) * MudSystem%TripTank_MaxVol_Allowded
- ENDIF
-
-
-
- IF ((MudSystem%TripTankVolumeCalc < MudSystem%TripTank_MinVol_Allowded) .OR. (MudSystem%TripTankVolumeCalc > MudSystem%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)
- MudSystem%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)
- MudSystem%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)
- MudSystem%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)
- MudSystem%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
- MudSystem%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
- MudSystem%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
- MudSystem%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 MudSystemModule
|