@@ -633,7 +633,7 @@ module MudSystemModule
use CTanksVariables
Use KickVariables
Use CHoistingVariables
use CSimulationVariables
! use CSimulationVariables
implicit none
Integer I
@@ -647,87 +647,64 @@ module MudSystemModule
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 <<<
!===========================================================================================================================
!===========================================================================================================================
! >>> 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
!ActiveTankVolume= ActiveMudVolumeGal ! update from student input
!ActiveTankDensity= ActiveDensity ! update from student input
!ReserveTankVolume= ReserveMudVolumeGal ! update from student input
!ReserveTankDensity= ReserveDensity ! update from student input
if (j7 > 0) then !ActiveTankToDump
MudSystem%ActiveTankDensity= 0.
MudSystem%ActiveTankVolume= 0.
endif
endif
if (j8 > 0) then !TripTankToDump
MudSystem%TripTankDensityCalc= 0.
MudSystem%TripTankVolumeCalc= 0.
endif
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
if (j15 > 0) then !MudPumps1&2ToActiveTank_Through65&66
!write(*,*) 'j15 is open'
! << if H82 or H83 or H4 are open, no flow goes to other parts of system >>
! << if H82 or H83 or H4 are open, no flow goes to other parts of system >>
if (j2>0) Mp1Coef= 1.0
if (j12>0) Mp2Coef= 1.0
if (j2 /= 0 .or. j12/= 0) then
MudSystem%ActiveTankDensity = (MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume+ Mp1Coef*MudSystem%Mp1Density*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*MudSystem%Mp2Density*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))/ &
(MudSystem%ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.
!write(*,*) 'active by j15'
MudSystem%ActiveTankDensity = (MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume+ Mp1Coef*MudSystem%Mp1Density*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*MudSystem%Mp2Density*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))/ &
(MudSystem%ActiveTankVolume+ Mp1Coef*(PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) + Mp2Coef*(PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ Mp1Coef*PUMP(1)%Flow_Rate*MudSystem%DeltaT_Mudline/60. + Mp2Coef*PUMP(2)%Flow_Rate*MudSystem%DeltaT_Mudline/60.
!write(*,*) 'active by j15'
endif
MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
!if ActiveTankVolume is higher, excess amount is dumped
MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
!if ActiveTankVolume is higher, excess amount is dumped
endif
if (H84 > 0.0) then !CementPumpToCementTank_Through67
if (H84 > 0.0) then !CementPumpToCementTank_Through67
if (j13>0) CpCoef= 1.0
MudSystem%CementTankDensityCalc= (MudSystem%CementTankDensityCalc*MudSystem%CementTankVolumeCalc+ CpCoef*MudSystem%Mp3Density*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) ) / &
(MudSystem%CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))
MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)
MudSystem%CementTankDensityCalc= (MudSystem%CementTankDensityCalc*MudSystem%CementTankVolumeCalc+ CpCoef*MudSystem%Mp3Density*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.) ) / &
(MudSystem%CementTankVolumeCalc+CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.))
MudSystem%CementTankVolumeCalc= MudSystem%CementTankVolumeCalc+ CpCoef*(PUMP(3)%Flow_Rate*MudSystem%DeltaT_Mudline/60.)
endif
!===========================================================================================================================
!===========================================================================================================================
! DUMP Path
!===========================================================================================================================
!===========================================================================================================================
! DUMP Path
MudSystem%PumpsDumpVolume= MudSystem%PumpsDumpVolume+ (jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate) *MudSystem%DeltaT_Mudline/60.
MudSystem%PumpsDumpFlowRate= jj2*(1-H82)*DumpPump1*PUMP(1)%Flow_Rate + jj12*(1-H83)*DumpPump2*PUMP(2)%Flow_Rate + jj13*(1-H84)*DumpCementPump*PUMP(3)%Flow_Rate
!write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate
!write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate
if (Hoisting%DriveType==1 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromKelly_Pump1 .or. DumpFromKelly_Pump2 .or. DumpFromKelly_Pump3)) then
!write(*,*) 'Set_FlowFromKelly(.TRUE.)'
call Activate_PumpWithKellyDisconnected()
!write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate
!write(*,*) 'PumpsDumpFlowRate=' , PumpsDumpFlowRate
CALL Set_FlowFromKelly(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before
elseif (Hoisting%DriveType==1) then
call Deactivate_PumpWithKellyDisconnected()
CALL Set_FlowFromKelly(0.0) ! .FALSE. before
!write(*,*) 'Set_FlowFromKelly(.FALSE.)'
endif
!write(*,*) 'DumpFromFillupHead_Pump1=' , DumpFromFillupHead_Pump1
if (Hoisting%DriveType==0 .and. MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromTopDrive_Pump1 .or. DumpFromTopDrive_Pump2 .or. DumpFromTopDrive_Pump3)) then
!write(*,*) 'Set_FlowFromKelly(.TRUE.)'
call Activate_PumpWithTopdriveDisconnected()
@@ -736,106 +713,85 @@ module MudSystemModule
call Deactivate_PumpWithTopdriveDisconnected()
CALL Set_FlowFromKelly(0.0) ! .FALSE. before
!write(*,*) 'Set_FlowFromKelly(.FALSE.)'
endif
if (MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then
endif
if (MudSystem%PumpsDumpFlowRate > 0.0 .and. (DumpFromFillupHead_Pump1 .or. DumpFromFillupHead_Pump2 .or. DumpFromFillupHead_Pump3)) then
!call Activate_PumpWithKellyDisconnected()
CALL Set_FlowFromFillupHead(min(MudSystem%PumpsDumpFlowRate/6.,100.)) ! .TRUE. before
else
!call Deactivate_PumpWithKellyDisconnected()
CALL Set_FlowFromFillupHead(0.0) ! .FALSE. before
endif
!####C_Program -----> DriveType =
! = 0 TopDrive_DriveType
! = 1 Kelly_DriveType
!===========================================================================================================================
!===========================================================================================================================
! ****** Calculating Maximum Working Pressure
!####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
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
endif
! Calculating Maximum Working Pressure ******
!===========================================================================================================================
!===========================================================================================================================
! ****** Blown Conditions
!G: PumpsToString Coefficient
!jJ2,Jj12,Jj13: TanksToMudPump Coefficient
!H: Pumps To Tank_Through65 or 67 Coefficient
!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
!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(*,*) '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(*,*) '21)PumpPressure1=' , PumpPressure1
WRITE (*,*) ' valve 1 ', Manifold%Valve(1)%Status
WRITE (*,*) ' valve 4 ', Manifold%Valve(4)%Status
WRITE (*,*) ' valve 6 ', Manifold%Valve(6)%Status
@@ -846,16 +802,13 @@ module MudSystemModule
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(*,*) '22)PumpPressure1=' , PumpPressure2
WRITE (*,*) ' -valve 1 ', Manifold%Valve(1)%Status
WRITE (*,*) ' -valve 4 ', Manifold%Valve(4)%Status
WRITE (*,*) ' -valve 6 ', Manifold%Valve(6)%Status
@@ -866,20 +819,16 @@ module MudSystemModule
WRITE (*,*) ' -valve 68 ', Manifold%Valve(68)%Status
WRITE (*,*) ' -valve 69 ', Manifold%Valve(69)%Status
WRITE (*,*) ' -valve 48 ', Manifold%Valve(48)%Status
!call DisplayOpenPathsWrites()
ENDIF
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
!*****************************************************************************
!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
@@ -907,15 +856,11 @@ module MudSystemModule
!write(*,*) 'Pump1BlownStarted = .FALSE.'
endif
!write(*,*) ' valve 65=' , Valve(65)%Status
!write(*,*) ' valve 65=' , Valve(65)%Status
!if(((Mp2_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_83) .or. PumpPressure2 >= MaxWorkingPressure2 &
!.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array))) ) .and. MP2_Q > 0.0 ) then
if(PumpPressure2 >= MaxWorkingPressure2 .and. MP2_Q > 0.0 ) then
write(*,*) 'mp2,if=' , PumpPressure2 , MaxWorkingPressure2 , MP2_Q
MudSystem%Pump2BlownCount = MudSystem%Pump2BlownCount + 1
!if (Pump2BlownStarted == .FALSE. ) then
@@ -937,9 +882,8 @@ module MudSystemModule
!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(((Cp_NoPath == 1 .and. ThereIsPathFrom_71_72_73_To_84) .or. PumpPressure3 >= MaxWorkingPressure3 &
!.or.(J14> 0 .and. j4==0 .and. j9==0 .and. NOT(ALLOCATED(GasPocketWeight%Array)))) .and. MP3_Q > 0.0 ) then
if(PumpPressure3 >= MaxWorkingPressure3 .and. MP3_Q > 0.0 ) then
MudSystem%Pump3BlownCount = MudSystem%Pump3BlownCount + 1
@@ -955,9 +899,7 @@ module MudSystemModule
!Pump3BlownInTimeStep = 0
!Pump3BlownStarted = .FALSE.
endif
!write(*,*) '3)PumpPressure1=' , PumpPressure1
if (PumpPressure1>= 6000.) then
MudSystem%Pump1BlownCount = MudSystem%Pump1BlownCount + 1
if(MudSystem%Pump1BlownCount >= BlownThreshold) then
@@ -998,69 +940,45 @@ module MudSystemModule
!else
!Pump3BlownInTimeStep = 0
!Pump3BlownStarted = .FALSE.
endif
! Blown Conditions ********
!===========================================================================================================================
!===========================================================================================================================
endif
! Blown Conditions ********
!===========================================================================================================================
!===========================================================================================================================
if (j9 > 0 ) then !.and. WellisNOTFull== .false.) then !WellToBellNipple
!write(*,*) 'j9 is open'
!MUD(7)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline
MUD(7)%Q= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud
if (j4 > 0) then
BellNipple_FlowCoef= 13.625/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch)
MUD(7)%Q= BellNipple_FlowCoef * MUD(7)%Q
endif
!total_annFlow= total_annFlow+(AnnulusFlowRateFinal/600.d0)
!total_DeltaVPipe= total_DeltaVPipe + DeltaVolumePipe
!write(*,*) 'total_annFlow,total_DeltaVPipe' , total_annFlow,total_DeltaVPipe
if (MUD(7)%Q < 0.0 ) MUD(7)%Q= 0.0 !.or. WellisNOTFull== .true.) MUD(7)%Q= 0.0
!!AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in
!write(*,*) 'MUD(7)%Q=' , MUD(7)%Q
!write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn
!write(*,*) 'Ann_Kick_Saved_Volume=' , Ann_Kick_Saved_Volume
sys_total_injected= sys_total_injected+ MudSystem%MudVolume_InjectedFromAnn
if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
sys_total_injected= 0.
endif
!write(*,*) 'sys_total_injected=' , sys_total_injected
!WellOutletDensity= Ann_Density%Last() ! (ppg) <<< in CirculationCodeSelect Code
!MUD(7)%Q= ( Ann_Saved_MudDischarged_Volume_Final+Ann_Kick_Saved_Volume_Final - ((Qlost/60.0d0)*DeltaT_Mudline) )*60.d0/DeltaT_Mudline
MUD(7)%Q= ( MudSystem%MudVolume_InjectedFromAnn + MudSystem%Ann_Kick_Saved_Volume )*60.d0/MudSystem%DeltaT_Mudline !Injected is referred only to Mud
if (j4 > 0) then
BellNipple_FlowCoef= 13.625/(13.625+BopStackSpecification%ChokeLineId) ! 13.625= BellNipple ID (inch)
MUD(7)%Q= BellNipple_FlowCoef * MUD(7)%Q
endif
!total_annFlow= total_annFlow+(AnnulusFlowRateFinal/600.d0)
!total_DeltaVPipe= total_DeltaVPipe + DeltaVolumePipe
!write(*,*) 'total_annFlow,total_DeltaVPipe' , total_annFlow,total_DeltaVPipe
if (MUD(7)%Q < 0.0 ) MUD(7)%Q= 0.0 !.or. WellisNOTFull== .true.) MUD(7)%Q= 0.0
!!AnnulusFlowRateFinal: flow from string mud , DeltaVolumeOp: due to trip in
!write(*,*) 'MUD(7)%Q=' , MUD(7)%Q
!write(*,*) 'MudSystem%MudVolume_InjectedFromAnn-WellToBellNipple=' , MudSystem%MudVolume_InjectedFromAnn
!write(*,*) 'Ann_Kick_Saved_Volume=' , Ann_Kick_Saved_Volume
sys_total_injected= sys_total_injected+ MudSystem%MudVolume_InjectedFromAnn
if (ChokeControlPanel%ChokePanelStrokeResetSwitch == 1) then
sys_total_injected= 0.
endif
!write(*,*) 'sys_total_injected=' , sys_total_injected
!WellOutletDensity= Ann_Density%Last() ! (ppg) <<< in CirculationCodeSelect Code
if ((MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)) /= 0.0) then
MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%WellOutletDensity*(MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline))
else
MudSystem%BellNippleDensity= 0.0
endif
!IF (WellisNOTFull== .false.) THEN ! well must be full to do this order
MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)
MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(7)%Q/60.)*MudSystem%DeltaT_Mudline)
!ENDIF
VolumeToBellNipple= VolumeToBellNipple + MudSystem%BellNippleVolume
!write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple
!write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q
VolumeToBellNipple= VolumeToBellNipple + MudSystem%BellNippleVolume
!write(*,*) 'VolumeToBellNipple*****=' , VolumeToBellNipple
!write(*,*) 'BellNippleVolume in j9=' , BellNippleVolume , MUD(7)%Q
endif
if (j9 == 0 ) then !.or. WellisNOTFull== .true.) then
@@ -1073,12 +991,8 @@ module MudSystemModule
else
MudSystem%WellToPitsOpen= .false.
endif
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
if (j10 > 0) then !MudBucketToBellNipple
!write(*,*) 'j10 is open'
!MudBucketVolume= 0.
@@ -1088,182 +1002,109 @@ module MudSystemModule
MudSystem%BellNippleDensity= MudSystem%ActiveTankDensity
MudSystem%MudBucketVolume= 0.
endif
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
if (j6 > 0) then !TripTankToActiveTank And BellNipple
!write(*,*) 'j6 is open'
!write(*,*) 'active by j6'
MUD(6)%Q= 300. ! constant flow rate(gpm)
MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc - ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
!write(*,*) 'ActiveTankVolume before=', ActiveTankVolume
if (j6 == 1 .and. D71==1) then
!write(*,*) 'add to active'
MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
!write(*,*) 'ActiveTankVolume after=', ActiveTankVolume
endif
if (j6 == 1 .and. D80==1) then
MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
endif
if (j6 == 2) then
MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc - ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
!write(*,*) 'ActiveTankVolume before=', ActiveTankVolume
if (j6 == 1 .and. D71==1) then
!write(*,*) 'add to active'
MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
!write(*,*) 'ActiveTankVolume after=', ActiveTankVolume
endif
if (j6 == 1 .and. D80==1) then
MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
endif
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
endif
MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
!if ActiveTankVolume is higher, excess amount is dumped
if (j6 == 2) then
MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%BellNippleDensity= ((MudSystem%BellNippleDensity*MudSystem%BellNippleVolume)+(MudSystem%TripTankDensityCalc*(0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%BellNippleVolume+((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
MudSystem%BellNippleVolume= MudSystem%BellNippleVolume+ ((0.5*MUD(6)%Q/60.)*MudSystem%DeltaT_Mudline)
endif
MudSystem%ActiveTankVolume=min(MudSystem%ActiveTankVolume , MudProperties%ActiveTotalTankCapacityGal-MudProperties%ActiveSettledContentsGal)
!if ActiveTankVolume is higher, excess amount is dumped
endif
if (j6 == 0) then
MUD(6)%Q=0.0
endif
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
!===========================================================================================================================
CALL Set_FlowFromReturnLine(.false.)
if (j3 > 0) then !BellNippleToPits-FullWell - must be after **WellToBellNipple(j9)**
!write(*,*) 'j3 is open'
!write(*,*) 'active by j3'
!BellNipple flow rate= sum flow rate (well+ mudbucket+ triptank)
!Well to BellNipple: BellNippleVolume
!MudBucket to BellNipple: BellNippleVolume
!TripTnak to BellNipple: BellNippleVolume
MUD(3)%Q = (MudSystem%BellNippleVolume/MudSystem%DeltaT_Mudline)*60.d0 ! (gpm)
!write(*,*) 'BellNippleVolume in j3 =' , BellNippleVolume
!write(*,*) 'MUD(3)%Q =' , MUD(3)%Q
call Set_FlowRate(real(100.*min(MUD(3)%Q,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8)) ! for unity display
unityreturn = real(100.*min(MUD(3)%Q,MudSystem%PedalMeter)/MudSystem%PedalMeter, 8)
!write(*,*) 'unity return=' , real(100.*min(MUD(3)%Q,PedalMeter)/PedalMeter, 8)
if (MUD(3)%Q > MudSystem%PedalMeter .and. B78==0) then
MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume + ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline - (MudSystem%PedalMeter/60.)*MudSystem%DeltaT_Mudline)
!BellNippleDumpRate= MUD(3)%Q - PedalMeter
CALL Set_FlowFromReturnLine(.TRUE.) ! for unity display
endif
!VolumeToActive = VolumeToActive + BellNippleVolume
!write(*,*) 'VolumeToActive*******=' , VolumeToActive
!VolumeToActive = VolumeToActive + BellNippleVolume
!write(*,*) 'VolumeToActive*******=' , VolumeToActive
active_before= MudSystem%ActiveTankVolume
MudSystem%BellNippleVolume= MudSystem%BellNippleVolume- ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline) ! to be 0.
if ( MudSystem%BellNippleDensity > 1.0) then
if (j3 == 1 .and. B71==1) then !(volumes in galon)
MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter)
!write(*,*) 'MUD(3)%Q=' , MUD(3)%Q
IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)
!write(*,*) 'active increase bell 1=' , ((MUD(3)%Q/60.)*DeltaT_Mudline)
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg
!write(*,*) 'active increase bell 2=' , ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline)
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
!write(*,*) 'active increase bell 3=' , ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline)
ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN
!write(*,*) ' Auto true 3'
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
!write(*,*) 'active increase bell 4=' , ((MUD(3)%Q/60.d0)*DeltaT_Mudline)
ENDIF
IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
MudSystem%ActiveTankDensity= ((MudSystem%ActiveTankDensity*MudSystem%ActiveTankVolume)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%ActiveTankVolume+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline)
!write(*,*) 'active increase bell 1=' , ((MUD(3)%Q/60.)*DeltaT_Mudline)
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed cutting density = 20.8 ppg
!write(*,*) 'active increase bell 2=' , ((20.8d0-BellNippleDensity)/(20.8d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline)
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
!write(*,*) 'active increase bell 3=' , ((2.d0-BellNippleDensity)/(2.d0-ActiveTankDensity))*((MUD(3)%Q/60.d0)*DeltaT_Mudline)
ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN
!write(*,*) ' Auto true 3'
MudSystem%ActiveTankVolume= MudSystem%ActiveTankVolume+ ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
!write(*,*) 'active increase bell 4=' , ((MUD(3)%Q/60.d0)*DeltaT_Mudline)
ENDIF
endif
if (j3 == 1 .and. B77==1) then
MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter)
IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
if (j3 == 1 .and. B77==1) then
MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter)
IF (MudProperties%ActiveAutoDensity == .FALSE.) THEN
MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%BellNippleDensity*(MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))/(MudSystem%TripTankVolumeCalc+((MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline))
MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ (MUD(3)%Q/60.)*MudSystem%DeltaT_Mudline
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity > MudSystem%ActiveTankDensity) THEN
AddedVolumeToTank= ((20.8d0-MudSystem%BellNippleDensity)/(20.8d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN
ELSEIF (MudProperties%ActiveAutoDensity .and. MudSystem%BellNippleDensity < 5.0) THEN
AddedVolumeToTank= ((2.d0-MudSystem%BellNippleDensity)/(2.d0-MudSystem%ActiveTankDensity))*((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline) ! asumed GAS density = 2.0 ppg
MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN
ELSEIF (MudProperties%ActiveAutoDensity .and. 5.0 < MudSystem%BellNippleDensity .and. MudSystem%BellNippleDensity <= MudSystem%ActiveTankDensity) THEN
AddedVolumeToTank= ((MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline)
MudSystem%TripTankDensityCalc= ((MudSystem%TripTankDensityCalc*MudSystem%TripTankVolumeCalc)+(MudSystem%ActiveTankDensity*AddedVolumeToTank))/(MudSystem%TripTankVolumeCalc+AddedVolumeToTank)
MudSystem%TripTankVolumeCalc= MudSystem%TripTankVolumeCalc+ AddedVolumeToTank
ENDIF
endif
if (j3 == 1 .and. B78==1) then
MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline
!BellNippleDumpRate= MUD(3)%Q
endif
ENDIF
endif
if (j3 == 1 .and. B78==1) then
MudSystem%BellNippleDumpVolume= MudSystem%BellNippleDumpVolume+ (MUD(3)%Q/60.d0)*MudSystem%DeltaT_Mudline
!BellNippleDumpRate= MUD(3)%Q
endif
if (j3 == 2) then !78 is not allowded in this position
MUD(3)%Q = min(MUD(3)%Q , MudSystem%PedalMeter)
@@ -2191,7 +2032,7 @@ module MudSystemModule
MPumps%Total_Stroke_Counter_For_Plot = MPumps%Total_Stroke_Counter_For_Plot + ((DataDisplayConsole%MP1SPMGauge + DataDisplayConsole%MP2SPMGauge) / 60.0) * MudSystem%DeltaT_Mudline
CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot))
! CALL SetTotalStrokes(INT(MPumps%Total_Stroke_Counter_For_Plot))
DataDisplayConsole%TotalStrokeCounter= real(nint(MudSystem%TotalStrokesPump1+MudSystem%TotalStrokesPump2)) !for drilling data display