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.
 
 
 
 
 
 

276 lines
13 KiB

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