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.
 
 
 
 
 
 

384 lines
15 KiB

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