|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- module BOP
- contains
-
- subroutine BopStack_Step
- USE VARIABLES
- USE CBopControlPanelVariables
- USE TD_GeneralData
- ! USE CEquipmentsConstants
- use CSounds
- implicit none
-
-
- BOP_timeCounter= BOP_timeCounter + 1
-
- write(*,*) 'BOP_timeCounter=' , BOP_timeCounter
-
- AirSupplyPressureGauge= (1 - AirSupplyPressureGaugeMalf)* (1 - RigAirMalf) *120. !psi
-
-
- if (pram_reg < 2300.) then
- ShearIsNotAllowed= 1
- else
- 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):==
- ODDrillpipe_inAnnular= TD_AnnularPreventerDiam * 12.0 ! ft to inch
- ODDrillpipe_inPipeRam1= TD_UpperRamDiam * 12.0
- ODDrillpipe_inShearRam= TD_BlindRamDiam * 12.0
- ODDrillpipe_inPipeRam2= TD_LowerRamDiam * 12.0
-
-
-
- !IDshearBopFinal
- !IDPipeRam1Final
- !IDPipeRam2Final
- !IDAnnularFinal
-
- OpenArea_shearBop= PI*(IDshearBopFinal**2-ODDrillpipe_inShearRam**2)/4.0d0 !D(in), AREA(in^2)
- OpenArea_PipeRam1= PI*(IDPipeRam1Final**2-ODDrillpipe_inPipeRam1**2)/4.0d0 !D(in), AREA(in^2)
- OpenArea_PipeRam2= PI*(IDPipeRam2Final**2-ODDrillpipe_inPipeRam2**2)/4.0d0 !D(in), AREA(in^2)
- OpenArea_Annular= PI*(IDAnnularFinal**2-ODDrillpipe_inAnnular**2)/4.0d0 !D(in), AREA(in^2)
-
- MinimumOpenArea_InBOP= min(OpenArea_shearBop,OpenArea_PipeRam1,OpenArea_PipeRam2,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==========
- WellBorePressure=5000.
- if (ODDrillpipe_inAnnular>0.) then
- if (ODDrillpipe_inAnnular>0. .and. ODDrillpipe_inAnnular<=1.99) then
- acoef=-0.2673
- bcoef=994.3
- const=77
- elseif (ODDrillpipe_inAnnular>1.99 .and. ODDrillpipe_inAnnular<=2.375) then
- acoef=-0.2539
- bcoef=994.3
- const=73.15
- elseif (ODDrillpipe_inAnnular>2.375 .and. ODDrillpipe_inAnnular<=2.875) then
- acoef=-0.2005
- bcoef=745.9
- const=57.75
- elseif (ODDrillpipe_inAnnular>2.875 .and. ODDrillpipe_inAnnular<=3.5) then
- acoef=-0.1871
- bcoef=696.1
- const=53.9
- elseif (ODDrillpipe_inAnnular>3.5 .and. ODDrillpipe_inAnnular<=5) then
- acoef=-0.1733
- bcoef=647
- const=50
- elseif (ODDrillpipe_inAnnular>5 .and. ODDrillpipe_inAnnular<=10) then
- acoef=-0.1604
- bcoef=596.7
- const=46.2
- endif
- AnnularSealingPressure= max((acoef*WellBorePressure+bcoef), const) !(psi)
- else !CSO(COMPLETE SHUT OFF) ODDrillpipe_inAnnular=0
- AnnularSealingPressure= 1150. !(psi)
- endif
-
- !=====================================================================
- ! BYPASS POSITION
- !=====================================================================
- if(ByePassValve == -1.0 .and. AirMasterValve==1) then
- ByPassOld= -1.0
- !write(*,*) 'ByePassValve to -1' ,ByePassValve
- elseif(ByePassValve == 1.0 .and. AirMasterValve==1) then
- ByPassOld= 1.0
- !write(*,*) 'ByePassValve to 1=' ,ByePassValve
- endif
- !write(*,*) 'ByePassValve,ByPassOld=' ,ByePassValve,ByPassOld
- !=====================================================================
- !WRITE(*,*) 'AnnularRegulatorSetControl====' , AnnularRegulatorSetControl
- Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
- if (Annular_closed==1) then
- if (FirstSet==1) then ! code start
- Pannular_reg= Pannular_regset
- endif
-
- if (FirstSet==0) then ! durig run, but annular is not closing or opening
- Pannular_reg= min(p_acc,Pannular_regset)
- endif
- endif
-
- !===================================================================
- ! Annular Preventer Pressure Rise On Tooljoint
- !===================================================================
- if ( Annular_Situation_forTD == 1 .and. TD_AnnularFillingFinal==0.0 ) then ! Annular_Situation_forTD= 1 ! closed - for TD code
- AnnPressureRise= .true.
- elseif ( Annular_Situation_forTD == 0 ) then
- AnnPressureRise= .false.
- endif
-
- if (AnnPressureRise == .true.) then
- Pannular_reg= Pannular_reg + 200. * TD_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 (FirstSet== 1) then
- !new= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.)
- CALL Pannular_regDelay%AddToFirst( (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.) )
- CALL Pannular_regDelay%Remove(Pannular_regDelay%Length())
- AnnularPressureGauge= Pannular_regDelay%Last()
- !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.)
- !write(*,*) 'set 1' , AnnularPressureGauge
- else !FirstSet== 0
- !new= (1 - AnnularPressureGaugeMalf) * Pannular_reg
-
- CALL Pannular_regDelay%AddToFirst( (1 - AnnularPressureGaugeMalf) * Pannular_reg)
- CALL Pannular_regDelay%Remove(Pannular_regDelay%Length())
- AnnularPressureGauge= Pannular_regDelay%Last()
- !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * Pannular_reg
- !write(*,*) 'set 0' , AnnularPressureGauge
- endif
-
- !===================================================
- ! AIR OPERATED PUMP CODE- START
- !===================================================
- if (p_acc<AIR_PUMPON .and. airp_switch==0) then
- airp_switch=1
- endif
-
- if (p_acc>AIR_PUMPOFF .and. airp_switch==1) then
- airp_switch=0
- call SetSoundKoomeyAirPump(airp_switch)
- endif
-
- if (p_acc<ELECTRIC_PUMPON .and. elecp_switch==0) then
- elecp_switch=1
- endif
-
- if (p_acc>ELECTRIC_PUMPOFF .and. elecp_switch==1) then
- elecp_switch=0
- endif
-
- !write(*,*) 'airp_switch,elecp_switch=' , airp_switch,elecp_switch
- !================CHARGING BOTTLES=======================
- if (airp_switch==1 .or. elecp_switch==1) then
- if (Annular_closed==1 .and. 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 (p_acc>acc_ChargedPressure) then
- p_acc=acc_ChargedPressure
- if (AnnularLeakMalf== 0) then
- !finished_Annular=1
- RAM(1)%Bottles_Charged_MalfActive= .false.
- else
- finished_Annular=0
- RAM(1)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
- if (UpperRamsLeakMalf== 0) then
- !finished_pipe1=1
- RAM(2)%Bottles_Charged_MalfActive= .false.
- else
- finished_pipe1=0
- RAM(2)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
-
- if (LowerRamsLeakMalf== 0) then
- !finished_pipe2=1
- RAM(3)%Bottles_Charged_MalfActive= .false.
- else
- finished_pipe2=0
- RAM(3)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
- if (MiddleRamsLeakMalf== 0) then
- !finished_shear=1
- RAM(4)%Bottles_Charged_MalfActive= .false.
- else
- finished_shear=0
- RAM(4)%Bottles_Charged_MalfActive= .true.
- !fvr=fvr-2.5
- endif
-
- finished_KillLine=1
- finished_ChokeLine=1
-
-
- if (AnnularLeakMalf== 0 .and. UpperRamsLeakMalf== 0 .and. LowerRamsLeakMalf== 0 .and. MiddleRamsLeakMalf== 0) then
- elecp_switch=0
- airp_switch=0
- endif
- endif
- endif
- endif
-
- !=======================================================
- if (elecp_switch==1 .and. AccPupmsFailMalf==0) then !on position
- deltav_elecp=QELECTRIC_PUMP*DeltaT_BOP/60. !QELECTRIC_PUMP(gpm), deltav_elecp(gal), DeltaT_BOP(0.1 sec)
- SoundKoomeyElectricPump= .True.
- else
- deltav_elecp=0
- SoundKoomeyElectricPump= .false.
- endif
-
- !call SetSoundKoomeyElectricPump(SoundKoomeyElectricPump)
- if (airp_switch==1 .and. 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 (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(ByPassOld== -1.0) then ! (OPEN POSITION)
- !old=pram_reg
- !new=p_acc- MAXVAL(RAM%loss_before)
- !difference= new-old
- PressureDifference= p_acc- MAXVAL(RAM%loss_before) - pram_reg
- if (ABS(PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 300. psi
- pram_reg= pram_reg + (PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
- else
- pram_reg= p_acc- MAXVAL(RAM%loss_before) ! mishe khate paeen ye shart gozasht ke pacc=3000 shod, in adad dige kam nashe
- endif
-
- elseif (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
- PressureDifference= prams_regset - pram_reg
- !write(*,*) 'PressureDifference, prams_regset , pram_reg=' , PressureDifference, prams_regset , pram_reg
-
- if (ABS(PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 200. ! psi in starup
- pram_reg= pram_reg + (PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. in startup
- else
- pram_reg= prams_regset
- endif
- !write(*,*) 'pram_reg=' , pram_reg
-
- !endif ! if (RamsFirstSet==1) then
- endif
-
-
- endif
-
- MiddleRamsStatus = IDshearBop
- UpperRamsStatus = IDPipeRam1
- LowerRamsStatus = IDPipeRam2
- AnnularStatus = IDAnnular
- AccumulatorPressureGauge = (1 - AccumulatorPressureGaugeMalf) * p_acc
- ManifoldPressureGauge= (1 - ManifoldPressureGaugeMalf) * 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
|