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.
 
 
 
 
 
 

338 lines
23 KiB

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