Simulation Core
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

339 linhas
22 KiB

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