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