Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

398 lines
16 KiB

  1. SUBROUTINE PIPE_RAMS2
  2. use SimulationVariables
  3. USE CBopStackVariables
  4. use CBopControlPanel
  5. use SimulationVariables
  6. USE CEquipmentsConstants
  7. ! ! use CSimulationVariables
  8. implicit none
  9. !write(*,*) 'checkpoint 1'
  10. !=====================================================================
  11. ! PIPE RAMS 2- BOP CAMERON Type U 5000
  12. ! START CONDITIONS FOR PIPE RAMS 2
  13. !=====================================================================
  14. data%State%RAM(3)%SuccessionCounter = data%State%RAM(3)%SuccessionCounter + 1
  15. if (data%Equipments%BopControlPanel%LowerRamsValve == 1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  16. !write(*,*) 'close 1'
  17. if (data%State%BopStackInput%LowerRamsCloseLEDMine == LedOn) then
  18. RETURN
  19. end if
  20. if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then
  21. data%State%RAM(3)%SuccessionCounter = 0 ! also in starup
  22. data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup
  23. !return
  24. else
  25. data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter
  26. endif
  27. if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  28. !return
  29. data%State%RAM(3)%First_CloseTimecheck= 1
  30. data%Equipments%BopControlPanel%LowerRamsOpenLED = LedOff
  31. data%State%BopStackInput%LowerRamsOpenLEDMine = LedOff
  32. data%Equipments%BopControlPanel%LowerRamsCloseLED = LedOn !LedBlinking
  33. data%State%RAM(3)%FourwayValve = 1
  34. endif
  35. endif
  36. if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close
  37. !write(*,*) 'close 2'
  38. data%State%RAM(3)%FourwayValve = 0
  39. data%State%PipeRam2%closed=0
  40. !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4)
  41. data%State%RAM(3)%vdis_tot=0
  42. data%State%RAM(3)%vdis_bottles=0.
  43. data%State%RAM(3)%fvr_air=0.
  44. data%State%RAM(3)%vdis_elecp=0.
  45. data%State%Pumps%Qiter=7
  46. data%State%RAM(3)%Qzero=70
  47. data%State%RAM(3)%Q=data%State%RAM(3)%Qzero
  48. data%State%RAM(3)%flow=70
  49. data%State%RAM(3)%tol=0.0037
  50. if (data%State%PipeRam2%finished==1) then
  51. data%State%PipeRam2%LeverOld=-1.0
  52. else
  53. data%State%PipeRam2%LeverOld=data%Equipments%BopControlPanel%LowerRamsValve
  54. endif
  55. data%State%PipeRam2%finished=0
  56. data%State%PipeRam2%IsClosing = .true.
  57. data%State%PipeRam2%IsOpening = .false.
  58. data%State%RAM(3)%bop_type = 3
  59. !AbopPipeRam=196.67
  60. data%State%PipeRam1%A=(data%Configuration%BopStack%LowerRamClose*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.)
  61. data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231) !galon for each BOP
  62. !write(*,*) 'close 1'
  63. endif
  64. if (data%Equipments%BopControlPanel%LowerRamsValve == -1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  65. !write(*,*) 'open 1'
  66. if (data%State%BopStackInput%LowerRamsOpenLEDMine == LedOn) then
  67. RETURN
  68. end if
  69. if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then
  70. data%State%RAM(3)%SuccessionCounter = 0 ! also in starup
  71. data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup
  72. !return
  73. else
  74. data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter
  75. endif
  76. if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  77. !return
  78. data%State%RAM(3)%First_OpenTimecheck= 1
  79. data%Equipments%BopControlPanel%LowerRamsCloseLED = LedOff !new
  80. data%State%BopStackInput%LowerRamsCloseLEDMine = LedOff !new
  81. data%Equipments%BopControlPanel%LowerRamsOpenLED = LedOn !LedBlinking
  82. data%State%RAM(3)%FourwayValve = 1
  83. endif
  84. endif
  85. if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close
  86. !write(*,*) 'open 2'
  87. data%State%RAM(3)%FourwayValve = 0
  88. data%State%PipeRam2%closed=0
  89. !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4)
  90. data%State%RAM(3)%vdis_tot=0
  91. data%State%RAM(3)%vdis_bottles=0.
  92. data%State%RAM(3)%fvr_air=0.
  93. data%State%RAM(3)%vdis_elecp=0.
  94. data%State%Pumps%Qiter=7
  95. data%State%RAM(3)%Qzero=70
  96. data%State%RAM(3)%Q=data%State%RAM(3)%Qzero
  97. data%State%RAM(3)%flow=70
  98. data%State%RAM(3)%tol=0.0037
  99. if (data%State%PipeRam2%finished==1) then
  100. data%State%PipeRam2%LeverOld=1.0
  101. else
  102. data%State%PipeRam2%LeverOld=data%Equipments%BopControlPanel%LowerRamsValve
  103. endif
  104. data%State%PipeRam2%finished=0
  105. data%State%PipeRam2%IsOpening = .true.
  106. data%State%PipeRam2%IsClosing = .false.
  107. !if (LowerRamsOpenLED == LedOn) then
  108. ! RETURN
  109. !end if
  110. data%State%RAM(3)%bop_type = 3
  111. !AbopPipeRam=186.5
  112. data%State%PipeRam1%A=(data%Configuration%BopStack%LowerRamOpen*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.)
  113. data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231) !galon for each BOP
  114. !write(*,*) 'open 1'
  115. endif
  116. !=====================================================================
  117. if (data%State%PipeRam2%IsOpening .or. data%State%PipeRam2%IsClosing .or. data%State%RAM(3)%Bottles_Charged_MalfActive) then
  118. data%State%Annular%FirstSet= 0
  119. data%State%AnnularComputational%RamsFirstSet= 0
  120. CALL PIPE_RAMS2_SUB
  121. end if
  122. END SUBROUTINE PIPE_RAMS2
  123. SUBROUTINE PIPE_RAMS2_SUB
  124. use SimulationVariables
  125. USE CBopStackVariables
  126. use CBopControlPanel
  127. use SimulationVariables
  128. USE CEquipmentsConstants
  129. ! use CSimulationVariables
  130. implicit none
  131. ! FirstSet= 0
  132. ! RamsFirstSet= 0
  133. ! loop4: do while (finished_pipe2==0)
  134. !write(*,*) 'checkpoint 2'
  135. data%State%RAM(3)%SuccessionCounter = data%State%RAM(3)%SuccessionCounter + 1
  136. if (data%Equipments%BopControlPanel%LowerRamsValve == 1.0 .and. data%State%PipeRam2%LeverOld == -1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  137. !write(*,*) 'close 3'
  138. if ( data%State%RAM(3)%First_CloseTimecheck == 0 ) then
  139. if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then
  140. data%State%RAM(3)%SuccessionCounter = 0 ! also in starup
  141. data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup
  142. !return
  143. else
  144. data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter
  145. endif
  146. if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  147. !return
  148. data%Equipments%BopControlPanel%LowerRamsOpenLED = LedOff
  149. data%State%BopStackInput%LowerRamsOpenLEDMine = LedOff
  150. data%Equipments%BopControlPanel%LowerRamsCloseLED = LedOn !LedBlinking
  151. data%State%RAM(3)%FourwayValve = 1
  152. endif
  153. endif
  154. endif
  155. if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  156. !write(*,*) 'close 4'
  157. data%State%RAM(3)%FourwayValve = 0
  158. data%State%PipeRam2%closed=0
  159. !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4)
  160. data%State%RAM(3)%p_bop=data%State%ShearRAM%PA
  161. data%State%PipeRam2%LeverOld = data%Equipments%BopControlPanel%LowerRamsValve
  162. CALL OpenLowerRams
  163. data%State%PipeRam2%Situation_forTD= 0 ! open - for TD code
  164. data%State%RAM(3)%bop_type = 3
  165. !AbopPipeRam=196.67
  166. data%State%PipeRam1%A=(data%Configuration%BopStack%LowerRamClose*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.)
  167. data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam2%ID-max(data%State%PipeRam2%ODDrillpipe_in,data%State%PipeRam1%ODDrillpipe_inBase))/(2.*231)
  168. data%State%RAM(3)%vdis_bottles=0.
  169. data%State%RAM(3)%fvr_air=0.
  170. data%State%RAM(3)%vdis_elecp=0.
  171. data%State%PipeRam2%IsClosing = .true.
  172. data%State%PipeRam2%IsOpening = .false.
  173. !write(*,*) 'close 2'
  174. endif
  175. if (data%Equipments%BopControlPanel%LowerRamsValve == -1.0 .and. data%State%PipeRam2%LeverOld == 1.0 .and. data%State%PipeRam2%LowerRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  176. !write(*,*) 'open 3'
  177. if ( data%State%RAM(3)%First_OpenTimecheck == 0 ) then
  178. if ( data%State%RAM(3)%SuccessionCounter /= data%State%RAM(3)%SuccessionCounterOld+1 ) then
  179. data%State%RAM(3)%SuccessionCounter = 0 ! also in starup
  180. data%State%RAM(3)%SuccessionCounterOld = 0 ! also in starup
  181. !return
  182. else
  183. data%State%RAM(3)%SuccessionCounterOld= data%State%RAM(3)%SuccessionCounter
  184. endif
  185. if ( data%State%RAM(3)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  186. !return
  187. data%Equipments%BopControlPanel%LowerRamsCloseLED = LedOff
  188. data%State%BopStackInput%LowerRamsCloseLEDMine = LedOff
  189. data%Equipments%BopControlPanel%LowerRamsOpenLED = LedOn !LedBlinking
  190. data%State%RAM(3)%FourwayValve = 1
  191. endif
  192. endif
  193. endif
  194. if (data%State%RAM(3)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  195. !write(*,*) 'open 4'
  196. data%State%RAM(3)%FourwayValve = 0
  197. data%State%PipeRam2%closed=0
  198. !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4)
  199. data%State%RAM(3)%p_bop=data%State%ShearRAM%PA
  200. data%State%PipeRam2%LeverOld = data%Equipments%BopControlPanel%LowerRamsValve
  201. CALL OpenLowerRams
  202. data%State%PipeRam2%Situation_forTD= 0 ! open - for TD code
  203. data%State%RAM(3)%bop_type = 3
  204. !AbopPipeRam=186.5
  205. data%State%PipeRam1%A=(data%Configuration%BopStack%LowerRamOpen*231)/((data%State%PipeRam1%IDBase-data%State%PipeRam1%ODDrillpipe_inBase)/2.)
  206. data%State%PipeRam2%NeededVolume=data%State%PipeRam1%A*(data%State%PipeRam1%IDBase-data%State%PipeRam2%ID)/(2.*231)
  207. data%State%RAM(3)%vdis_bottles=0.
  208. data%State%RAM(3)%fvr_air=0.
  209. data%State%RAM(3)%vdis_elecp=0.
  210. data%State%PipeRam2%IsOpening = .true.
  211. data%State%PipeRam2%IsClosing = .false.
  212. !write(*,*) 'open 2'
  213. endif
  214. data%State%RAM(3)%First_CloseTimecheck = 0
  215. data%State%RAM(3)%First_OpenTimecheck = 0
  216. data%State%RAM(3)%time=data%State%RAM(3)%time+data%State%RamLine%DeltaT_BOP !overal time (s)
  217. !===================================================
  218. ! BOP
  219. !===================================================
  220. if (data%State%PipeRam2%closed==0) then !bop closing
  221. !write(*,*) 'BOP code is called'
  222. call bop_code(3,data%State%PipeRam2%H_Bop,3) !ramtype=3 3=RNUMBER
  223. endif !bop is closing
  224. !================================================================
  225. if (data%State%PipeRam2%closed==1) then
  226. data%State%RAM(3)%Q=0
  227. !p_bop=pram_reg
  228. data%State%RAM(3)%p_bop=data%State%ShearRAM%PA
  229. data%State%RAMS%minloss(3,17)=0. !RNUMBER=3
  230. endif
  231. data%State%RAM(3)%timecounter_ram=data%State%RAM(3)%timecounter_ram+1
  232. ! MiddleRamsStatus = IDshearBop
  233. ! UpperRamsStatus = IDPipeRam1
  234. ! LowerRamsStatus = IDPipeRam2
  235. ! AnnularStatus = IDAnnular
  236. ! AccumulatorPressureGauge = p_acc
  237. ! ManifoldPressureGauge= pram_reg
  238. ! AnnularPressureGauge=Pannular_reg
  239. !
  240. !
  241. !
  242. ! WRITE(60,60) data%State%RAM(3)%time,data%State%RAM(3)%Q,data%State%RAM(3)%vdis_tot,p_acc, &
  243. ! pram_reg,Pannular_reg,data%State%RAM(3)%p_bop,IDshearBop, &
  244. ! IDPipeRam1,IDPipeRam2,IDAnnular
  245. !60 FORMAT(11(f18.5))
  246. ! call sleepqq(100)
  247. if (data%State%PipeRam2%closed==1) then
  248. ! if ((MiddleRamsValve==1. .and. MiddleRamsFailureMalf==0) .or. (MiddleRamsValve==-1.0 .and. MiddleRamsFailureMalf==0) .or. (UpperRamsValve==1. .and. UpperRamsFailureMalf==0) .or. (UpperRamsValve==-1.0 .and. UpperRamsFailureMalf==0) .or. (AnnularValve==1. .and. AnnularFailureMalf==0) .or. (AnnularValve==-1.0 .and. AnnularFailureMalf==0) .or. ChokeLineValve==1. .or. ChokeLineValve==-1.0 .or. KillLineValve==1. .or. KillLineValve==-1.0) then
  249. data%State%PipeRam2%finished=1
  250. ! endif
  251. endif
  252. ! if (IsStopped == .true.) return
  253. ! end do loop4 !while finished_pipe2==0
  254. if ( data%State%PipeRam2%finished==1 .and. data%State%RAM(3)%Bottles_Charged_MalfActive==.true.) then
  255. call bop_code(3,data%State%PipeRam2%H_Bop,3) !ramtype=3 3=RNUMBER
  256. ! call sleepqq(100)
  257. endif
  258. END SUBROUTINE PIPE_RAMS2_SUB