Simulation Core
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

279 行
13 KiB

  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/BopStack/SHEAR_RAM.f90"
  2. SUBROUTINE SHEAR_RAMS
  3. use SimulationVariables
  4. USE CBopStackVariables
  5. use CBopControlPanel
  6. use SimulationVariables
  7. USE CEquipmentsConstants
  8. ! use CSimulationVariables
  9. implicit none
  10. !=====================================================================
  11. ! SHEAR RAMS- BOP CAMERON Type U 5000
  12. ! START CONDITIONS FOR SHEAR RAMS
  13. !=====================================================================
  14. data%State%RAM(4)%SuccessionCounter = data%State%RAM(4)%SuccessionCounter + 1
  15. if (data%Equipments%BopControlPanel%MiddleRamsValve == 1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  16. if (data%State%BopStackInput%MiddleRamsCloseLEDMine == LedOn) then
  17. RETURN
  18. end if
  19. if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then
  20. data%State%RAM(4)%SuccessionCounter = 0 ! also in starup
  21. data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup
  22. !return
  23. else
  24. data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter
  25. endif
  26. if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  27. !return
  28. data%State%RAM(4)%First_CloseTimecheck= 1
  29. data%Equipments%BopControlPanel%MiddleRamsOpenLED = LedOff
  30. data%State%BopStackInput%MiddleRamsOpenLEDMine = LedOff
  31. data%Equipments%BopControlPanel%MiddleRamsCloseLED = LedOn !LedBlinking
  32. data%State%RAM(4)%FourwayValve = 1
  33. endif
  34. endif
  35. if (data%State%RAM(4)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then ! 1: Open , 0: Close
  36. !write(*,*) 'close 2'
  37. data%State%RAM(4)%FourwayValve = 0
  38. data%State%RamLine%ShearBop_closed=0
  39. !ShearBop_closed_withPossibility= ShearBop_closed * TD_BOPConnectionPossibility(3)
  40. data%State%RAM(4)%vdis_tot=0
  41. data%State%RAM(4)%vdis_bottles=0.
  42. data%State%RAM(4)%fvr_air=0.
  43. data%State%RAM(4)%vdis_elecp=0.
  44. data%State%Pumps%Qiter=7
  45. data%State%RAM(4)%Qzero=70
  46. data%State%RAM(4)%Q=data%State%RAM(4)%Qzero
  47. data%State%RAM(4)%flow=70
  48. data%State%RAM(4)%tol=0.0037
  49. if (data%State%RamLine%FINISHED_shear==1) then
  50. data%State%RamLine%ShearRamsLeverOld=-1.0
  51. else
  52. data%State%RamLine%ShearRamsLeverOld=data%Equipments%BopControlPanel%MiddleRamsValve
  53. endif
  54. data%State%RamLine%FINISHED_shear=0
  55. data%State%RamLine%ShearRamIsClosing = .true.
  56. data%State%RamLine%ShearRamIsOpening = .false.
  57. data%State%RAM(4)%bop_type = 2
  58. !NeededVolumeShearRams=5.8 !galon for each BOP
  59. !AbopShearRam=196.67 !(in^2)
  60. data%State%ShearRAM%AbopShearRam=(data%Configuration%BopStack%BlindRamClose*231)/(data%State%ShearRAM%IDshearBopBase/2.)
  61. !NeededVolumeShearRams=BlindRamClose !galon for each BOP **changed
  62. data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%ShearIsNotAllowed*data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231) !3.67 galon for each BOP ! **changed
  63. data%State%ShearRAM%VA=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231)
  64. data%State%ShearRAM%VB=data%State%ShearRAM%NeededVolumeShearRams
  65. endif
  66. if (data%Equipments%BopControlPanel%MiddleRamsValve == -1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  67. if (data%State%BopStackInput%MiddleRamsOpenLEDMine == LedOn) then
  68. RETURN
  69. end if
  70. if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then
  71. data%State%RAM(4)%SuccessionCounter = 0 ! also in starup
  72. data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup
  73. !return
  74. else
  75. data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter
  76. endif
  77. if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  78. !return
  79. data%State%RAM(4)%First_OpenTimecheck= 1
  80. data%Equipments%BopControlPanel%MiddleRamsCloseLED = LedOff !new
  81. data%State%BopStackInput%MiddleRamsCloseLEDMine = LedOff !new
  82. data%Equipments%BopControlPanel%MiddleRamsOpenLED = LedOn !LedBlinking
  83. endif
  84. endif
  85. if (data%State%RAM(4)%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(4)%FourwayValve = 0
  88. data%State%RamLine%ShearBop_closed=0
  89. !ShearBop_closed_withPossibility= ShearBop_closed * TD_BOPConnectionPossibility(3)
  90. data%State%RAM(4)%vdis_tot=0
  91. data%State%RAM(4)%vdis_bottles=0.
  92. data%State%RAM(4)%fvr_air=0.
  93. data%State%RAM(4)%vdis_elecp=0.
  94. data%State%Pumps%Qiter=7
  95. data%State%RAM(4)%Qzero=70
  96. data%State%RAM(4)%Q=data%State%RAM(4)%Qzero
  97. data%State%RAM(4)%flow=70
  98. data%State%RAM(4)%tol=0.0037
  99. if (data%State%RamLine%FINISHED_shear==1) then
  100. data%State%RamLine%ShearRamsLeverOld=1.0
  101. else
  102. data%State%RamLine%ShearRamsLeverOld=data%Equipments%BopControlPanel%MiddleRamsValve
  103. endif
  104. data%State%RamLine%FINISHED_shear=0
  105. data%State%RamLine%ShearRamIsOpening = .true.
  106. data%State%RamLine%ShearRamIsClosing = .false.
  107. data%State%RAM(4)%bop_type = 3
  108. !AbopShearRam=186.5 !(in^2)
  109. data%State%ShearRAM%AbopShearRam=(data%Configuration%BopStack%BlindRamOpen*231)/(data%State%ShearRAM%IDshearBopBase/2.)
  110. !NeededVolumeShearRams=5.5 !galon for each BOP
  111. !NeededVolumeShearRams=BlindRamOpen ! **changed
  112. data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%ShearIsNotAllowed*data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231) !3.67 galon for each BOP ! **changed
  113. !va=AbopShearRam*(IDshearBopBase-ODDrillpipe_inShearRam)/(2.*231)
  114. !vb=NeededVolumeShearRams
  115. endif
  116. !=====================================================================
  117. ! if (ShearRamIsOpening .or. ShearRamIsClosing .or. data%State%RAM(4)%Bottles_Charged_MalfActive) then
  118. ! CALL SHEAR_RAMS_SUB
  119. ! end if
  120. END SUBROUTINE SHEAR_RAMS
  121. SUBROUTINE SHEAR_RAMS_SUB
  122. use SimulationVariables
  123. USE CBopStackVariables
  124. use CBopControlPanel
  125. use SimulationVariables
  126. USE CEquipmentsConstants
  127. ! use CSimulationVariables
  128. implicit none
  129. ! FirstSet= 0
  130. ! RamsFirstSet= 0
  131. ! loop2: do while (finished_shear==0)
  132. data%State%RAM(4)%SuccessionCounter = data%State%RAM(4)%SuccessionCounter + 1
  133. if (data%Equipments%BopControlPanel%MiddleRamsValve == 1.0 .and. data%State%RamLine%ShearRamsLeverOld == -1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1 .and. data%State%RAM(4)%First_CloseTimecheck == 0) then
  134. if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then
  135. data%State%RAM(4)%SuccessionCounter = 0 ! also in starup
  136. data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup
  137. else
  138. data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter
  139. endif
  140. if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  141. data%Equipments%BopControlPanel%MiddleRamsOpenLED = LedOff
  142. data%State%BopStackInput%MiddleRamsOpenLEDMine = LedOff
  143. data%Equipments%BopControlPanel%MiddleRamsCloseLED = LedOn !LedBlinking
  144. data%State%RAM(4)%FourwayValve = 1
  145. endif
  146. endif
  147. if (data%State%RAM(4)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  148. data%State%RAM(4)%FourwayValve = 0
  149. data%State%RamLine%ShearBop_closed=0
  150. data%State%RAM(4)%p_bop=data%State%ShearRAM%PA
  151. data%State%RamLine%ShearRamsLeverOld = data%Equipments%BopControlPanel%MiddleRamsValve
  152. CALL OpenMiddleRams ! for C code
  153. data%State%RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code
  154. data%State%RAM(4)%bop_type = 2
  155. data%State%ShearRAM%AbopShearRam=(data%Configuration%BopStack%BlindRamClose*231)/(data%State%ShearRAM%IDshearBopBase/2.)
  156. data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBop-data%State%ShearRAM%ShearIsNotAllowed*data%State%ShearRAM%ODDrillpipe_inShearRam)/(2.*231) ! **changed
  157. data%State%RAM(4)%vdis_bottles=0.
  158. data%State%RAM(4)%fvr_air=0.
  159. data%State%RAM(4)%vdis_elecp=0.
  160. data%State%RamLine%ShearRamIsClosing = .true.
  161. data%State%RamLine%ShearRamIsOpening = .false.
  162. endif
  163. if (data%Equipments%BopControlPanel%MiddleRamsValve == -1.0 .and. data%State%RamLine%ShearRamsLeverOld == 1.0 .and. data%State%ShearRAM%MiddleRamsFailureMalf==0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1 .and. data%State%RAM(4)%First_OpenTimecheck == 0) then
  164. if ( data%State%RAM(4)%SuccessionCounter /= data%State%RAM(4)%SuccessionCounterOld+1 ) then
  165. data%State%RAM(4)%SuccessionCounter = 0 ! also in starup
  166. data%State%RAM(4)%SuccessionCounterOld = 0 ! also in starup
  167. !return
  168. else
  169. data%State%RAM(4)%SuccessionCounterOld= data%State%RAM(4)%SuccessionCounter
  170. endif
  171. if ( data%State%RAM(4)%SuccessionCounter >= int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  172. data%Equipments%BopControlPanel%MiddleRamsCloseLED = LedOff
  173. data%State%BopStackInput%MiddleRamsCloseLEDMine = LedOff
  174. data%Equipments%BopControlPanel%MiddleRamsOpenLED = LedOn !LedBlinking
  175. data%State%RAM(4)%FourwayValve = 1
  176. endif
  177. endif
  178. if (data%State%RAM(4)%FourwayValve == 1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  179. data%State%RAM(4)%FourwayValve = 0
  180. data%State%RamLine%ShearBop_closed=0
  181. data%State%RAM(4)%p_bop=data%State%ShearRAM%PA
  182. data%State%RamLine%ShearRamsLeverOld = data%Equipments%BopControlPanel%MiddleRamsValve
  183. CALL OpenMiddleRams
  184. data%State%RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code
  185. data%State%RAM(4)%bop_type = 3
  186. data%State%ShearRAM%NeededVolumeShearRams=data%State%ShearRAM%AbopShearRam*(data%State%ShearRAM%IDshearBopBase-data%State%ShearRAM%IDshearBop)/(2.*231)
  187. data%State%RAM(4)%vdis_bottles=0.
  188. data%State%RAM(4)%fvr_air=0.
  189. data%State%RAM(4)%vdis_elecp=0.
  190. data%State%RamLine%ShearRamIsOpening = .true.
  191. data%State%RamLine%ShearRamIsClosing = .false.
  192. endif
  193. data%State%RAM(4)%First_CloseTimecheck = 0
  194. data%State%RAM(4)%First_OpenTimecheck = 0
  195. data%State%RAM(4)%time=data%State%RAM(4)%time+data%State%RamLine%DeltaT_BOP !overal time (s)
  196. !===================================================
  197. ! BOP
  198. !===================================================
  199. if (data%State%RamLine%ShearBop_closed==0) then !bop closing
  200. call bop_code(1,data%State%ShearRAM%H_ShearRamBop,4) !ramtype=1 4=RNUMBER
  201. endif !bop is closing
  202. !================================================================
  203. if (data%State%RamLine%ShearBop_closed==1) then
  204. data%State%RAM(4)%Q=0
  205. data%State%RAM(4)%p_bop=data%State%ShearRAM%PA
  206. data%State%RAMS%minloss(4,17)=0. !RNUMBER=4
  207. endif
  208. data%State%RAM(4)%timecounter_ram=data%State%RAM(4)%timecounter_ram+1
  209. ! commented by mahmood
  210. ! call sleepqq(100)
  211. if (data%State%RamLine%ShearBop_closed==1) then
  212. data%State%RamLine%FINISHED_shear=1
  213. endif
  214. ! if (IsStopped == .true.) return
  215. ! end do loop2 !while finished_shear==0
  216. ! if ( finished_shear==1 .and. data%State%RAM(4)%Bottles_Charged_MalfActive==.true.) then
  217. ! call bop_code(1,H_ShearRamBop,4) !ramtype=1 4=RNUMBER
  218. ! call sleepqq(100)
  219. ! endif
  220. END SUBROUTINE SHEAR_RAMS_SUB