Simulation Core
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ChokeControlMain.i90 30 KiB

vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
vor 1 Jahr
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. # 1 "/home/admin/SimulationCore2/Equipments/ChokeControl/ChokeControlMain.f90"
  2. module ChokeControlMain
  3. USE CHOKEVARIABLES
  4. use SimulationVariables !@
  5. implicit none
  6. public
  7. contains
  8. ! subroutine ChokeControl_Setup()
  9. ! ! use CSimulationVariables
  10. ! implicit none
  11. ! call OnSimulationInitialization%Add(ChokeControl_Init)
  12. ! call OnSimulationStop%Add(ChokeControl_Init)
  13. ! call OnChokeControlStep%Add(ChokeControl_Step)
  14. ! call OnChokeControlOutput%Add(ChokeControl_Output)
  15. ! call OnChokeControlMain%Add(ChokeControlMainBody)
  16. ! end subroutine
  17. subroutine ChokeControl_Init
  18. call Choke_StartUp()
  19. end subroutine ChokeControl_Init
  20. subroutine ChokeControl_Step
  21. use ChokeModule
  22. implicit none
  23. INTEGER CHNUMBER
  24. IF(data%Equipments%ChokeControlPanel%ChokeSelectorSwitch) THEN
  25. data%Equipments%ChokeControlPanel%Choke1LED=1
  26. data%Equipments%ChokeControlPanel%Choke2LED=0
  27. CHNUMBER=1
  28. ELSE
  29. data%Equipments%ChokeControlPanel%Choke2LED=1
  30. data%Equipments%ChokeControlPanel%Choke1LED=0
  31. CHNUMBER=2
  32. ENDIF
  33. if(ABS(data%Equipments%ChokeControlPanel%ChokeControlLever)==1.0 .AND. data%Equipments%ChokeControlPanel%ChokePanelRigAirSwitch .AND. data%State%CHOOKE(CHNUMBER)%FailMalf==0 .AND. data%State%AirDrivenPump%ChokeAirFail==0) then
  34. if (data%Equipments%ChokeControlPanel%ChokeControlLever == 1.0) then
  35. data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .true.
  36. data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .false.
  37. endif
  38. if (data%Equipments%ChokeControlPanel%ChokeControlLever == -1.0) then
  39. data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .true.
  40. data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .false.
  41. endif
  42. data%State%AirPumpLine%TIME=data%State%AirPumpLine%TIME+data%State%AirPumpLine%DeltaT_Choke !overal time (s)
  43. call airpump_code_CHOKE(CHNUMBER)
  44. else
  45. call CHOKE_MainBody2()
  46. endif
  47. end subroutine ChokeControl_Step
  48. ! subroutine ChokeControl_Output
  49. ! implicit none
  50. ! end subroutine ChokeControl_Output
  51. ! subroutine ChokeControlMainBody
  52. ! use CRigSizeVariables
  53. ! use CHOKE
  54. ! implicit none
  55. ! CALL Choke_StartUp()
  56. ! loop1: DO
  57. ! CALL CHOKE_MainBody
  58. ! call sleepqq(100)
  59. ! !IF (IsStopped==.true.) THEN
  60. ! ! EXIT loop1
  61. ! !ENDIF
  62. ! !write(*,*) '1111111111111'
  63. ! if(IsStopped) then
  64. ! !write(*,*) '22222222222222'
  65. ! CALL DEALLOCATE_ARRAYS_CHOKE()
  66. ! !write(*,*) '333333333'
  67. ! call Quit()
  68. ! end if
  69. ! ENDDO loop1
  70. ! CLOSE(150)
  71. ! !CALL DEALLOCATE_ARRAYS_CHOKE()
  72. ! end subroutine ChokeControlMainBody
  73. SUBROUTINE Choke_StartUp()
  74. USE CHOKEVARIABLES
  75. use SimulationVariables
  76. USE CChokeProblemsVariables
  77. implicit none
  78. CALL LOSS_INPUTS_CHOKE()
  79. !OPEN(150,FILE='CHOKE_AIRPUMP_OUTPUTS.DAT')
  80. !data%State%CHOOKE(1)%WashoutMalf=1
  81. !data%State%CHOOKE(1)%PlugMalf=0
  82. !data%State%CHOOKE(1)%FailMalf=0
  83. !
  84. !data%State%CHOOKE(2)%WashoutMalf=1
  85. !data%State%CHOOKE(2)%PlugMalf=0
  86. !data%State%CHOOKE(2)%FailMalf=0
  87. !
  88. !
  89. !ChokeAirFail=0
  90. !
  91. !GaugeChokePositionMailf=0
  92. data%State%Choke%kRatio=1.4
  93. data%State%Choke%Cp=0.24
  94. data%State%Choke%CL=0.8
  95. data%State%Choke%x1=0.5
  96. data%State%Choke%LiquidPPG=9.
  97. data%State%Choke%LiquidDensity=data%State%Choke%LiquidPPG*7.48 !lbm/ft**3
  98. data%State%Choke%VL=1.0/data%State%Choke%LiquidDensity !SpecificVolume of Liquid
  99. data%State%Choke%Cv=data%State%Choke%Cp/data%State%Choke%kRatio
  100. data%State%Choke%nPolytripic=1+(data%State%Choke%x1*(data%State%Choke%Cp-data%State%Choke%Cv)/(data%State%Choke%x1*data%State%Choke%Cv+(1-data%State%Choke%x1)*data%State%Choke%CL))
  101. data%State%Choke%VG1=1./0.748 !lbm/ft**3 Specific Volume of Air, Upstream
  102. data%State%Choke%Cdrag=0.8
  103. data%State%Choke%Pwh=1400. !psi
  104. data%State%Choke%Patm=14.7
  105. data%State%Choke%MixDens2=data%State%Choke%x1*data%State%Choke%VG1 !lbm/ft**3
  106. data%State%Choke%epsilon_abs= 1e-5
  107. data%State%Choke%epsilon_step= 1e-5
  108. !ChokeDiameter= 32/64. !in
  109. data%State%CHOOKE%PercentClose= 0.0
  110. !AreaChoke=0.01334635
  111. ! data%State%CHOOKE(1)%AreaChoke=0.01334635
  112. !ChokeAreaFullyOpen = 123.d0 / 64.d0 ! fully open area is 123/64 in^2 = 0.01334635 ft^2
  113. data%State%AirPumpLine%DeltaT_Choke=0.1
  114. !TotalStrokes1=0.
  115. !TotalStrokes2=0.
  116. data%State%Choke%HydraulicChoke1WashoutCoef= 0.0
  117. data%State%Choke%HydraulicChoke2WashoutCoef= 0.0
  118. data%State%Choke%ChokePlugTimeDelay = int(180./data%State%AirPumpLine%DeltaT_Choke) ! =1800 = 180/0.1 : for 3 min delay
  119. data%State%Choke%Present_HydraulicChoke1Plug = REAL(data%problems%ChokeProblems%HydraulicChoke1PluggedPercent)/100.
  120. data%State%Choke%HydraulicChoke1PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke1PluggedPercent
  121. data%State%Choke%Plug1TimeCounter= 0
  122. data%State%Choke%DeltaPlug1Percent = 0.0
  123. data%State%Choke%Present_HydraulicChoke2Plug = REAL(data%problems%ChokeProblems%HydraulicChoke2PluggedPercent)/100.
  124. data%State%Choke%HydraulicChoke2PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke2PluggedPercent
  125. data%State%Choke%Plug2TimeCounter= 0
  126. data%State%Choke%DeltaPlug2Percent = 0.0
  127. !======================AIRPUMP INPUTS(CONSTANTS)===========================
  128. data%State%AirPumpLine%CourseBase= 24. !cm
  129. data%State%CHOOKE%PassedCourse= 0.
  130. data%Equipments%ChokeControlPanel%ChokePosition=0.
  131. data%State%AirPumpLine%Acylinder= PI*(8.**2)/4. ! (CM^2), 8=DIAMETER, 24=course , 3785.412: cm^3 to galon
  132. data%State%CHOOKE%ChokeIsOpening = .false.
  133. data%State%CHOOKE%ChokeIsClosing = .false.
  134. data%State%AirPumpLine%P_AIRP=0
  135. data%State%AirDrivenPump%cc1 = 0.1354; data%State%AirDrivenPump%cc2 = -2.066; data%State%AirDrivenPump%cc3 = -21.09; data%State%AirDrivenPump%cc4 = -51.36; data%State%AirDrivenPump%cc5 = 5935 ! FOR OUTPUT IN GPM
  136. ! cc1 = 4.754e-07; cc2 = -0.0001676; cc3 = -0.03953; cc4 = -2.223; cc5 = 5935 FOR OUTPUT IN IN^3/MIN
  137. data%State%AirPumpLine%Pdownstrem= 4950 !+0.01*Pchoke (psi) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  138. data%State%AirPumpLine%QITER=5. !(gpm)
  139. ! Q=0.0003585; true
  140. data%State%AirPumpLine%TIME=0
  141. data%State%AirPumpLine%TOL_AIR=0.05
  142. data%State%AirPumpLine%alpha_Qair=0
  143. data%State%AirPumpLine%alpha_timeair=0
  144. data%State%AirPumpLine%alpha_Pdownstrem=data%State%AirPumpLine%Pdownstrem
  145. data%State%AirPumpLine%alpha_diffpair=0
  146. data%State%AirPumpLine%alpha_lossesair=0
  147. end
  148. SUBROUTINE DEALLOCATE_ARRAYS_CHOKE()
  149. USE CHOKEVARIABLES
  150. use SimulationVariables !@
  151. implicit none
  152. write(*,*) 'deallocateeeeeeeeeeeee'
  153. !===========================================================================
  154. ! AIR PUMP LOSSES INPUT
  155. !===========================================================================
  156. !if(allocated(PIPINGS_AIRPUMP)) deallocate(PIPINGS_AIRPUMP)
  157. DEALLOCATE (data%State%AirPumpLine%PIPINGS_AIRPUMP,data%State%AirPumpLine%DIAM_AIR_INCH, &
  158. data%State%AirPumpLine%Re_air,data%State%AirPumpLine%AREA_AIR,data%State%AirPumpLine%LENGT_AIR,data%State%AirPumpLine%ROUGHNESS_AIRPLINE,data%State%AirPumpLine%REL_ROUGHAIR, &
  159. data%State%AirPumpLine%fric_air,data%State%AirPumpLine%fricloss_air)
  160. !================================================================
  161. DEALLOCATE (data%State%AirPumpLine%MINORS_AIRPUMP,data%State%AirPumpLine%MINORDIAM_AIR_INCH, &
  162. data%State%AirPumpLine%MINORAREA_AIR,data%State%AirPumpLine%LF_AIR,data%State%AirPumpLine%CV_AIR,data%State%AirPumpLine%NOTE_AIR &
  163. ,data%State%AirPumpLine%minlosspa_air,data%State%AirPumpLine%minloss_air)
  164. END
  165. SUBROUTINE LOSS_INPUTS_CHOKE()
  166. USE CHOKEVARIABLES
  167. use SimulationVariables
  168. implicit none
  169. Integer I
  170. !===========================================================================
  171. ! AIR PUMP LOSSES INPUT
  172. !===========================================================================
  173. data%State%AirPumpLine%NO_PIPINGS_AIRPLINE=1
  174. ALLOCATE (data%State%AirPumpLine%PIPINGS_AIRPUMP(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE,3))
  175. ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
  176. data%State%AirPumpLine%PIPINGS_AIRPUMP(1,1:3)= (/0.5, 60960., 0.03/) !Avg.acc.distance
  177. !60960= 200 ft
  178. ALLOCATE(data%State%AirPumpLine%DIAM_AIR_INCH(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  179. ALLOCATE(data%State%AirPumpLine%Re_air(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  180. ALLOCATE(data%State%AirPumpLine%AREA_AIR(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  181. ALLOCATE(data%State%AirPumpLine%LENGT_AIR(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  182. ALLOCATE(data%State%AirPumpLine%ROUGHNESS_AIRPLINE(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  183. ALLOCATE(data%State%AirPumpLine%REL_ROUGHAIR(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  184. ALLOCATE(data%State%AirPumpLine%fric_air(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  185. ALLOCATE(data%State%AirPumpLine%fricloss_air(data%State%AirPumpLine%NO_PIPINGS_AIRPLINE))
  186. DO I=1,data%State%AirPumpLine%NO_PIPINGS_AIRPLINE
  187. data%State%AirPumpLine%DIAM_AIR_INCH(I)=data%State%AirPumpLine%PIPINGS_AIRPUMP(I,1)
  188. data%State%AirPumpLine%LENGT_AIR(I)=data%State%AirPumpLine%PIPINGS_AIRPUMP(I,2)
  189. data%State%AirPumpLine%ROUGHNESS_AIRPLINE(I)=data%State%AirPumpLine%PIPINGS_AIRPUMP(I,3)
  190. data%State%AirPumpLine%AREA_AIR(I)=PI*(data%State%AirPumpLine%DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m)
  191. data%State%AirPumpLine%REL_ROUGHAIR(I)=data%State%AirPumpLine%ROUGHNESS_AIRPLINE(I)/(data%State%AirPumpLine%DIAM_AIR_INCH(I)*25.4)
  192. !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m)
  193. data%State%AirPumpLine%LENGT_AIR(I)=data%State%AirPumpLine%LENGT_AIR(I)*.001 ! (m)
  194. ENDDO
  195. !================================================================
  196. data%State%AirPumpLine%NO_MINORS_AIRPLINE=6
  197. ALLOCATE (data%State%AirPumpLine%MINORS_AIRPUMP(data%State%AirPumpLine%NO_MINORS_AIRPLINE,4))
  198. ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
  199. data%State%AirPumpLine%MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee
  200. data%State%AirPumpLine%MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow
  201. data%State%AirPumpLine%MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter
  202. data%State%AirPumpLine%MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve
  203. data%State%AirPumpLine%MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve
  204. data%State%AirPumpLine%MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA
  205. ALLOCATE (data%State%AirPumpLine%MINORDIAM_AIR_INCH(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%MINORAREA_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE), &
  206. data%State%AirPumpLine%LF_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%CV_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%NOTE_AIR(data%State%AirPumpLine%NO_MINORS_AIRPLINE) &
  207. ,data%State%AirPumpLine%minlosspa_air(data%State%AirPumpLine%NO_MINORS_AIRPLINE),data%State%AirPumpLine%minloss_air(data%State%AirPumpLine%NO_MINORS_AIRPLINE))
  208. DO I=1,data%State%AirPumpLine%NO_MINORS_AIRPLINE
  209. data%State%AirPumpLine%MINORDIAM_AIR_INCH(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,1)
  210. data%State%AirPumpLine%LF_AIR(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,2)
  211. data%State%AirPumpLine%CV_AIR(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,3)
  212. data%State%AirPumpLine%NOTE_AIR(I)=data%State%AirPumpLine%MINORS_AIRPUMP(I,4)
  213. data%State%AirPumpLine%MINORAREA_AIR(I)=PI*(data%State%AirPumpLine%MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m)
  214. ENDDO
  215. END
  216. ! SUBROUTINE PIPE_RAMS_CHOKE(CHNUMBER)
  217. ! USE CHOKEVARIABLES
  218. ! use ConfigurationVariables !@
  219. ! Use CSimulationVariables
  220. ! implicit none
  221. ! INTEGER CHNUMBER
  222. ! Integer I
  223. ! loop3: do while (ABS(data%Equipments%ChokeControlPanel%ChokeControlLever)==1.0 .AND. data%Equipments%ChokeControlPanel%ChokePanelRigAirSwitch == 1 .AND. data%State%CHOOKE(CHNUMBER)%FailMalf==0 .AND. data%State%AirDrivenPump%ChokeAirFail==0)
  224. ! if (data%Equipments%ChokeControlPanel%ChokeControlLever == 1.0) then
  225. ! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .true.
  226. ! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .false.
  227. ! endif
  228. ! if (data%Equipments%ChokeControlPanel%ChokeControlLever == -1.0) then
  229. ! data%State%CHOOKE(CHNUMBER)%ChokeIsOpening = .true.
  230. ! data%State%CHOOKE(CHNUMBER)%ChokeIsClosing = .false.
  231. ! endif
  232. ! data%State%AirPumpLine%TIME=data%State%AirPumpLine%TIME+data%State%AirPumpLine%DeltaT_Choke !overal time (s)
  233. ! call airpump_code_CHOKE(CHNUMBER)
  234. ! call sleepqq(100)
  235. ! if (IsStopped == .true.) return
  236. ! end do loop3 !while finished_Choke==0
  237. ! end
  238. SUBROUTINE airpump_code_CHOKE(CHNUMBER)
  239. USE CHOKEVARIABLES
  240. use SimulationVariables !@
  241. use CChokeManifold
  242. use SimulationVariables
  243. use CSounds
  244. USE CChokeProblemsVariables
  245. implicit none
  246. Integer I
  247. INTEGER CHNUMBER
  248. data%State%AirDrivenPump%QAIR_PUMP=data%State%AirPumpLine%QITER+.1 !(gpm) maximum flow for the start
  249. data%State%AirPumpLine%diffp_air=-10
  250. data%State%AirPumpLine%losses_air=10
  251. !===================================================================
  252. ! AIR OPERATED PUMP
  253. ! MODEL 10-6000W030 RATIO 55:1
  254. !=================for air consumption at 100 psig===================
  255. do while (data%State%AirPumpLine%diffp_air<0)
  256. data%State%AirDrivenPump%QAIR_PUMP=data%State%AirDrivenPump%QAIR_PUMP-.1
  257. ! Qup=data%State%AirDrivenPump%QAIR_PUMP;
  258. !cc1 = 1354; cc2 = -2066; cc3 = -2109; cc4 = -513.6; cc5 = 5935 FOR OUTPUT IN GPM
  259. data%State%AirPumpLine%P_AIRP=data%State%AirDrivenPump%cc1*(data%State%AirDrivenPump%QAIR_PUMP**4) + data%State%AirDrivenPump%cc2*(data%State%AirDrivenPump%QAIR_PUMP**3) + data%State%AirDrivenPump%cc3*(data%State%AirDrivenPump%QAIR_PUMP**2) + data%State%AirDrivenPump%cc4*data%State%AirDrivenPump%QAIR_PUMP + data%State%AirDrivenPump%cc5 !(psig)
  260. ! kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-5/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
  261. data%State%AirPumpLine%diffp_air= data%State%AirPumpLine%P_AIRP - data%State%AirPumpLine%Pdownstrem
  262. end do !returns Qup
  263. do while (abs((data%State%AirPumpLine%diffp_air-data%State%AirPumpLine%losses_air)/data%State%AirPumpLine%diffp_air)>data%State%AirPumpLine%TOL_AIR) !finding correct QAIR_pump for 1 timecounter_ram
  264. if (data%State%AirPumpLine%diffp_air-data%State%AirPumpLine%losses_air>0) then
  265. data%State%AirDrivenPump%QAIR_PUMP=data%State%AirDrivenPump%QAIR_PUMP+.005
  266. else
  267. data%State%AirDrivenPump%QAIR_PUMP=data%State%AirDrivenPump%QAIR_PUMP-.005
  268. endif
  269. !===================================================================
  270. ! AIR OPERATED PUMP
  271. ! MODEL 10-6000W030 RATIO 55:1
  272. !=================for air consumption at 100 psig===================
  273. data%State%AirPumpLine%P_AIRP=data%State%AirDrivenPump%cc1*(data%State%AirDrivenPump%QAIR_PUMP**4) + data%State%AirDrivenPump%cc2*(data%State%AirDrivenPump%QAIR_PUMP**3) + data%State%AirDrivenPump%cc3*(data%State%AirDrivenPump%QAIR_PUMP**2) + data%State%AirDrivenPump%cc4*data%State%AirDrivenPump%QAIR_PUMP + data%State%AirDrivenPump%cc5 !(psig)
  274. !kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-005/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
  275. data%State%AirPumpLine%diffp_air= data%State%AirPumpLine%P_AIRP - data%State%AirPumpLine%Pdownstrem
  276. !===========================LOSSES====================================
  277. do i=1,data%State%AirPumpLine%NO_PIPINGS_AIRPLINE
  278. data%State%AirPumpLine%Re_air(i)=data%State%AirDrivenPump%QAIR_PUMP*6.30902e-005*data%State%AirPumpLine%DIAM_AIR_INCH(I)*0.0254/(data%State%AirPumpLine%AREA_AIR(i)*nu)
  279. enddo
  280. do i=1,data%State%AirPumpLine%NO_PIPINGS_AIRPLINE
  281. if (data%State%AirPumpLine%Re_air(i)<Re_cr) then
  282. data%State%AirPumpLine%fric_air(i)=64/data%State%AirPumpLine%Re_air(i)
  283. else
  284. data%State%AirPumpLine%fric_air(i)=1/(-1.8*log10((data%State%AirPumpLine%REL_ROUGHAIR(i)/3.7)**1.11+6.9/data%State%AirPumpLine%Re_air(i)))**2
  285. endif
  286. data%State%AirPumpLine%fricloss_air(i)=((data%State%AirPumpLine%fric_air(i)*(wdens*sg*data%State%AirPumpLine%LENGT_AIR(i)*(data%State%AirDrivenPump%QAIR_PUMP*6.30902e-005/data%State%AirPumpLine%AREA_AIR(i))**2))/(2*data%State%AirPumpLine%DIAM_AIR_INCH(I)*0.0254))/6895
  287. enddo
  288. data%State%AirPumpLine%pipe_loss1air=sum(data%State%AirPumpLine%fricloss_air) !loss before regulator(psi)
  289. do i=1,data%State%AirPumpLine%NO_MINORS_AIRPLINE
  290. if (data%State%AirPumpLine%LF_AIR(i)/=0) then
  291. data%State%AirPumpLine%minlosspa_air(i)=data%State%AirPumpLine%LF_AIR(i)*wdens*sg*(data%State%AirDrivenPump%QAIR_PUMP*6.30902e-005/data%State%AirPumpLine%MINORAREA_AIR(i))**2/2 !(Pa)
  292. data%State%AirPumpLine%minloss_air(i)=data%State%AirPumpLine%minlosspa_air(i)/6895 !(psi)
  293. elseif (data%State%AirPumpLine%CV_AIR(i)/=0) then
  294. data%State%AirPumpLine%minlosspa_air(i)=1000*sg*((11.7*data%State%AirDrivenPump%QAIR_PUMP*6.30902e-005*3600)/(data%State%AirPumpLine%CV_AIR(i)))**2 !(pa)
  295. data%State%AirPumpLine%minloss_air(i)=data%State%AirPumpLine%minlosspa_air(i)/6895 !(psi)
  296. else
  297. data%State%AirPumpLine%minlosspa_air(i)=data%State%AirPumpLine%NOTE_AIR(i)*1e5 !(pa)
  298. data%State%AirPumpLine%minloss_air(i)=data%State%AirPumpLine%minlosspa_air(i)/6895 !(psi)
  299. endif
  300. enddo
  301. data%State%AirPumpLine%minor_loss1air=sum(data%State%AirPumpLine%minloss_air) !loss before regulator(psi)
  302. data%State%AirPumpLine%static_loss1air=0
  303. data%State%AirPumpLine%losses_air=data%State%AirPumpLine%pipe_loss1air+data%State%AirPumpLine%minor_loss1air+data%State%AirPumpLine%static_loss1air !(psi)
  304. !=========================================================================
  305. end do !returns correct QAIR_PUMP for 1 counter
  306. data%State%AirPumpLine%QITER=data%State%AirDrivenPump%QAIR_PUMP
  307. data%State%AirDrivenPump%QAIR_PUMP=data%State%AirDrivenPump%QAIR_PUMP*(data%Equipments%ChokeControlPanel%ChokeRateControlKnob/10.) ! final Q (gpm)
  308. data%State%Choke%Cumulative_AirVolume_Choke= data%State%Choke%Cumulative_AirVolume_Choke + ((data%State%AirDrivenPump%QAIR_PUMP * data%State%AirPumpLine%DeltaT_Choke / 60.0 ) / (1.5*0.004329004) ) ! =strokes
  309. if ( data%State%Choke%Cumulative_AirVolume_Choke > 1.0 ) then
  310. data%State%Choke%SoundChokePump= 60
  311. data%State%Choke%Cumulative_AirVolume_Choke= data%State%Choke%Cumulative_AirVolume_Choke - 1.0
  312. else
  313. data%State%Choke%SoundChokePump= 0.0
  314. endif
  315. data%State%AirPumpLine%DELTAV_AIR=data%State%AirDrivenPump%QAIR_PUMP*data%State%AirPumpLine%DeltaT_Choke/60 !(galon) delta_t=1sec , Q(gpm)
  316. if (data%State%CHOOKE(CHNUMBER)%ChokeIsClosing) data%State%CHOOKE(CHNUMBER)%PassedCourse=data%State%CHOOKE(CHNUMBER)%PassedCourse + (data%State%AirPumpLine%DELTAV_AIR*3785.412/data%State%AirPumpLine%Acylinder)!*(ChokeRateControlKnob/10.) ! 3785.412 : GALON TO CM^3
  317. if (data%State%CHOOKE(CHNUMBER)%ChokeIsOpening) data%State%CHOOKE(CHNUMBER)%PassedCourse=data%State%CHOOKE(CHNUMBER)%PassedCourse - (data%State%AirPumpLine%DELTAV_AIR*3785.412/data%State%AirPumpLine%Acylinder)!*(ChokeRateControlKnob/10.)
  318. !DeltaT_Choke= 1sec or 2sec
  319. !((((((((IN OUTER LOOP))))))
  320. !===============AIR PUMP OUTPUTS=========================
  321. data%State%AirPumpLine%alpha_timeair=data%State%AirPumpLine%TIME ! overal time (s)
  322. data%State%AirPumpLine%alpha_Pdownstrem=data%State%AirPumpLine%Pdownstrem
  323. data%State%AirPumpLine%alpha_pairp=data%State%AirPumpLine%P_AIRP
  324. data%State%AirPumpLine%alpha_Qair=data%State%AirDrivenPump%QAIR_PUMP
  325. !write(*,*) 'diffp_air=',diffp_air
  326. !pause
  327. data%State%AirPumpLine%alpha_diffpair=data%State%AirPumpLine%diffp_air
  328. data%State%AirPumpLine%alpha_lossesair=data%State%AirPumpLine%losses_air
  329. !========================================================
  330. !OPEN(150,FILE='CHOKE_AIRPUMP_OUTPUTS.DAT')
  331. if (data%State%CHOOKE(CHNUMBER)%ChokeIsClosing .AND. data%State%CHOOKE(CHNUMBER)%PassedCourse>data%State%AirPumpLine%CourseBase) then
  332. data%State%CHOOKE(CHNUMBER)%PassedCourse=data%State%AirPumpLine%CourseBase
  333. data%State%Choke%SoundChokePump= 0.0
  334. endif
  335. if (data%State%CHOOKE(CHNUMBER)%ChokeIsOpening .AND. data%State%CHOOKE(CHNUMBER)%PassedCourse<0.) then
  336. data%State%CHOOKE(CHNUMBER)%PassedCourse=0.
  337. data%State%Choke%SoundChokePump= 0.0
  338. endif
  339. call SetSoundChokePump(data%State%Choke%SoundChokePump)
  340. data%State%CHOOKE(CHNUMBER)%PercentClose= data%State%CHOOKE(CHNUMBER)%PassedCourse/data%State%AirPumpLine%CourseBase
  341. IF (data%Equipments%ChokeControlPanel%Choke1LED==1) THEN
  342. data%Equipments%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%CHOOKE(1)%PercentClose*10
  343. ELSE ! Choke2LED==1
  344. data%Equipments%ChokeControlPanel%ChokePosition= (1 - data%State%Choke%GaugeChokePositionMailf) * data%State%CHOOKE(2)%PercentClose*10
  345. ENDIF
  346. !CALL SetHydraulicChock1(nint(MIN(data%State%CHOOKE(1)%PercentClose / 0.91 , 1.0)*100))
  347. ! CALL SetHydraulicChock2(nint(MIN(data%State%CHOOKE(2)%PercentClose / 0.91 , 1.0)*100))
  348. ! .91 >> 9 percent clearance
  349. ! =================== calculating Area
  350. ! AreaChoke=0.5
  351. ! .91 >> 9 percent clearance
  352. data%State%CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(data%State%CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2)
  353. data%State%CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(data%State%CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2
  354. data%State%Choke%HydraulicChoke1WashoutCoef= data%State%Choke%HydraulicChoke1WashoutCoef * data%State%CHOOKE(1)%WashoutMalf
  355. data%State%Choke%HydraulicChoke1WashoutCoef= MIN( 0.5 , data%State%Choke%HydraulicChoke1WashoutCoef+ data%State%CHOOKE(1)%WashoutMalf*(0.5/(60.0/data%State%AirPumpLine%DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time
  356. data%State%Choke%HydraulicChoke2WashoutCoef= data%State%Choke%HydraulicChoke2WashoutCoef * data%State%CHOOKE(2)%WashoutMalf
  357. data%State%Choke%HydraulicChoke2WashoutCoef= MIN( 0.5 , data%State%Choke%HydraulicChoke2WashoutCoef+ data%State%CHOOKE(2)%WashoutMalf*(0.5/(60.0/data%State%AirPumpLine%DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time
  358. !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef
  359. IF (data%State%CHOOKE(1)%PlugMalf == 1) THEN
  360. data%State%Choke%Present_HydraulicChoke1Plug= data%State%Choke%Present_HydraulicChoke1Plug * data%State%CHOOKE(1)%PlugMalf
  361. ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  362. ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent
  363. !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent
  364. if ( (data%problems%ChokeProblems%HydraulicChoke1PluggedPercent - data%State%Choke%HydraulicChoke1PluggedPercent_Old) /= 0) then
  365. data%State%Choke%DeltaPlug1Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke1PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke1Plug
  366. data%State%Choke%Plug1TimeCounter = 0
  367. !write(*,*) 'DeltaPlug1Percent, Present_HydraulicChoke1Plug = ' ,DeltaPlug1Percent , Present_HydraulicChoke1Plug
  368. endif
  369. data%State%Choke%Plug1TimeCounter= data%State%Choke%Plug1TimeCounter + 1
  370. data%State%Choke%HydraulicChoke1PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke1PluggedPercent
  371. if (data%State%Choke%Plug1TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=600
  372. data%State%Choke%Present_HydraulicChoke1Plug = data%State%Choke%Present_HydraulicChoke1Plug + data%State%CHOOKE(1)%PlugMalf* ((data%State%Choke%DeltaPlug1Percent / real(data%State%Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0
  373. endif
  374. !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug
  375. ENDIF
  376. IF (data%State%CHOOKE(2)%PlugMalf == 1) THEN
  377. data%State%Choke%Present_HydraulicChoke2Plug= data%State%Choke%Present_HydraulicChoke2Plug * data%State%CHOOKE(2)%PlugMalf
  378. ! integer: HydraulicChoke2PluggedPercent,HydraulicChoke2PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  379. ! real: Present_HydraulicChoke2Plug,DeltaPlug2Percent
  380. if ( (data%problems%ChokeProblems%HydraulicChoke2PluggedPercent - data%State%Choke%HydraulicChoke2PluggedPercent_Old) /= 0 ) then
  381. data%State%Choke%DeltaPlug2Percent = (REAL(data%problems%ChokeProblems%HydraulicChoke2PluggedPercent)/100.) - data%State%Choke%Present_HydraulicChoke2Plug
  382. data%State%Choke%Plug2TimeCounter = 0
  383. endif
  384. data%State%Choke%Plug2TimeCounter= data%State%Choke%Plug2TimeCounter + 1
  385. data%State%Choke%HydraulicChoke2PluggedPercent_Old= data%problems%ChokeProblems%HydraulicChoke2PluggedPercent
  386. if (data%State%Choke%Plug2TimeCounter <= data%State%Choke%ChokePlugTimeDelay) then !ChokePlugTimeDelay=600
  387. data%State%Choke%Present_HydraulicChoke2Plug = data%State%Choke%Present_HydraulicChoke2Plug + data%State%CHOOKE(2)%PlugMalf *((data%State%Choke%DeltaPlug2Percent / real(data%State%Choke%ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0
  388. endif
  389. ENDIF
  390. ! fully open area is 123/64 in^2 = 0.01334635 ft^2
  391. data%State%CHOOKE(1)%AreaChoke=data%State%CHOOKE(1)%AreaChoke+(data%State%CHOOKE(1)%WashoutMalf*data%State%Choke%HydraulicChoke1WashoutCoef*data%State%Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  392. !write(*,*) 'data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke=' ,data%State%CHOOKE(1)%WashoutMalf , data%State%CHOOKE(1)%AreaChoke
  393. data%State%CHOOKE(1)%AreaChoke=data%State%CHOOKE(1)%AreaChoke-(data%State%CHOOKE(1)%PlugMalf* data%State%Choke%Present_HydraulicChoke1Plug *data%State%CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup
  394. data%State%CHOOKE(2)%AreaChoke=data%State%CHOOKE(2)%AreaChoke+(data%State%CHOOKE(2)%WashoutMalf*data%State%Choke%HydraulicChoke2WashoutCoef*data%State%Choke%ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  395. data%State%CHOOKE(2)%AreaChoke=data%State%CHOOKE(2)%AreaChoke-(data%State%CHOOKE(2)%PlugMalf* data%State%Choke%Present_HydraulicChoke2Plug *data%State%CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup
  396. !write(*,*) 'data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke=' ,data%State%CHOOKE(2)%WashoutMalf , data%State%CHOOKE(2)%AreaChoke
  397. data%State%CHOOKE(1)%AreaChokeFinal= data%State%CHOOKE(1)%AreaChoke
  398. data%State%CHOOKE(2)%AreaChokeFinal= data%State%CHOOKE(2)%AreaChoke
  399. ! 144: ft^2 to in^2
  400. CALL SetHydraulicChock1(100 - nint((data%State%CHOOKE(1)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  401. CALL SetHydraulicChock2(100 - nint((data%State%CHOOKE(2)%AreaChokeFinal/(data%State%Choke%ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  402. !write(*,*) 'data%State%CHOOKE(1)%PercentClose=' , data%State%CHOOKE(1)%PercentClose ! close percent 0 to 100
  403. !write(*,*) 'ChokePosition=' , ChokePosition ! close position 0 to 10 for display
  404. !write(*,*) 'data%State%CHOOKE(1)%AreaChokeFinal=' , data%State%CHOOKE(1)%AreaChokeFinal ! Open Area (in^2) with clearance
  405. !write(*,*) '(ChokeAreaFullyOpen/144.)=' , (ChokeAreaFullyOpen/144.)
  406. !write(*,*) 'valve value=' , 100 - nint((data%State%CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100) ! percent close 0 to 100 with clearance
  407. !write(*,*) 'Valve(33)%Status=' , Valve(33)%Status ! T : open , F: close
  408. ! =================== calculating Area
  409. !write(*,*) 'data%State%CHOOKE(1)%AreaChoke= ' , data%State%CHOOKE(1)%AreaChoke
  410. !WRITE(150,50) alpha_timeair,alpha_Qair,alpha_pairp, &
  411. !alpha_Pdownstrem,alpha_diffpair,alpha_lossesair,data%State%CHOOKE(CHNUMBER)%PassedCourse
  412. !50 FORMAT(7(f15.5))
  413. !========================================================================================
  414. !========================================================================================
  415. ! write(*,*) PassedCourse
  416. end
  417. end module ChokeControlMain