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.
 
 
 
 
 
 

382 lines
16 KiB

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