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.
 
 
 
 
 
 

400 regels
15 KiB

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