Simulation Core
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

302 рядки
16 KiB

  1. module BOP
  2. contains
  3. subroutine BopStack_Init
  4. call BOP_StartUp
  5. end subroutine BopStack_Init
  6. subroutine BopStack_Step
  7. USE VARIABLES
  8. USE CBopControlPanelVariables
  9. USE TD_GeneralData
  10. ! USE CEquipmentsConstants
  11. use CSounds
  12. implicit none
  13. BopStackInput%BOP_timeCounter= BopStackInput%BOP_timeCounter + 1
  14. write(*,*) 'BOP_timeCounter=' , BopStackInput%BOP_timeCounter
  15. BopControlPanel%AirSupplyPressureGauge= (1 - BopStackAcc%AirSupplyPressureGaugeMalf)* (1 - BopStackAcc%RigAirMalf) *120. !psi
  16. if (BopStackAcc%pram_reg < 2300.) then
  17. ShearRam%ShearIsNotAllowed= 1
  18. else
  19. ShearRam%ShearIsNotAllowed= 0
  20. endif
  21. !write(*,*) 'ShearIsNotAllowed=' , ShearIsNotAllowed
  22. !TD_AnnularFillingFinal ! (0.0 to 1.0) percentage filled by tool joint
  23. !======================================================================
  24. ! MAIN BODY OF PROGRAM
  25. ! PURPOSE: BOP Control
  26. !======================================================================
  27. !=== Instantaneous Pipe Diameters in Each Ram (Input from TD Module):==
  28. Annular%ODDrillpipe_inAnnular= TD_BOP%AnnularPreventerDiam * 12.0 ! ft to inch
  29. PipeRam1%ODDrillpipe_in= TD_BOP%UpperRamDiam * 12.0
  30. ShearRam%ODDrillpipe_inShearRam= TD_BOP%BlindRamDiam * 12.0
  31. PipeRam2%ODDrillpipe_in= TD_BOP%LowerRamDiam * 12.0
  32. !IDshearBopFinal
  33. !IDPipeRam1Final
  34. !IDPipeRam2Final
  35. !IDAnnularFinal
  36. ShearRam%OpenArea_shearBop= PI*(ShearRam%IDshearBopFinal**2-ShearRam%ODDrillpipe_inShearRam**2)/4.0d0 !D(in), AREA(in^2)
  37. ShearRam%OpenArea_PipeRam1= PI*(ShearRam%IDPipeRam1Final**2-PipeRam1%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2)
  38. ShearRam%OpenArea_PipeRam2= PI*(ShearRam%IDPipeRam2Final**2-PipeRam2%ODDrillpipe_in**2)/4.0d0 !D(in), AREA(in^2)
  39. ShearRam%OpenArea_Annular= PI*(ShearRam%IDAnnularFinal**2-Annular%ODDrillpipe_inAnnular**2)/4.0d0 !D(in), AREA(in^2)
  40. ShearRam%MinimumOpenArea_InBOP= min(ShearRam%OpenArea_shearBop,ShearRam%OpenArea_PipeRam1,ShearRam%OpenArea_PipeRam2,ShearRam%OpenArea_Annular)
  41. !TD_BOPConnectionPossibility(j) = 0 or 1
  42. !!!AnnularPreventerDiam = TD_BOPConnectionPossibility(1) >> used in Annular code
  43. !!!UpperRamDiam = TD_BOPConnectionPossibility(2) >> used in PipeRam1 code
  44. !!!BlindRamDiam = TD_BOPConnectionPossibility(3) >> used in ShearRam code
  45. !!!LowerRamDiam = TD_BOPConnectionPossibility(4) >> used in PipeRam2 code
  46. !=====================================================================
  47. !============SEALING PRESSURES TO BE SET IN ANNULAR REGULATOR==========
  48. AnnularComputational%WellBorePressure=5000.
  49. if (Annular%ODDrillpipe_inAnnular>0.) then
  50. if (Annular%ODDrillpipe_inAnnular>0. .and. Annular%ODDrillpipe_inAnnular<=1.99) then
  51. AnnularComputational%acoef=-0.2673
  52. AnnularComputational%Bcoef=994.3
  53. AnnularComputational%const=77
  54. elseif (Annular%ODDrillpipe_inAnnular>1.99 .and. Annular%ODDrillpipe_inAnnular<=2.375) then
  55. AnnularComputational%acoef=-0.2539
  56. AnnularComputational%Bcoef=994.3
  57. AnnularComputational%const=73.15
  58. elseif (Annular%ODDrillpipe_inAnnular>2.375 .and. Annular%ODDrillpipe_inAnnular<=2.875) then
  59. AnnularComputational%acoef=-0.2005
  60. AnnularComputational%Bcoef=745.9
  61. AnnularComputational%const=57.75
  62. elseif (Annular%ODDrillpipe_inAnnular>2.875 .and. Annular%ODDrillpipe_inAnnular<=3.5) then
  63. AnnularComputational%acoef=-0.1871
  64. AnnularComputational%Bcoef=696.1
  65. AnnularComputational%const=53.9
  66. elseif (Annular%ODDrillpipe_inAnnular>3.5 .and. Annular%ODDrillpipe_inAnnular<=5) then
  67. AnnularComputational%acoef=-0.1733
  68. AnnularComputational%Bcoef=647
  69. AnnularComputational%const=50
  70. elseif (Annular%ODDrillpipe_inAnnular>5 .and. Annular%ODDrillpipe_inAnnular<=10) then
  71. AnnularComputational%acoef=-0.1604
  72. AnnularComputational%Bcoef=596.7
  73. AnnularComputational%const=46.2
  74. endif
  75. AnnularComputational%AnnularSealingPressure= max((AnnularComputational%acoef*AnnularComputational%WellBorePressure+AnnularComputational%Bcoef), AnnularComputational%const) !(psi)
  76. else !CSO(COMPLETE SHUT OFF) ODDrillpipe_inAnnular=0
  77. AnnularComputational%AnnularSealingPressure= 1150. !(psi)
  78. endif
  79. !=====================================================================
  80. ! BYPASS POSITION
  81. !=====================================================================
  82. if(BopControlPanel%ByePassValve == -1.0 .and. BopControlPanel%AirMasterValve==1) then
  83. BopStackAcc%ByPassOld= -1.0
  84. !write(*,*) 'ByePassValve to -1' ,ByePassValve
  85. elseif(BopControlPanel%ByePassValve == 1.0 .and. BopControlPanel%AirMasterValve==1) then
  86. BopStackAcc%ByPassOld= 1.0
  87. !write(*,*) 'ByePassValve to 1=' ,ByePassValve
  88. endif
  89. !write(*,*) 'ByePassValve,ByPassOld=' ,ByePassValve,ByPassOld
  90. !=====================================================================
  91. !WRITE(*,*) 'AnnularRegulatorSetControl====' , AnnularRegulatorSetControl
  92. Annular%Pannular_regset=min(BopControlPanel%AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
  93. if (Annular%Annular_closed==1) then
  94. if (Annular%FirstSet==1) then ! code start
  95. Annular%Pannular_reg= Annular%Pannular_regset
  96. endif
  97. if (Annular%FirstSet==0) then ! durig run, but annular is not closing or opening
  98. Annular%Pannular_reg= min(RamLine%P_ACC,Annular%Pannular_regset)
  99. endif
  100. endif
  101. !===================================================================
  102. ! Annular Preventer Pressure Rise On Tooljoint
  103. !===================================================================
  104. if ( Annular%Annular_Situation_forTD == 1 .and. TD_BOP%AnnularFillingFinal==0.0 ) then ! Annular_Situation_forTD= 1 ! closed - for TD code
  105. AnnularComputational%AnnPressureRise= .true.
  106. elseif ( Annular%Annular_Situation_forTD == 0 ) then
  107. AnnularComputational%AnnPressureRise= .false.
  108. endif
  109. if (AnnularComputational%AnnPressureRise == .true.) then
  110. Annular%Pannular_reg= Annular%Pannular_reg + 200. * TD_BOP%AnnularFillingFinal ! 200 psi pressure rise when 100% of AnnPreventer is filled by tool joint
  111. !TD_AnnularFillingFinal ! (0.0 to 1.0) percentage filled by tool joint
  112. endif
  113. !===================================================================
  114. if (Annular%FirstSet== 1) then
  115. !new= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.)
  116. CALL AnnularComputational%Pannular_regDelay%AddToFirst( (1 - Annular%AnnularPressureGaugeMalf) * min(BopControlPanel%AnnularRegulatorSetControl,1700.) )
  117. CALL AnnularComputational%Pannular_regDelay%Remove(AnnularComputational%Pannular_regDelay%Length())
  118. BopControlPanel%AnnularPressureGauge= AnnularComputational%Pannular_regDelay%Last()
  119. !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * min(AnnularRegulatorSetControl,1700.)
  120. !write(*,*) 'set 1' , AnnularPressureGauge
  121. else !FirstSet== 0
  122. !new= (1 - AnnularPressureGaugeMalf) * Pannular_reg
  123. CALL AnnularComputational%Pannular_regDelay%AddToFirst( (1 - Annular%AnnularPressureGaugeMalf) * Annular%Pannular_reg)
  124. CALL AnnularComputational%Pannular_regDelay%Remove(AnnularComputational%Pannular_regDelay%Length())
  125. BopControlPanel%AnnularPressureGauge= AnnularComputational%Pannular_regDelay%Last()
  126. !AnnularPressureGauge= (1 - AnnularPressureGaugeMalf) * Pannular_reg
  127. !write(*,*) 'set 0' , AnnularPressureGauge
  128. endif
  129. !===================================================
  130. ! AIR OPERATED PUMP CODE- START
  131. !===================================================
  132. if (RamLine%P_ACC<Pumps%AIR_ON .and. RamLine%AIRP_SWITCH==0) then
  133. RamLine%AIRP_SWITCH=1
  134. endif
  135. if (RamLine%P_ACC>Pumps%AIR_OFF .and. RamLine%AIRP_SWITCH==1) then
  136. RamLine%AIRP_SWITCH=0
  137. call SetSoundKoomeyAirPump(RamLine%AIRP_SWITCH)
  138. endif
  139. if (RamLine%P_ACC<Pumps%ELECTRIC_ON .and. RamLine%ELECP_SWITCH==0) then
  140. RamLine%ELECP_SWITCH=1
  141. endif
  142. if (RamLine%P_ACC>Pumps%ELECTRIC_OFF .and. RamLine%ELECP_SWITCH==1) then
  143. RamLine%ELECP_SWITCH=0
  144. endif
  145. !write(*,*) 'airp_switch,elecp_switch=' , airp_switch,elecp_switch
  146. !================CHARGING BOTTLES=======================
  147. if (RamLine%AIRP_SWITCH==1 .or. RamLine%ELECP_SWITCH==1) then
  148. 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
  149. call pumps_charge_bottle()
  150. ! increases volume and pressure in the bottles
  151. if (RamLine%P_ACC>BopStackAcc%acc_ChargedPressure) then
  152. RamLine%P_ACC=BopStackAcc%acc_ChargedPressure
  153. if (Annular%AnnularLeakMalf== 0) then
  154. !finished_Annular=1
  155. RAM(1)%Bottles_Charged_MalfActive= .false.
  156. else
  157. Annular%finished_Annular=0
  158. RAM(1)%Bottles_Charged_MalfActive= .true.
  159. !fvr=fvr-2.5
  160. endif
  161. if (PipeRam1%UpperRamsLeakMalf== 0) then
  162. !finished_pipe1=1
  163. RAM(2)%Bottles_Charged_MalfActive= .false.
  164. else
  165. PipeRam1%finished=0
  166. RAM(2)%Bottles_Charged_MalfActive= .true.
  167. !fvr=fvr-2.5
  168. endif
  169. if (PipeRam2%LowerRamsLeakMalf== 0) then
  170. !finished_pipe2=1
  171. RAM(3)%Bottles_Charged_MalfActive= .false.
  172. else
  173. PipeRam2%finished=0
  174. RAM(3)%Bottles_Charged_MalfActive= .true.
  175. !fvr=fvr-2.5
  176. endif
  177. if (ShearRam%MiddleRamsLeakMalf== 0) then
  178. !finished_shear=1
  179. RAM(4)%Bottles_Charged_MalfActive= .false.
  180. else
  181. RamLine%FINISHED_shear=0
  182. RAM(4)%Bottles_Charged_MalfActive= .true.
  183. !fvr=fvr-2.5
  184. endif
  185. KillLine%finished=1
  186. ChokeLine%finished=1
  187. if (Annular%AnnularLeakMalf== 0 .and. PipeRam1%UpperRamsLeakMalf== 0 .and. PipeRam2%LowerRamsLeakMalf== 0 .and. ShearRam%MiddleRamsLeakMalf== 0) then
  188. RamLine%ELECP_SWITCH=0
  189. RamLine%AIRP_SWITCH=0
  190. endif
  191. endif
  192. endif
  193. endif
  194. !=======================================================
  195. if (RamLine%ELECP_SWITCH==1 .and. BopStackAcc%AccPupmsFailMalf==0) then !on position
  196. Pumps%DELTAV_ELECP=Pumps%QELECTRIC*RamLine%DeltaT_BOP/60. !QELECTRIC_PUMP(gpm), deltav_elecp(gal), DeltaT_BOP(0.1 sec)
  197. Pumps%SoundKoomeyElectric= .True.
  198. else
  199. Pumps%DELTAV_ELECP=0
  200. Pumps%SoundKoomeyElectric= .false.
  201. endif
  202. !call SetSoundKoomeyElectricPump(SoundKoomeyElectricPump)
  203. if (RamLine%AIRP_SWITCH==1 .and. BopStackAcc%AccPupmsFailMalf==0) then !on position
  204. call airpump_code() !ramtype=2
  205. end if ! if (airp_switch==1) then !on position
  206. !===============AIR OPERATED PUMP CODE- END================
  207. if (RamLine%ShearBop_closed==1 .and. PipeRam1%closed==1 .and. PipeRam2%closed==1 .and. ChokeLine%closed==1 .and. KillLine%closed==1) then
  208. !write(*,*) ' All Rams are closed'
  209. if(BopStackAcc%ByPassOld== -1.0) then ! (OPEN POSITION)
  210. !old=pram_reg
  211. !new=p_acc- MAXVAL(RAM%loss_before)
  212. !difference= new-old
  213. BopStackAcc%PressureDifference= RamLine%P_ACC- MAXVAL(RAM%loss_before) - BopStackAcc%pram_reg
  214. if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 300. psi
  215. BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
  216. else
  217. 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
  218. endif
  219. elseif (BopStackAcc%ByPassOld== 1.0) then ! (CLOSE POSITION)
  220. !pram_reg= prams_regset
  221. !if (RamsFirstSet==1) then
  222. !write(*,*) 'bypass CLOSE POSITION'
  223. !old=pram_reg
  224. !new=prams_regset
  225. !difference= new-old
  226. BopStackAcc%PressureDifference= BopStackAcc%PRAMS_REGSET - BopStackAcc%pram_reg
  227. !write(*,*) 'PressureDifference, prams_regset , pram_reg=' , PressureDifference, prams_regset , pram_reg
  228. if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then !BaseDifferenceP= 200. ! psi in starup
  229. BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20. in startup
  230. else
  231. BopStackAcc%pram_reg= BopStackAcc%PRAMS_REGSET
  232. endif
  233. !write(*,*) 'pram_reg=' , pram_reg
  234. !endif ! if (RamsFirstSet==1) then
  235. endif
  236. endif
  237. BopControlPanel%MiddleRamsStatus = ShearRam%IDshearBop
  238. BopControlPanel%UpperRamsStatus = PipeRam1%ID
  239. BopControlPanel%LowerRamsStatus = PipeRam2%ID
  240. BopControlPanel%AnnularStatus = Annular%IDAnnular
  241. BopControlPanel%AccumulatorPressureGauge = (1 - BopStackAcc%AccumulatorPressureGaugeMalf) * RamLine%P_ACC
  242. BopControlPanel%ManifoldPressureGauge= (1 - BopStackAcc%ManifoldPressureGaugeMalf) * BopStackAcc%pram_reg
  243. !AnnularPressureGauge=Pannular_reg
  244. !
  245. ! WRITE(60,60) RAM(2)%time,RAM(2)%Q,RAM(2)%vdis_tot,p_acc, &
  246. ! pram_reg,Pannular_reg,RAM(2)%p_bop,IDshearBop, &
  247. ! IDPipeRam1,IDPipeRam2,IDAnnular
  248. !60 FORMAT(11(f18.5))
  249. !WRITE(*,*) 'IDAnnular=' , IDAnnular
  250. !write(*,*) 'elecp_switch=' , elecp_switch
  251. !call sleepqq(100)
  252. end subroutine BopStack_Step
  253. end module BOP