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.

AirPump_Choke_Subs.f90 23 KiB

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