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.
 
 
 
 
 
 

455 lines
15 KiB

  1. SUBROUTINE DEALLOCATE_ARRAYS_CHOKE()
  2. USE CHOKEVARIABLES
  3. implicit none
  4. write(*,*) 'deallocateeeeeeeeeeeee'
  5. !===========================================================================
  6. ! AIR PUMP LOSSES INPUT
  7. !===========================================================================
  8. !if(allocated(PIPINGS_AIRPUMP)) deallocate(PIPINGS_AIRPUMP)
  9. DEALLOCATE (PIPINGS_AIRPUMP,DIAM_AIR_INCH, &
  10. Re_air,AREA_AIR,LENGT_AIR,ROUGHNESS_AIRPLINE,REL_ROUGHAIR, &
  11. fric_air,fricloss_air)
  12. !================================================================
  13. DEALLOCATE (MINORS_AIRPUMP,MINORDIAM_AIR_INCH, &
  14. MINORAREA_AIR,LF_AIR,CV_AIR,NOTE_AIR &
  15. ,minlosspa_air,minloss_air)
  16. END
  17. SUBROUTINE LOSS_INPUTS_CHOKE()
  18. USE CHOKEVARIABLES
  19. implicit none
  20. Integer I
  21. !===========================================================================
  22. ! AIR PUMP LOSSES INPUT
  23. !===========================================================================
  24. NO_PIPINGS_AIRPLINE=1
  25. ALLOCATE (PIPINGS_AIRPUMP(NO_PIPINGS_AIRPLINE,3))
  26. ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
  27. PIPINGS_AIRPUMP(1,1:3)= (/0.5, 60960., 0.03/) !Avg.acc.distance
  28. !60960= 200 ft
  29. ALLOCATE (DIAM_AIR_INCH(NO_PIPINGS_AIRPLINE),Re_air(NO_PIPINGS_AIRPLINE),AREA_AIR(NO_PIPINGS_AIRPLINE), &
  30. LENGT_AIR(NO_PIPINGS_AIRPLINE),ROUGHNESS_AIRPLINE(NO_PIPINGS_AIRPLINE),REL_ROUGHAIR(NO_PIPINGS_AIRPLINE), &
  31. fric_air(NO_PIPINGS_AIRPLINE),fricloss_air(NO_PIPINGS_AIRPLINE))
  32. DO I=1,NO_PIPINGS_AIRPLINE
  33. DIAM_AIR_INCH(I)=PIPINGS_AIRPUMP(I,1)
  34. LENGT_AIR(I)=PIPINGS_AIRPUMP(I,2)
  35. ROUGHNESS_AIRPLINE(I)=PIPINGS_AIRPUMP(I,3)
  36. AREA_AIR(I)=PI*(DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m)
  37. REL_ROUGHAIR(I)=ROUGHNESS_AIRPLINE(I)/(DIAM_AIR_INCH(I)*25.4)
  38. !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m)
  39. LENGT_AIR(I)=LENGT_AIR(I)*.001 ! (m)
  40. ENDDO
  41. !================================================================
  42. NO_MINORS_AIRPLINE=6
  43. ALLOCATE (MINORS_AIRPUMP(NO_MINORS_AIRPLINE,4))
  44. ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
  45. MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee
  46. MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow
  47. MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter
  48. MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve
  49. MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve
  50. MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA
  51. ALLOCATE (MINORDIAM_AIR_INCH(NO_MINORS_AIRPLINE),MINORAREA_AIR(NO_MINORS_AIRPLINE), &
  52. LF_AIR(NO_MINORS_AIRPLINE),CV_AIR(NO_MINORS_AIRPLINE),NOTE_AIR(NO_MINORS_AIRPLINE) &
  53. ,minlosspa_air(NO_MINORS_AIRPLINE),minloss_air(NO_MINORS_AIRPLINE))
  54. DO I=1,NO_MINORS_AIRPLINE
  55. MINORDIAM_AIR_INCH(I)=MINORS_AIRPUMP(I,1)
  56. LF_AIR(I)=MINORS_AIRPUMP(I,2)
  57. CV_AIR(I)=MINORS_AIRPUMP(I,3)
  58. NOTE_AIR(I)=MINORS_AIRPUMP(I,4)
  59. MINORAREA_AIR(I)=PI*(MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m)
  60. ENDDO
  61. END
  62. SUBROUTINE PIPE_RAMS_CHOKE(CHNUMBER)
  63. USE CHOKEVARIABLES
  64. implicit none
  65. INTEGER CHNUMBER
  66. Integer I
  67. loop3: do while (ABS(ChokeControlLever)==1.0 .AND. ChokePanelRigAirSwitch == 1 .AND. CHOOKE(CHNUMBER)%FailMalf==0 .AND. ChokeAirFail==0)
  68. if (ChokeControlLever == 1.0) then
  69. CHOOKE(CHNUMBER)%ChokeIsClosing = .true.
  70. CHOOKE(CHNUMBER)%ChokeIsOpening = .false.
  71. endif
  72. if (ChokeControlLever == -1.0) then
  73. CHOOKE(CHNUMBER)%ChokeIsOpening = .true.
  74. CHOOKE(CHNUMBER)%ChokeIsClosing = .false.
  75. endif
  76. time=time+DeltaT_Choke !overal time (s)
  77. !====================================================
  78. ! ********************************
  79. call airpump_code_CHOKE(CHNUMBER)
  80. ! *************************
  81. !====================================================
  82. call sleepqq(100)
  83. if (IsStopped == .true.) return
  84. end do loop3 !while finished_Choke==0
  85. end
  86. SUBROUTINE airpump_code_CHOKE(CHNUMBER)
  87. USE CHOKEVARIABLES
  88. USE CChokeManifoldVariables
  89. use CSounds
  90. USE CChokeProblemsVariables
  91. implicit none
  92. Integer I
  93. INTEGER CHNUMBER
  94. QAIR_PUMP=Qiter+.1 !(gpm) maximum flow for the start
  95. diffp_air=-10
  96. losses_air=10
  97. !===================================================================
  98. ! AIR OPERATED PUMP
  99. ! MODEL 10-6000W030 RATIO 55:1
  100. !=================for air consumption at 100 psig===================
  101. do while (diffp_air<0)
  102. QAIR_PUMP=QAIR_PUMP-.1
  103. ! Qup=QAIR_PUMP;
  104. !cc1 = 1354; cc2 = -2066; cc3 = -2109; cc4 = -513.6; cc5 = 5935 FOR OUTPUT IN GPM
  105. p_airp=cc1*(QAIR_PUMP**4) + cc2*(QAIR_PUMP**3) + cc3*(QAIR_PUMP**2) + cc4*QAIR_PUMP + cc5 !(psig)
  106. ! kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-5/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
  107. diffp_air= p_airp - Pdownstrem
  108. end do !returns Qup
  109. do while (abs((diffp_air-losses_air)/diffp_air)>tol_air) !finding correct QAIR_pump for 1 timecounter_ram
  110. if (diffp_air-losses_air>0) then
  111. QAIR_PUMP=QAIR_PUMP+.005
  112. else
  113. QAIR_PUMP=QAIR_PUMP-.005
  114. endif
  115. !===================================================================
  116. ! AIR OPERATED PUMP
  117. ! MODEL 10-6000W030 RATIO 55:1
  118. !=================for air consumption at 100 psig===================
  119. p_airp=cc1*(QAIR_PUMP**4) + cc2*(QAIR_PUMP**3) + cc3*(QAIR_PUMP**2) + cc4*QAIR_PUMP + cc5 !(psig)
  120. !kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-005/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
  121. diffp_air= p_airp - Pdownstrem
  122. !===========================LOSSES====================================
  123. do i=1,NO_PIPINGS_AIRPLINE
  124. Re_air(i)=QAIR_PUMP*6.30902e-005*DIAM_AIR_INCH(I)*0.0254/(area_air(i)*nu)
  125. enddo
  126. do i=1,NO_PIPINGS_AIRPLINE
  127. if (Re_air(i)<Re_cr) then
  128. fric_air(i)=64/Re_air(i)
  129. else
  130. fric_air(i)=1/(-1.8*log10((rel_roughair(i)/3.7)**1.11+6.9/Re_air(i)))**2
  131. endif
  132. fricloss_air(i)=((fric_air(i)*(wdens*sg*lengt_air(i)*(QAIR_PUMP*6.30902e-005/area_air(i))**2))/(2*DIAM_AIR_INCH(I)*0.0254))/6895
  133. enddo
  134. pipe_loss1air=sum(fricloss_air) !loss before regulator(psi)
  135. do i=1,NO_MINORS_AIRPLINE
  136. if (LF_air(i)/=0) then
  137. minlosspa_air(i)=LF_air(i)*wdens*sg*(QAIR_PUMP*6.30902e-005/MINORAREA_AIR(i))**2/2 !(Pa)
  138. minloss_air(i)=minlosspa_air(i)/6895 !(psi)
  139. elseif (CV_air(i)/=0) then
  140. minlosspa_air(i)=1000*sg*((11.7*QAIR_PUMP*6.30902e-005*3600)/(CV_air(i)))**2 !(pa)
  141. minloss_air(i)=minlosspa_air(i)/6895 !(psi)
  142. else
  143. minlosspa_air(i)=NOTE_air(i)*1e5 !(pa)
  144. minloss_air(i)=minlosspa_air(i)/6895 !(psi)
  145. endif
  146. enddo
  147. minor_loss1air=sum(minloss_air) !loss before regulator(psi)
  148. static_loss1air=0
  149. losses_air=pipe_loss1air+minor_loss1air+static_loss1air !(psi)
  150. !=========================================================================
  151. end do !returns correct QAIR_PUMP for 1 counter
  152. Qiter=QAIR_PUMP
  153. QAIR_PUMP=QAIR_PUMP*(ChokeRateControlKnob/10.) ! final Q (gpm)
  154. Cumulative_AirVolume_Choke= Cumulative_AirVolume_Choke + ((QAIR_PUMP * DeltaT_Choke / 60.0 ) / (1.5*0.004329004) ) ! =strokes
  155. if ( Cumulative_AirVolume_Choke > 1.0 ) then
  156. SoundChokePump= 60
  157. Cumulative_AirVolume_Choke= Cumulative_AirVolume_Choke - 1.0
  158. else
  159. SoundChokePump= 0.0
  160. endif
  161. !SoundChokePump= int (QAIR_PUMP/ (1.5*0.004329004)*DeltaT_Choke/60.0) ! 1.5: Volume per stroke (in^3) , 0.004329004: in^3 to gal , 60:seconds
  162. deltav_air=QAIR_PUMP*DeltaT_Choke/60 !(galon) delta_t=1sec , Q(gpm)
  163. if (CHOOKE(CHNUMBER)%ChokeIsClosing) CHOOKE(CHNUMBER)%PassedCourse=CHOOKE(CHNUMBER)%PassedCourse + (deltav_air*3785.412/Acylinder)!*(ChokeRateControlKnob/10.) ! 3785.412 : GALON TO CM^3
  164. if (CHOOKE(CHNUMBER)%ChokeIsOpening) CHOOKE(CHNUMBER)%PassedCourse=CHOOKE(CHNUMBER)%PassedCourse - (deltav_air*3785.412/Acylinder)!*(ChokeRateControlKnob/10.)
  165. !DeltaT_Choke= 1sec or 2sec
  166. !((((((((IN OUTER LOOP))))))
  167. !===============AIR PUMP OUTPUTS=========================
  168. alpha_timeair=time ! overal time (s)
  169. alpha_Pdownstrem=Pdownstrem
  170. alpha_pairp=p_airp
  171. alpha_Qair=QAIR_PUMP
  172. !write(*,*) 'diffp_air=',diffp_air
  173. !pause
  174. alpha_diffpair=diffp_air
  175. alpha_lossesair=losses_air
  176. !========================================================
  177. !OPEN(150,FILE='CHOKE_AIRPUMP_OUTPUTS.DAT')
  178. if (CHOOKE(CHNUMBER)%ChokeIsClosing .AND. CHOOKE(CHNUMBER)%PassedCourse>CourseBase) then
  179. CHOOKE(CHNUMBER)%PassedCourse=CourseBase
  180. SoundChokePump= 0.0
  181. endif
  182. if (CHOOKE(CHNUMBER)%ChokeIsOpening .AND. CHOOKE(CHNUMBER)%PassedCourse<0.) then
  183. CHOOKE(CHNUMBER)%PassedCourse=0.
  184. SoundChokePump= 0.0
  185. endif
  186. call SetSoundChokePump(SoundChokePump)
  187. CHOOKE(CHNUMBER)%PercentClose= CHOOKE(CHNUMBER)%PassedCourse/CourseBase
  188. IF (Choke1LED==1) THEN
  189. ChokePosition= (1 - GaugeChokePositionMailf) * CHOOKE(1)%PercentClose*10
  190. ELSE ! Choke2LED==1
  191. ChokePosition= (1 - GaugeChokePositionMailf) * CHOOKE(2)%PercentClose*10
  192. ENDIF
  193. !CALL SetHydraulicChock1(nint(MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)*100))
  194. ! CALL SetHydraulicChock2(nint(MIN(CHOOKE(2)%PercentClose / 0.91 , 1.0)*100))
  195. ! .91 >> 9 percent clearance
  196. ! =================== calculating Area
  197. ! AreaChoke=0.5
  198. ! .91 >> 9 percent clearance
  199. CHOOKE(1)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(1)%PercentClose / 0.91 , 1.0)) !ft^2 0.01334635 is ChokeAreaFullyOpen (ft^2)
  200. CHOOKE(2)%AreaChoke=0.01334635-(0.01334635* MIN(CHOOKE(2)%PercentClose/ 0.91 , 1.0)) !ft^2
  201. !write(*,*) 'CHOOKE(1)%AreaChoke= ' , CHOOKE(1)%AreaChoke
  202. HydraulicChoke1WashoutCoef= HydraulicChoke1WashoutCoef * CHOOKE(1)%WashoutMalf
  203. HydraulicChoke1WashoutCoef= MIN( 0.5 , HydraulicChoke1WashoutCoef+ CHOOKE(1)%WashoutMalf*(0.5/(60.0/DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time
  204. HydraulicChoke2WashoutCoef= HydraulicChoke2WashoutCoef * CHOOKE(2)%WashoutMalf
  205. HydraulicChoke2WashoutCoef= MIN( 0.5 , HydraulicChoke2WashoutCoef+ CHOOKE(2)%WashoutMalf*(0.5/(60.0/DeltaT_Choke)) ) ! 0.5=maximum washout coef , 60.0 sec= 1min duration time
  206. !write(*,*) 'HydraulicChoke1WashoutCoef=' , HydraulicChoke1WashoutCoef
  207. IF (CHOOKE(1)%PlugMalf == 1) THEN
  208. Present_HydraulicChoke1Plug= Present_HydraulicChoke1Plug * CHOOKE(1)%PlugMalf
  209. ! integer: HydraulicChoke1PluggedPercent,HydraulicChoke1PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  210. ! real: Present_HydraulicChoke1Plug,DeltaPlug1Percent
  211. !write(*,*) 'HydraulicChoke1PluggedPercent=' , HydraulicChoke1PluggedPercent
  212. if ( (HydraulicChoke1PluggedPercent - HydraulicChoke1PluggedPercent_Old) /= 0) then
  213. DeltaPlug1Percent = (REAL(HydraulicChoke1PluggedPercent)/100.) - Present_HydraulicChoke1Plug
  214. Plug1TimeCounter = 0
  215. !write(*,*) 'DeltaPlug1Percent, Present_HydraulicChoke1Plug = ' ,DeltaPlug1Percent , Present_HydraulicChoke1Plug
  216. endif
  217. Plug1TimeCounter= Plug1TimeCounter + 1
  218. HydraulicChoke1PluggedPercent_Old= HydraulicChoke1PluggedPercent
  219. if (Plug1TimeCounter <= ChokePlugTimeDelay) then !ChokePlugTimeDelay=600
  220. Present_HydraulicChoke1Plug = Present_HydraulicChoke1Plug + CHOOKE(1)%PlugMalf* ((DeltaPlug1Percent / real(ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0
  221. endif
  222. !write(*,*) 'Present_HydraulicChoke1Plug=' , Present_HydraulicChoke1Plug
  223. ENDIF
  224. IF (CHOOKE(2)%PlugMalf == 1) THEN
  225. Present_HydraulicChoke2Plug= Present_HydraulicChoke2Plug * CHOOKE(2)%PlugMalf
  226. ! integer: HydraulicChoke2PluggedPercent,HydraulicChoke2PluggedPercent_Old,PlugTimeCounter,ChokePlugTimeDelay
  227. ! real: Present_HydraulicChoke2Plug,DeltaPlug2Percent
  228. if ( (HydraulicChoke2PluggedPercent - HydraulicChoke2PluggedPercent_Old) /= 0 ) then
  229. DeltaPlug2Percent = (REAL(HydraulicChoke2PluggedPercent)/100.) - Present_HydraulicChoke2Plug
  230. Plug2TimeCounter = 0
  231. endif
  232. Plug2TimeCounter= Plug2TimeCounter + 1
  233. HydraulicChoke2PluggedPercent_Old= HydraulicChoke2PluggedPercent
  234. if (Plug2TimeCounter <= ChokePlugTimeDelay) then !ChokePlugTimeDelay=600
  235. Present_HydraulicChoke2Plug = Present_HydraulicChoke2Plug + CHOOKE(2)%PlugMalf *((DeltaPlug2Percent / real(ChokePlugTimeDelay))) ! real(ChokePlugTimeDelay)= 600.0
  236. endif
  237. ENDIF
  238. ! fully open area is 123/64 in^2 = 0.01334635 ft^2
  239. CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke+(CHOOKE(1)%WashoutMalf*HydraulicChoke1WashoutCoef*ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  240. !write(*,*) 'CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke=' ,CHOOKE(1)%WashoutMalf , CHOOKE(1)%AreaChoke
  241. CHOOKE(1)%AreaChoke=CHOOKE(1)%AreaChoke-(CHOOKE(1)%PlugMalf* Present_HydraulicChoke1Plug *CHOOKE(1)%AreaChoke) ! Initialised in Choke Startup
  242. CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke+(CHOOKE(2)%WashoutMalf*HydraulicChoke2WashoutCoef*ChokeAreaFullyOpen/144.0) ! Initialised in Choke Startup
  243. CHOOKE(2)%AreaChoke=CHOOKE(2)%AreaChoke-(CHOOKE(2)%PlugMalf* Present_HydraulicChoke2Plug *CHOOKE(2)%AreaChoke) ! Initialised in Choke Startup
  244. !write(*,*) 'CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke=' ,CHOOKE(2)%WashoutMalf , CHOOKE(2)%AreaChoke
  245. CHOOKE(1)%AreaChokeFinal= CHOOKE(1)%AreaChoke
  246. CHOOKE(2)%AreaChokeFinal= CHOOKE(2)%AreaChoke
  247. ! 144: ft^2 to in^2
  248. CALL SetHydraulicChock1(100 - nint((CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  249. CALL SetHydraulicChock2(100 - nint((CHOOKE(2)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100)) ! for manifold valve
  250. !write(*,*) 'CHOOKE(1)%PercentClose=' , CHOOKE(1)%PercentClose ! close percent 0 to 100
  251. !write(*,*) 'ChokePosition=' , ChokePosition ! close position 0 to 10 for display
  252. !write(*,*) 'CHOOKE(1)%AreaChokeFinal=' , CHOOKE(1)%AreaChokeFinal ! Open Area (in^2) with clearance
  253. !write(*,*) '(ChokeAreaFullyOpen/144.)=' , (ChokeAreaFullyOpen/144.)
  254. !write(*,*) 'valve value=' , 100 - nint((CHOOKE(1)%AreaChokeFinal/(ChokeAreaFullyOpen/144.))*100) ! percent close 0 to 100 with clearance
  255. !write(*,*) 'Valve(33)%Status=' , Valve(33)%Status ! T : open , F: close
  256. ! =================== calculating Area
  257. !write(*,*) 'CHOOKE(1)%AreaChoke= ' , CHOOKE(1)%AreaChoke
  258. ! WRITE(150,50) alpha_timeair,alpha_Qair,alpha_pairp, &
  259. ! alpha_Pdownstrem,alpha_diffpair,alpha_lossesair,CHOOKE(CHNUMBER)%PassedCourse
  260. !50 FORMAT(7(f15.5))
  261. !========================================================================================
  262. !========================================================================================
  263. ! write(*,*) PassedCourse
  264. end