Simulation Core
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

429 linhas
19 KiB

  1. SUBROUTINE ANNULAR_SUB1
  2. use SimulationVariables
  3. use CBopControlPanel
  4. use SimulationVariables
  5. use PressureDisplayVARIABLESModule
  6. USE CEquipmentsConstants
  7. USE CBopStackVariables
  8. implicit none
  9. !write(*,*) 'checkpoint 1'
  10. !=====================================================================
  11. ! ANNULAR PREVENTER- BOP CAMERON Type U 5000
  12. ! START CONDITIONS FOR ANNULAR PREVENTER
  13. !=====================================================================
  14. data%State%RAM(1)%SuccessionCounter = data%State%RAM(1)%SuccessionCounter + 1
  15. if (data%Equipments%BopControlPanel%AnnularValve == 1.0 .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  16. if (data%State%BopStackInput%AnnularCloseLedMine == LedOn) then
  17. RETURN
  18. end if
  19. if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then
  20. data%State%RAM(1)%SuccessionCounter = 0 ! also in starup
  21. data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup
  22. !return
  23. else
  24. data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter
  25. endif
  26. if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  27. !return
  28. data%State%RAM(1)%First_CloseTimecheck= 1
  29. data%Equipments%BopControlPanel%AnnularOpenLED = LedOff
  30. data%State%BopStackInput%AnnularOpenLedMine = LedOff
  31. data%Equipments%BopControlPanel%AnnularCloseLED = LedOn !LedBlinking
  32. data%State%RAM(1)%FourwayValve = 1
  33. endif
  34. endif
  35. if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure) then ! 1: Open , 0: Close
  36. data%State%RAM(1)%FourwayValve = 0
  37. data%State%Annular%Annular_closed=0
  38. !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1)
  39. data%State%RAM(1)%vdis_tot=0
  40. data%State%RAM(1)%vdis_bottles=0.
  41. data%State%RAM(1)%fvr_air=0.
  42. data%State%RAM(1)%vdis_elecp=0.
  43. data%State%Pumps%Qiter=7
  44. data%State%RAM(1)%Qzero=70
  45. data%State%RAM(1)%Q=data%State%RAM(1)%Qzero
  46. data%State%RAM(1)%flow=70
  47. data%State%Annular%tolAnnular=0.0018
  48. if (data%State%Annular%finished_Annular==1) then
  49. data%State%Annular%AnnularLeverOld=-1.0
  50. else
  51. data%State%Annular%AnnularLeverOld=data%Equipments%BopControlPanel%AnnularValve
  52. endif
  53. data%State%Annular%finished_Annular=0
  54. data%State%Annular%AnnularIsClosing = .true.
  55. data%State%Annular%AnnularIsOpening = .false.
  56. data%State%RAM(2)%bop_type = 3
  57. !AbopAnnular=963.1 !(in^2)
  58. data%State%Annular%AbopAnnular=(data%Configuration%BopStack%AnnularPreventerClose*231.)/((data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnularBase)/2.) ! 231 in^3 = 1 gal
  59. data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnularBase-max(data%State%Annular%ODDrillpipe_inAnnular,data%State%Annular%ODDrillpipe_inAnnularBase))/(2.*231) !=17.98 galon for IDAnnularBase=13 5/8 , ODDrillpipe_inAnnularBase=5
  60. !WRITE(*,*) 'a)NeededVolumeAnnular=' , NeededVolumeAnnular
  61. !write(*,*) 'close 1'
  62. endif
  63. if (data%Equipments%BopControlPanel%AnnularValve == -1.0 .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1 ) then
  64. if (data%State%BopStackInput%AnnularOpenLedMine == LedOn) then
  65. RETURN
  66. end if
  67. !CasingPressure : PressureGauges(2) *****temp conditionssssss
  68. !note: (AnnularSealingPressure) is only for opening while well is pressurised
  69. if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then
  70. data%State%RAM(1)%SuccessionCounter = 0 ! also in starup
  71. data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup
  72. !return
  73. else
  74. data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter
  75. endif
  76. if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  77. !return
  78. data%State%RAM(1)%First_OpenTimecheck= 1
  79. data%Equipments%BopControlPanel%AnnularCloseLED = LedOff !new
  80. data%State%BopStackInput%AnnularCloseLedMine = LedOff !new
  81. data%Equipments%BopControlPanel%AnnularOpenLED = LedOn !LedBlinking
  82. data%State%RAM(1)%FourwayValve = 1
  83. endif
  84. endif
  85. if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure &
  86. .and. (data%State%Annular%Annular_closed==0 .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2) <=100.0) .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2)>100.0 .and. data%State%Annular%Pannular_reg>=data%State%AnnularComputational%AnnularSealingPressure))) then ! 1: Open , 0: Close
  87. !write(*,*) 'open 2'
  88. data%State%RAM(1)%FourwayValve = 0
  89. data%State%Annular%Annular_closed=0
  90. !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1)
  91. data%State%RAM(1)%vdis_tot=0
  92. data%State%RAM(1)%vdis_bottles=0.
  93. data%State%RAM(1)%fvr_air=0.
  94. data%State%RAM(1)%vdis_elecp=0.
  95. data%State%Pumps%Qiter=7
  96. data%State%RAM(1)%Qzero=70
  97. data%State%RAM(1)%Q=data%State%RAM(1)%Qzero
  98. data%State%RAM(1)%flow=70
  99. data%State%Annular%tolAnnular=0.0018
  100. if (data%State%Annular%finished_Annular==1) then
  101. data%State%Annular%AnnularLeverOld=1.0
  102. else
  103. data%State%Annular%AnnularLeverOld=data%Equipments%BopControlPanel%AnnularValve
  104. endif
  105. data%State%Annular%finished_Annular=0
  106. data%State%Annular%AnnularIsOpening = .true.
  107. data%State%Annular%AnnularIsClosing = .false.
  108. !if (AnnularOpenLed == LedOn) then
  109. ! RETURN
  110. !end if
  111. data%State%RAM(1)%bop_type = 3
  112. !AbopAnnular=758.48 !(in^2)
  113. data%State%Annular%AbopAnnular=(data%Configuration%BopStack%AnnularPreventerOpen*231)/((data%State%Annular%IDAnnularBase-max(data%State%Annular%ODDrillpipe_inAnnular,data%State%Annular%ODDrillpipe_inAnnularBase))/2.)
  114. data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnular)/(2.*231) !=14.16 galon for IDAnnularBase=13 5/8 , ODDrillpipe_inAnnular=5
  115. !write(*,*) 'open 1'
  116. endif
  117. !=====================================================================
  118. if (data%State%Annular%AnnularIsOpening .or. data%State%Annular%AnnularIsClosing .or. data%State%RAM(1)%Bottles_Charged_MalfActive) then
  119. CALL ANNULAR_SUB2
  120. end if
  121. END SUBROUTINE ANNULAR_SUB1
  122. SUBROUTINE ANNULAR_SUB2
  123. use SimulationVariables
  124. use PressureDisplayVARIABLESModule
  125. use CBopControlPanel
  126. use SimulationVariables
  127. USE CEquipmentsConstants
  128. USE CBopStackVariables
  129. ! use CSimulationVariables
  130. implicit none
  131. data%State%Annular%FirstSet= 0
  132. data%State%AnnularComputational%RamsFirstSet= 0
  133. ! loop5: do while (finished_Annular==0)
  134. !write(*,*) 'checkpoint 2'
  135. data%State%RAM(1)%SuccessionCounter = data%State%RAM(1)%SuccessionCounter + 1
  136. ! CALL CPU_TIME(Annular_StartTime)
  137. if (data%Equipments%BopControlPanel%AnnularValve == 1.0 .and. data%State%Annular%AnnularLeverOld == -1.0 .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  138. if ( data%State%RAM(1)%First_CloseTimecheck == 0 ) then
  139. if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then
  140. data%State%RAM(1)%SuccessionCounter = 0 ! also in starup
  141. data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup
  142. !return
  143. else
  144. data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter
  145. endif
  146. if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  147. !return
  148. data%Equipments%BopControlPanel%AnnularOpenLED = LedOff
  149. data%State%BopStackInput%AnnularOpenLedMine = LedOff
  150. data%Equipments%BopControlPanel%AnnularCloseLED = LedOn !LedBlinking
  151. data%State%RAM(1)%FourwayValve = 1
  152. endif
  153. endif
  154. !write(*,*) 'chekkk 1'
  155. endif
  156. if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  157. !write(*,*) 'close 4'
  158. data%State%RAM(1)%FourwayValve = 0
  159. data%State%Annular%Annular_closed=0
  160. !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1)
  161. data%State%AnnularComputational%p_annular=data%State%AnnularComputational%pa_annular
  162. data%State%Annular%AnnularLeverOld = data%Equipments%BopControlPanel%AnnularValve
  163. CALL OpenAnnular
  164. data%State%Annular%Annular_Situation_forTD= 0 ! open - for TD code
  165. data%State%RAM(1)%bop_type = 3
  166. !AbopAnnular=963.1 !(in^2)
  167. data%State%Annular%AbopAnnular=(data%Configuration%BopStack%AnnularPreventerClose*231)/((data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnularBase)/2.)
  168. !write(*,*) 'NeededVolumeShearRams1=',NeededVolumeShearRams
  169. data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnular-max(data%State%Annular%ODDrillpipe_inAnnular,data%State%Annular%ODDrillpipe_inAnnularBase))/(2*231.)
  170. ! write(*,*) 'NeededVolumeAnnular=',NeededVolumeAnnular
  171. data%State%RAM(1)%vdis_bottles=0.
  172. data%State%RAM(1)%fvr_air=0.
  173. data%State%RAM(1)%vdis_elecp=0.
  174. data%State%Annular%AnnularIsClosing = .true.
  175. data%State%Annular%AnnularIsOpening = .false.
  176. !write(*,*) 'close 2'
  177. endif
  178. if (data%Equipments%BopControlPanel%AnnularValve == -1.0 .and. data%State%Annular%AnnularLeverOld == 1.0 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure .and. data%State%Annular%AnnularFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1 ) then
  179. !CasingPressure : PressureGauges(2) *****temp conditionssssss
  180. !note: (AnnularSealingPressure) is only for opening while well is pressurised
  181. if ( data%State%RAM(1)%First_OpenTimecheck == 0 ) then
  182. if ( data%State%RAM(1)%SuccessionCounter /= data%State%RAM(1)%SuccessionCounterOld+1 ) then
  183. data%State%RAM(1)%SuccessionCounter = 0 ! also in starup
  184. data%State%RAM(1)%SuccessionCounterOld = 0 ! also in starup
  185. !return
  186. else
  187. data%State%RAM(1)%SuccessionCounterOld= data%State%RAM(1)%SuccessionCounter
  188. endif
  189. if ( data%State%RAM(1)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  190. !return
  191. data%Equipments%BopControlPanel%AnnularCloseLED = LedOff
  192. data%State%BopStackInput%AnnularCloseLedMine= LedOff
  193. data%Equipments%BopControlPanel%AnnularOpenLED = LedOn !LedBlinking
  194. data%State%RAM(1)%FourwayValve = 1
  195. endif
  196. endif
  197. !write(*,*) 'chekkk 2'
  198. endif
  199. if (data%State%RAM(1)%FourwayValve == 1 .and. data%State%Annular%Pannular_reg>data%State%AnnularComputational%AnnularMovingPressure &
  200. .and. (data%State%Annular%Annular_closed==0 .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2) <=100.0) .or. (data%State%Annular%Annular_closed==1 .and. data%State%PressureDisplay%PressureGauges(2)>100.0 .and. data%State%Annular%Pannular_reg>=data%State%AnnularComputational%AnnularSealingPressure))) then
  201. !write(*,*) 'open 4'
  202. data%State%RAM(1)%FourwayValve = 0
  203. data%State%Annular%Annular_closed=0
  204. !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1)
  205. data%State%AnnularComputational%p_annular=data%State%AnnularComputational%pa_annular
  206. data%State%Annular%AnnularLeverOld = data%Equipments%BopControlPanel%AnnularValve
  207. CALL OpenAnnular
  208. data%State%Annular%Annular_Situation_forTD= 0 ! open - for TD code
  209. data%State%RAM(1)%bop_type = 3
  210. !AbopAnnular=758.48 !(in^2)
  211. data%State%Annular%AbopAnnular=(data%Configuration%BopStack%AnnularPreventerOpen*231)/((data%State%Annular%IDAnnularBase-data%State%Annular%ODDrillpipe_inAnnularBase)/2.)
  212. data%State%Annular%NeededVolumeAnnular=data%State%Annular%AbopAnnular*(data%State%Annular%IDAnnularBase-data%State%Annular%IDAnnular)/(2*231.)
  213. data%State%RAM(1)%vdis_bottles=0.
  214. data%State%RAM(1)%fvr_air=0.
  215. data%State%RAM(1)%vdis_elecp=0.
  216. data%State%Annular%AnnularIsOpening = .true.
  217. data%State%Annular%AnnularIsClosing = .false.
  218. !write(*,*) 'open 2'
  219. endif
  220. data%State%RAM(1)%First_CloseTimecheck = 0
  221. data%State%RAM(1)%First_OpenTimecheck = 0
  222. data%State%RAM(1)%time=data%State%RAM(1)%time+data%State%RamLine%DeltaT_BOP !overal time (s)
  223. !===================================================
  224. ! BOP
  225. !===================================================
  226. if (data%State%Annular%Annular_closed==0) then !bop closing
  227. !write(*,*) 'AnnularIsClosing,AnnularIsOpening' , AnnularIsClosing,AnnularIsOpening
  228. call bop_codeAnnular(1) !ramtype=4 1=RNUMBER
  229. endif !bop is closing
  230. !================================================================
  231. if (data%State%Annular%Annular_closed==1) then
  232. data%State%RAM(1)%Q=0
  233. !p_bop=pram_reg
  234. data%State%AnnularComputational%p_annular=data%State%AnnularComputational%pa_annular
  235. endif
  236. data%State%RAM(1)%timecounter_ram=data%State%RAM(1)%timecounter_ram+1
  237. ! MiddleRamsStatus = IDshearBop
  238. ! UpperRamsStatus = IDPipeRam1
  239. ! LowerRamsStatus = IDPipeRam2
  240. ! AnnularStatus = IDAnnular
  241. ! AccumulatorPressureGauge = p_acc
  242. ! ManifoldPressureGauge= pram_reg
  243. ! AnnularPressureGauge=Pannular_reg
  244. !
  245. !
  246. !
  247. ! WRITE(60,60) data%State%RAM(1)%time,data%State%RAM(1)%Q,data%State%RAM(1)%vdis_tot,p_acc, &
  248. ! pram_reg,Pannular_reg,data%State%RAM(1)%p_bop,IDshearBop, &
  249. ! IDPipeRam1,IDPipeRam2,IDAnnular
  250. !60 FORMAT(11(f18.5))
  251. ! call sleepqq(100)
  252. !CALL CPU_TIME(Annular_EndTime)
  253. !
  254. !
  255. !data%State%Pump(1)%INT_CPU_TIME=IDINT((Annular_EndTime-Annular_StartTime)*1000.)
  256. !data%State%Pump(1)%Dt_ref=IDINT(DeltaT_BOP*1000.)
  257. !
  258. !call sleepqq(data%State%Pump(1)%Dt_ref-data%State%Pump(1)%INT_CPU_TIME)
  259. if (data%State%Annular%Annular_closed==1) then
  260. ! if ((MiddleRamsValve==1. .and. MiddleRamsFailureMalf==0) .or. (MiddleRamsValve==-1.0 .and. MiddleRamsFailureMalf==0) .or. (LowerRamsValve==1. .and. LowerRamsFailureMalf==0) .or. (LowerRamsValve==-1.0 .and. LowerRamsFailureMalf==0) .or. (UpperRamsValve==1. .and. UpperRamsFailureMalf==0) .or. (UpperRamsValve==-1.0 .and. UpperRamsFailureMalf==0) .or. ChokeLineValve==1. .or. ChokeLineValve==-1.0 .or. KillLineValve==1. .or. KillLineValve==-1.0) then
  261. data%State%Annular%finished_Annular=1
  262. ! endif
  263. endif
  264. ! if (IsStopped == .true.) return
  265. ! end do loop5 !while finished_Annular==0
  266. if ( data%State%Annular%finished_Annular==1 .and. data%State%RAM(1)%Bottles_Charged_MalfActive==.true.) then
  267. call bop_codeAnnular(1) !ramtype=4 1=RNUMBER
  268. ! call sleepqq(100)
  269. endif
  270. END SUBROUTINE ANNULAR_SUB2