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.
 
 
 
 
 
 

312 lines
13 KiB

  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/Equipments/BopStack/CHOKE_LINE.f90"
  2. SUBROUTINE CHOKE_LINE
  3. use SimulationVariables
  4. USE CAccumulatorVariables
  5. USE CBopStackVariables
  6. use CBopControlPanel
  7. use SimulationVariables
  8. USE CEquipmentsConstants
  9. implicit none
  10. !=====================================================================
  11. ! CHOKE LINE 1- BOP CAMERON Type U 5000
  12. ! START CONDITIONS FOR CHOKE LINE 1
  13. !=====================================================================
  14. data%State%RAM(5)%SuccessionCounter = data%State%RAM(5)%SuccessionCounter + 1
  15. if (data%Equipments%BopControlPanel%ChokeLineValve == -1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  16. if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then
  17. data%State%RAM(5)%SuccessionCounter = 0 ! also in starup
  18. data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup
  19. return
  20. else
  21. data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter
  22. endif
  23. if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  24. return
  25. endif
  26. data%State%RAM(5)%First_CloseTimecheck= 1
  27. if (data%State%BopStackInput%ChokeLineOpenLEDMine == LedOn) then
  28. RETURN
  29. end if
  30. data%State%ChokeLine%closed=0
  31. data%State%RAM(5)%vdis_tot=0
  32. data%State%RAM(5)%vdis_bottles=0.
  33. data%State%RAM(5)%fvr_air=0.
  34. data%State%RAM(5)%vdis_elecp=0.
  35. data%State%Pumps%Qiter=7
  36. data%State%RAM(5)%Qzero=70
  37. data%State%RAM(5)%Q=data%State%RAM(5)%Qzero
  38. data%State%RAM(5)%flow=70
  39. data%State%RAM(5)%tol=0.0037
  40. if (data%State%ChokeLine%finished==1) then
  41. data%State%ChokeLine%LeverOld= 1.0
  42. else
  43. data%State%ChokeLine%LeverOld=data%Equipments%BopControlPanel%ChokeLineValve
  44. endif
  45. data%State%ChokeLine%finished=0
  46. data%State%ChokeLine%IsOpening = .true.
  47. data%Equipments%BopControlPanel%ChokeLineCloseLED = LedOff
  48. data%State%BopStackInput%ChokeLineCloseLEDMine = LedOff
  49. data%Equipments%BopControlPanel%ChokeLineOpenLED = LedOn !LedBlinking
  50. data%State%RAM(5)%bop_type = 3
  51. !AbopChokeLine=196.67
  52. data%State%ChokeLine%Abop=(data%Configuration%BopStack%ChokeClose*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.)
  53. data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%IDBase-max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP
  54. endif
  55. if (data%Equipments%BopControlPanel%ChokeLineValve == 1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  56. if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then
  57. data%State%RAM(5)%SuccessionCounter = 0 ! also in starup
  58. data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup
  59. return
  60. else
  61. data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter
  62. endif
  63. if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  64. return
  65. endif
  66. data%State%RAM(5)%First_OpenTimecheck= 1
  67. if (data%State%BopStackInput%ChokeLineCloseLEDMine == LedOn) then
  68. RETURN
  69. end if
  70. data%State%ChokeLine%closed=0
  71. data%State%RAM(5)%vdis_tot=0
  72. data%State%RAM(5)%vdis_bottles=0.
  73. data%State%RAM(5)%fvr_air=0.
  74. data%State%RAM(5)%vdis_elecp=0.
  75. data%State%Pumps%Qiter=7
  76. data%State%RAM(5)%Qzero=70
  77. data%State%RAM(5)%Q=data%State%RAM(5)%Qzero
  78. data%State%RAM(5)%flow=70
  79. data%State%RAM(5)%tol=0.0037
  80. if (data%State%ChokeLine%finished==1) then
  81. data%State%ChokeLine%LeverOld= -1.0
  82. else
  83. data%State%ChokeLine%LeverOld=data%Equipments%BopControlPanel%ChokeLineValve
  84. endif
  85. data%State%ChokeLine%finished=0
  86. data%State%ChokeLine%IsClosing = .true.
  87. !if (ChokeLineCloseLED == LedOn) then
  88. ! RETURN
  89. !end if
  90. data%Equipments%BopControlPanel%ChokeLineCloseLED = LedOff !new
  91. data%State%BopStackInput%ChokeLineCloseLEDMine = LedOff !new
  92. data%Equipments%BopControlPanel%ChokeLineCloseLED = LedOn !LedBlinking
  93. data%State%RAM(5)%bop_type = 3
  94. !AbopChokeLine=196.67
  95. data%State%ChokeLine%Abop=(data%Configuration%BopStack%ChokeOpen*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.)
  96. data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%IDBase-max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase))/(2.*231) !1.5 galon for each BOP
  97. endif
  98. !=====================================================================
  99. ! if (ChokeLineIsOpening .or. ChokeLineIsClosing) then
  100. ! CALL CHOKE_LINE_SUB
  101. ! end if
  102. END SUBROUTINE CHOKE_LINE
  103. SUBROUTINE CHOKE_LINE_SUB
  104. use SimulationVariables
  105. USE CAccumulatorVariables
  106. USE CBopStackVariables
  107. use CBopControlPanel
  108. use SimulationVariables
  109. USE CEquipmentsConstants
  110. ! use CSimulationVariables
  111. implicit none
  112. ! FirstSet= 0
  113. ! RamsFirstSet= 0
  114. ! loop5: do while (finished_ChokeLine==0)
  115. data%State%RAM(5)%SuccessionCounter = data%State%RAM(5)%SuccessionCounter + 1
  116. if (data%Equipments%BopControlPanel%ChokeLineValve == 1.0 .and. data%State%ChokeLine%LeverOld == -1.0 .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure) then
  117. if ( data%State%RAM(5)%First_CloseTimecheck == 0 ) then
  118. if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then
  119. data%State%RAM(5)%SuccessionCounter = 0 ! also in starup
  120. data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup
  121. return
  122. else
  123. data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter
  124. endif
  125. if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  126. return
  127. endif
  128. endif
  129. data%State%ChokeLine%closed=0
  130. data%State%RAM(5)%p_bop=data%State%ShearRAM%PA
  131. data%State%ChokeLine%LeverOld = data%Equipments%BopControlPanel%ChokeLineValve
  132. data%Equipments%BopControlPanel%ChokeLineOpenLED = LedOff
  133. data%State%BopStackInput%ChokeLineOpenLEDMine = LedOff
  134. data%Equipments%BopControlPanel%ChokeLineCloseLED = LedOn !LedBlinking
  135. CALL OpenChokeLine
  136. data%State%RAM(5)%bop_type = 3
  137. !AbopChokeLine=196.67
  138. data%State%ChokeLine%Abop=(data%Configuration%BopStack%ChokeClose*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.)
  139. data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%ID-max(data%State%ChokeLine%ODDrillpipe_in,data%State%ChokeLine%ODDrillpipe_inBase))/(2.*231)
  140. data%State%RAM(5)%vdis_bottles=0.
  141. data%State%RAM(5)%fvr_air=0.
  142. data%State%RAM(5)%vdis_elecp=0.
  143. data%State%ChokeLine%IsClosing = .true.
  144. data%State%ChokeLine%IsOpening = .false.
  145. endif
  146. if (data%Equipments%BopControlPanel%ChokeLineValve == -1.0 .and. data%State%ChokeLine%LeverOld == 1.0 .and. data%State%RamLine%P_ACC>data%State%BopStackAcc%acc_MinPressure .and. data%State%BopStackAcc%RigAirMalf==0 .and. data%Equipments%BopControlPanel%AirMasterValve==1) then
  147. if ( data%State%RAM(5)%First_OpenTimecheck == 0 ) then
  148. if ( data%State%RAM(5)%SuccessionCounter /= data%State%RAM(5)%SuccessionCounterOld+1 ) then
  149. data%State%RAM(5)%SuccessionCounter = 0 ! also in starup
  150. data%State%RAM(5)%SuccessionCounterOld = 0 ! also in starup
  151. return
  152. else
  153. data%State%RAM(5)%SuccessionCounterOld= data%State%RAM(5)%SuccessionCounter
  154. endif
  155. if ( data%State%RAM(5)%SuccessionCounter < int(2.5/data%State%RamLine%DeltaT_BOP) ) then
  156. return
  157. endif
  158. endif
  159. data%State%ChokeLine%closed=0
  160. data%State%RAM(5)%p_bop=data%State%ShearRAM%PA
  161. data%State%ChokeLine%LeverOld = data%Equipments%BopControlPanel%ChokeLineValve
  162. data%Equipments%BopControlPanel%ChokeLineCloseLED = LedOff
  163. data%State%BopStackInput%ChokeLineCloseLEDMine = LedOff
  164. data%Equipments%BopControlPanel%ChokeLineOpenLED = LedOn !LedBlinking
  165. CALL OpenChokeLine
  166. data%State%RAM(5)%bop_type = 3
  167. !AbopChokeLine=196.67
  168. data%State%ChokeLine%Abop=(data%Configuration%BopStack%ChokeOpen*231)/((data%State%ChokeLine%IDBase-data%State%ChokeLine%ODDrillpipe_inBase)/2.)
  169. data%State%ChokeLine%NeededVolume=data%State%ChokeLine%Abop*(data%State%ChokeLine%IDBase-data%State%ChokeLine%ID)/(2.*231)
  170. data%State%RAM(5)%vdis_bottles=0.
  171. data%State%RAM(5)%fvr_air=0.
  172. data%State%RAM(5)%vdis_elecp=0.
  173. data%State%ChokeLine%IsOpening = .true.
  174. data%State%ChokeLine%IsClosing = .false.
  175. endif
  176. data%State%RAM(5)%First_CloseTimecheck = 0
  177. data%State%RAM(5)%First_OpenTimecheck = 0
  178. data%State%RAM(5)%time=data%State%RAM(5)%time+data%State%RamLine%DeltaT_BOP !overal time (s)
  179. !===================================================
  180. ! BOP
  181. !===================================================
  182. if (data%State%ChokeLine%closed==0) then !bop closing
  183. call bop_code(4,data%State%ChokeLine%H_Bop,5) !ramtype=4 5=RNUMBER
  184. endif !bop is closing
  185. !================================================================
  186. if (data%State%ChokeLine%closed==1) then
  187. data%State%RAM(5)%Q=0
  188. !p_bop=pram_reg
  189. data%State%RAM(5)%p_bop=data%State%ShearRAM%PA
  190. data%State%RAMS%minloss(5,17)=0. !RNUMBER=5
  191. endif
  192. data%State%RAM(5)%timecounter_ram=data%State%RAM(5)%timecounter_ram+1
  193. ! MiddleRamsStatus = IDshearBop
  194. ! UpperRamsStatus = IDPipeRam1
  195. ! LowerRamsStatus = IDPipeRam2
  196. ! AnnularStatus = IDAnnular
  197. ! AccumulatorPressureGauge = p_acc
  198. ! ManifoldPressureGauge= pram_reg
  199. ! AnnularPressureGauge=Pannular_reg
  200. !
  201. !
  202. !
  203. ! WRITE(60,60) data%State%RAM(5)%time,data%State%RAM(5)%Q,data%State%RAM(5)%vdis_tot,p_acc, &
  204. ! pram_reg,Pannular_reg,data%State%RAM(5)%p_bop,IDshearBop, &
  205. ! IDPipeRam1,IDPipeRam2,IDAnnular
  206. !60 FORMAT(11(f18.5))
  207. ! call sleepqq(100)
  208. if (data%State%ChokeLine%closed==1) then
  209. ! if ((UpperRamsValve==1. .and. UpperRamsFailureMalf==0) .or. (UpperRamsValve==-1.0 .and. UpperRamsFailureMalf==0) .or. (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. KillLineValve==1. .or. KillLineValve==-1.0) then
  210. data%State%ChokeLine%finished=1
  211. ! endif
  212. endif
  213. ! if (IsStopped == .true.) return
  214. ! end do loop5 !while finished_ChokeLine==0
  215. END SUBROUTINE CHOKE_LINE_SUB