|
- module BOP
- contains
-
- subroutine BopStack_Init
- call BOP_StartUp
- end subroutine BopStack_Init
- subroutine BopStack_Step
- USE VARIABLES
- USE CBopControlPanelVariables
- USE TD_GeneralData
- ! USE CEquipmentsConstants
- use CSounds
- implicit none
-
-
- BopStackInput%BOP_timeCounter= BopStackInput%BOP_timeCounter + 1
-
- write(*,*) 'BOP_timeCounter=' , BopStackInput%BOP_timeCounter
-
- BopControlPanel%AirSupplyPressureGauge= (1 - BopStackAcc%AirSupplyPressureGaugeMalf)* (1 - BopStackAcc%RigAirMalf) *120. !psi
-
-
- if (BopStackAcc%pram_reg < 2300.) then
- ShearRam%ShearIsNotAllowed= 1
- else
- ShearRam%ShearIsNotAllowed= 0
- endif
-
- !write(*,*) 'ShearIsNotAllowed=' , ShearIsNotAllowed
-
-
- !TD_AnnularFillingFinal ! (0.0 to 1.0) percentage filled by tool joint
-
-
- !======================================================================
- ! MAIN BODY OF PROGRAM
- ! PURPOSE: BOP Control
- !======================================================================
-
-
- !=== Instantaneous Pipe Diameters in Each Ram (Input from TD Module):==
- Annular%ODDrillpipe_inAnnular= TD_BOP%AnnularPreventerDiam * 12.0 ! ft to inch
- PipeRam1%ODDrillpipe_in= TD_BOP%UpperRamDiam * 12.0
- ShearRam%ODDrillpipe_inShearRam= TD_BOP%BlindRamDiam * 12.0
- PipeRam2%ODDrillpipe_in= TD_BOP%LowerRamDiam * 12.0
-
-
-
- !IDshearBopFinal
- !IDPipeRam1Final
- !IDPipeRam2Final
- !IDAnnularFinal
-
- ShearRam%OpenArea_shearBop= PI*(ShearRam%IDshearBopFinal**2-ShearRam%ODDrillpipe_inShearRam**2)/4.0d0 !D(in), AREA(in^2)
- ShearRam%OpenArea_PipeRam1= PI*(ShearRam%IDPipeRam1Final**2-PipeRam1%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2)
- ShearRam%OpenArea_PipeRam2= PI*(ShearRam%IDPipeRam2Final**2-PipeRam2%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2)
- ShearRam%OpenArea_Annular= PI*(ShearRam%IDAnnularFinal**2-Annular%ODDrillpipe_inAnnular**2)/4.0d0 !D(in), AREA(in^2)
-
- ShearRam%MinimumOpenArea_InBOP= min(ShearRam%OpenArea_shearBop,ShearRam%OpenArea_PipeRam1,ShearRam%OpenArea_PipeRam2,ShearRam%OpenArea_Annular)
-
- !TD_BOPConnectionPossibility(j) = 0 or 1
-
- !!!AnnularPreventerDiam = TD_BOPConnectionPossibility(1) >> used in Annular code
- !!!UpperRamDiam = TD_BOPConnectionPossibility(2) >> used in PipeRam1 code
- !!!BlindRamDiam = TD_BOPConnectionPossibility(3) >> used in ShearRam code
- !!!LowerRamDiam = TD_BOPConnectionPossibility(4) >> used in PipeRam2 code
-
- !=====================================================================
- !============SEALING PRESSURES TO BE SET IN ANNULAR REGULATOR==========
- AnnularComputational%WellBorePressure=5000.
- if (Annular%ODDrillpipe_inAnnular>0.) then
- if (Annular%ODDrillpipe_inAnnular>0. .and. Annular%ODDrillpipe_inAnnular<=1.99) then
- AnnularComputational%acoef=-0.2673
- AnnularComputational%Bcoef=994.3
- AnnularComputational%const=77
- elseif (Annular%ODDrillpipe_inAnnular>1.99 .and. Annular%ODDrillpipe_inAnnular<=2.375) then
- AnnularComputational%acoef=-0.2539
- AnnularComputational%Bcoef=994.3
- AnnularComputational%const=73.15
- elseif (Annular%ODDrillpipe_inAnnular>2.375 .and. Annular%ODDrillpipe_inAnnular<=2.875) then
- AnnularComputational%acoef=-0.2005
- AnnularComputational%Bcoef=745.9
- AnnularComputational%const=57.75
- elseif (Annular%ODDrillpipe_inAnnular>2.875 .and. Annular%ODDrillpipe_inAnnular<=3.5) then
- AnnularComputational%acoef=-0.1871
- AnnularComputational%Bcoef=696.1
- AnnularComputational%const=53.9
- elseif (Annular%ODDrillpipe_inAnnular>3.5 .and. Annular%ODDrillpipe_inAnnular<=5) then
- AnnularComputational%acoef=-0.1733
- AnnularComputational%Bcoef=647
- AnnularComputational%const=50
- elseif (Annular%ODDrillpipe_inAnnular>5 .and. Annular%ODDrillpipe_inAnnular<=10) then
- AnnularComputational%acoef=-0.1604
- AnnularComputational%Bcoef=596.7
- AnnularComputational%const=46.2
- endif
- AnnularComputational%AnnularSealingPressure= max((AnnularComputational%acoef*AnnularComputational%WellBorePressure+AnnularComputational%Bcoef), AnnularComputational%const) !(psi)
- else !CSO(COMPLETE SHUT OFF) ODDrillpipe_inAnnular=0
- AnnularComputational%AnnularSealingPressure= 1150. !(psi)
- endif
-
- !=====================================================================
- ! BYPASS POSITION
- !=====================================================================
- if(BopControlPanel%ByePassValve == -1.0 .and. BopControlPanel%AirMasterValve==1) then
- BopStackAcc%ByPassOld= -1.0
- !write(*,*) 'ByePassValve to -1' ,ByePassValve
- elseif(BopControlPanel%ByePassValve == 1.0 .and. BopControlPanel%AirMasterValve==1) then
- BopStackAcc%ByPassOld= 1.0
- !write(*,*) 'ByePassValve to 1=' ,ByePassValve
- endif
- !write(*,*) 'ByePassValve,ByPassOld=' ,ByePassValve,ByPassOld
- !=====================================================================
- !WRITE(*,*) 'AnnularRegulatorSetControl====' , AnnularRegulatorSetControl
- Annular%Pannular_regset=min(BopControlPanel%AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
- if (Annular%Annular_closed==1) then
- if (Annular%FirstSet==1) then ! code start
- Annular%Pannular_reg= Annular%Pannular_regset
- endif
-
- if (Annular%FirstSet==0) then ! durig run, but annular is not closing or opening
- Annular%Pannular_reg= min(RamLine%P_ACC,Annular%Pannular_regset)
- endif
- endif
-
- !===================================================================
- ! Annular Preventer Pressure Rise On Tooljoint
- !===================================================================
- if ( Annular%Annular_Situation_forTD == 1 .and. TD_BOP%AnnularFillingFinal==0.0 ) then ! Annular_Situation_forTD= 1 ! closed - for TD code
- AnnularComputational%AnnPressureRise= .true.
- elseif ( Annular%Annular_Situation_forTD == 0 ) then
- AnnularComputational%AnnPressureRise= .false.
- endif
-
- if (AnnularComputational%AnnPressureRise == .true.) then
- Annular%Pannular_reg= Annular%Pannular_reg + 200. * TD_BOP%AnnularFillingFinal ! 200 psi pressure rise when 100% of AnnPreventer is filled by tool joint
- !TD_AnnularFillingFinal ! (0.0 to 1.0) percentage filled by tool joint
- endif
- !===================================================================
- if (Annular%FirstSet== 1) then
- !new= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.)
- CALL AnnularComputational%Pannular_regDelay%AddToFirst( (1 - Annular%AnnularPressureGaugeMalf) * min(BopControlPanel%AnnularRegulatorSetControl,1700.) )
- CALL AnnularComputational%Pannular_regDelay%Remove(AnnularComputational%Pannular_regDelay%Length())
- BopControlPanel%AnnularPressureGauge= AnnularComputational%Pannular_regDelay%Last()
- !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.)
- !write(*,*) 'set 1' , AnnularPressureGauge
- else !FirstSet== 0
- !new= (1 - AnnularPressureGaugeMalf) * Pannular_reg
-
- CALL AnnularComputational%Pannular_regDelay%AddToFirst( (1 - Annular%AnnularPressureGaugeMalf) * Annular%Pannular_reg)
- CALL AnnularComputational%Pannular_regDelay%Remove(AnnularComputational%Pannular_regDelay%Length())
- BopControlPanel%AnnularPressureGauge= AnnularComputational%Pannular_regDelay%Last()
- !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * Pannular_reg
- !write(*,*) 'set 0' , AnnularPressureGauge
- endif
-
- !===================================================
- ! AIR OPERATED PUMP CODE- START
- !===================================================
- if (RamLine%P_ACC<Pumps%AIR_ON .and. RamLine%AIRP_SWITCH==0) then
- RamLine%AIRP_SWITCH=1
- endif
-
- if (RamLine%P_ACC>Pumps%AIR_OFF .and. RamLine%AIRP_SWITCH==1) then
- RamLine%AIRP_SWITCH=0
- call SetSoundKoomeyAirPump(RamLine%AIRP_SWITCH)
- endif
-
- if (RamLine%P_ACC<Pumps%ELECTRIC_ON .and. RamLine%ELECP_SWITCH==0) then
- RamLine%ELECP_SWITCH=1
- endif
-
- if (RamLine%P_ACC>Pumps%ELECTRIC_OFF .and. RamLine%ELECP_SWITCH==1) then
- RamLine%ELECP_SWITCH=0
- endif
-
- !write(*,*) 'airp_switch,elecp_switch=' , airp_switch,elecp_switch
- !================CHARGING BOTTLES=======================
- if (RamLine%AIRP_SWITCH==1 .or. RamLine%ELECP_SWITCH==1) then
- if (Annular%Annular_closed==1 .and. RamLine%ShearBop_closed==1 .and. PipeRam1%closed==1 .and. PipeRam2%closed==1 .and. ChokeLine%closed==1 .and. KillLine%closed==1) then
- call pumps_charge_bottle()
- ! increases volume and pressure in the bottles
- if (RamLine%P_ACC>BopStackAcc%acc_ChargedPressure) then
- RamLine%P_ACC=BopStackAcc%acc_ChargedPressure
- if (Annular%AnnularLeakMalf== 0) then
- !finished_Annular=1
- RAM(1)%Bottles_Charged_MalfActive= .false.
- else
- Annular%finished_Annular=0
- RAM(1)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
- if (PipeRam1%UpperRamsLeakMalf== 0) then
- !finished_pipe1=1
- RAM(2)%Bottles_Charged_MalfActive= .false.
- else
- PipeRam1%finished=0
- RAM(2)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
-
- if (PipeRam2%LowerRamsLeakMalf== 0) then
- !finished_pipe2=1
- RAM(3)%Bottles_Charged_MalfActive= .false.
- else
- PipeRam2%finished=0
- RAM(3)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
- if (ShearRam%MiddleRamsLeakMalf== 0) then
- !finished_shear=1
- RAM(4)%Bottles_Charged_MalfActive= .false.
- else
- RamLine%FINISHED_shear=0
- RAM(4)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
-
- KillLine%finished=1
- ChokeLine%finished=1
-
-
- if (Annular%AnnularLeakMalf== 0 .and. PipeRam1%UpperRamsLeakMalf== 0 .and. PipeRam2%LowerRamsLeakMalf== 0 .and. ShearRam%MiddleRamsLeakMalf== 0) then
- RamLine%ELECP_SWITCH=0
- RamLine%AIRP_SWITCH=0
- endif
- endif
- endif
- endif
-
- !=======================================================
- if (RamLine%ELECP_SWITCH==1 .and. BopStackAcc%AccPupmsFailMalf==0) then !on position
- Pumps%DELTAV_ELECP=Pumps%QELECTRIC*RamLine%DeltaT_BOP/60. !QELECTRIC_PUMP(gpm), deltav_elecp(gal), DeltaT_BOP(0.1 sec)
- Pumps%SoundKoomeyElectric= .True.
- else
- Pumps%DELTAV_ELECP=0
- Pumps%SoundKoomeyElectric= .false.
- endif
-
- !call SetSoundKoomeyElectricPump(SoundKoomeyElectricPump)
- if (RamLine%AIRP_SWITCH==1 .and. BopStackAcc%AccPupmsFailMalf==0) then !on position
- call airpump_code() !ramtype=2
- end if ! if (airp_switch==1) then !on position
-
-
- !===============AIR OPERATED PUMP CODE- END================
- if (RamLine%ShearBop_closed==1 .and. PipeRam1%closed==1 .and. PipeRam2%closed==1 .and. ChokeLine%closed==1 .and. KillLine%closed==1) then
-
- !write(*,*) ' All Rams are closed'
-
- if(BopStackAcc%ByPassOld== -1.0) then ! (OPEN POSITION)
- !old=pram_reg
- !new=p_acc- MAXVAL(RAM%loss_before)
- !difference= new-old
- BopStackAcc%PressureDifference= RamLine%P_ACC- MAXVAL(RAM%loss_before) - BopStackAcc%pram_reg
- if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 300. psi
- BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
- else
- BopStackAcc%pram_reg= RamLine%P_ACC- MAXVAL(RAM%loss_before) ! mishe khate paeen ye shart gozasht ke pacc=3000 shod, in adad dige kam nashe
- endif
-
- elseif (BopStackAcc%ByPassOld== 1.0) then ! (CLOSE POSITION)
- !pram_reg= prams_regset
- !if (RamsFirstSet==1) then
- !write(*,*) 'bypass CLOSE POSITION'
- !old=pram_reg
- !new=prams_regset
- !difference= new-old
- BopStackAcc%PressureDifference= BopStackAcc%PRAMS_REGSET - BopStackAcc%pram_reg
- !write(*,*) 'PressureDifference, prams_regset , pram_reg=' , PressureDifference, prams_regset , pram_reg
-
- if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 200. ! psi in starup
- BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. in startup
- else
- BopStackAcc%pram_reg= BopStackAcc%PRAMS_REGSET
- endif
- !write(*,*) 'pram_reg=' , pram_reg
-
- !endif ! if (RamsFirstSet==1) then
- endif
-
-
- endif
-
- BopControlPanel%MiddleRamsStatus = ShearRam%IDshearBop
- BopControlPanel%UpperRamsStatus = PipeRam1%ID
- BopControlPanel%LowerRamsStatus = PipeRam2%ID
- BopControlPanel%AnnularStatus = Annular%IDAnnular
- BopControlPanel%AccumulatorPressureGauge = (1 - BopStackAcc%AccumulatorPressureGaugeMalf) * RamLine%P_ACC
- BopControlPanel%ManifoldPressureGauge= (1 - BopStackAcc%ManifoldPressureGaugeMalf) * BopStackAcc%pram_reg
- !AnnularPressureGauge=Pannular_reg
- !
- ! WRITE(60,60) RAM(2)%time,RAM(2)%Q,RAM(2)%vdis_tot,p_acc, &
- ! pram_reg,Pannular_reg,RAM(2)%p_bop,IDshearBop, &
- ! IDPipeRam1,IDPipeRam2,IDAnnular
- !60 FORMAT(11(f18.5))
- !WRITE(*,*) 'IDAnnular=' , IDAnnular
- !write(*,*) 'elecp_switch=' , elecp_switch
- !call sleepqq(100)
- end subroutine BopStack_Step
-
- end module BOP
|