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.

LOSS_INPUTS.f90 55 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  1. SUBROUTINE DEALLOCATE_ARRAYS()
  2. USE VARIABLES
  3. implicit none
  4. !===========================================================================
  5. ! RAMLINE MINOR LOSSES INPUT
  6. !===========================================================================
  7. DEALLOCATE (BopStackInput%MINORS1,RamLine%MINORDIAMETER_RAMLINE,RamLine%AREAMINOR_RAMLINE &
  8. ,RamLine%LF_RAMLINE,RamLine%CV_RAMLINE,RamLine%NOTE_RAMLINE,RAMS%minlosspa,RAMS%minloss)
  9. !===========================================================================
  10. ! RAMLINE PIPNING LOSSES INPUT
  11. !===========================================================================
  12. DEALLOCATE (BopStackInput%PIPINGS_RAMLINE,RamLine%DIAM_RAMLINE_INCH, &
  13. RamLine%AREA_RAMLINE,RamLine%LENGT_RAMLINE,RamLine%ROUGHNESS_RAMLINE,RamLine%RELROUGH_RAMLINE &
  14. ,RAMS%Re_ramline,RAMS%fric,RAMS%fricloss)
  15. !===========================================================================
  16. ! ANNULAR MINOR LOSSES INPUT
  17. !===========================================================================
  18. DEALLOCATE (BopStackInput%MINORS_ANNULAR,AnnularComputational%MINORDIAMETER_ANNULARLINE,AnnularComputational%AREAMINOR_ANNULARLINE &
  19. ,AnnularComputational%LF_ANNULARLINE,AnnularComputational%CV_ANNULARLINE,AnnularComputational%NOTE_ANNULARLINE,AnnularComputational%minlosspa_ANNULAR,AnnularComputational%minloss_ANNULAR)
  20. !===========================================================================
  21. ! ANNULAR PIPNING LOSSES INPUT
  22. !===========================================================================
  23. DEALLOCATE (BopStackInput%PIPINGS_ANNULAR,AnnularComputational%DIAM_ANNULARLINE_INCH,AnnularComputational%AREA_ANNULARLINE, &
  24. AnnularComputational%LENGT_ANNULARLINE,AnnularComputational%ROUGHNESS_ANNULARLINE,AnnularComputational%RELROUGH_ANNULARLINE &
  25. ,AnnularComputational%Re_ANNULARline,AnnularComputational%fricANNULAR,AnnularComputational%friclossANNULAR)
  26. !===========================================================================
  27. ! AIR PUMP LOSSES INPUT
  28. !===========================================================================
  29. DEALLOCATE (BopStackInput%PIPINGS_AIRPUMP,RamLine%DIAM_AIR_INCH, &
  30. RamLine%Re_air,RamLine%AREA_AIR,RamLine%LENGT_AIR,RamLine%ROUGHNESS_AIRPLINE,RamLine%REL_ROUGHAIR, &
  31. RamLine%fric_air,RamLine%fricloss_air)
  32. !================================================================
  33. DEALLOCATE (BopStackInput%MINORS_AIRPUMP,RamLine%MINORDIAM_AIR_INCH, &
  34. RamLine%MINORAREA_AIR,RamLine%LF_AIR,RamLine%CV_AIR,RamLine%NOTE_AIR &
  35. ,RamLine%minlosspa_air,RamLine%minloss_air)
  36. !===========================================================================
  37. ! DELAY ARRAYS
  38. !===========================================================================
  39. call AnnularComputational%Pannular_regDelay%Empty()
  40. END
  41. SUBROUTINE LOSS_INPUTS()
  42. USE VARIABLES
  43. implicit none
  44. INTEGER I
  45. !===========================================================================
  46. ! RAMLINE MINOR LOSSES INPUT
  47. !===========================================================================
  48. RamLine%NO_MINORSRAMLINE=34
  49. ALLOCATE (BopStackInput%MINORS1(RamLine%NO_MINORSRAMLINE,4))
  50. ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
  51. BopStackInput%MINORS1(1,1:4)= (/2., 2., 0., 0./) !Acc.tee
  52. BopStackInput%MINORS1(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
  53. BopStackInput%MINORS1(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
  54. BopStackInput%MINORS1(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
  55. BopStackInput%MINORS1(5,1:4)= (/2., 0.9, 0., 0./) !tee
  56. BopStackInput%MINORS1(6,1:4)= (/2., 2., 0., 0./) !tee
  57. BopStackInput%MINORS1(7,1:4)= (/2., 0., 105., 0./) !valve
  58. BopStackInput%MINORS1(8,1:4)= (/2., 0.9, 0., 0./) !tee
  59. BopStackInput%MINORS1(9,1:4)= (/2., 0., 105., 0./) !valve
  60. BopStackInput%MINORS1(10,1:4)= (/2., 0.42, 0., 0./) !elbow
  61. BopStackInput%MINORS1(11,1:4)= (/2., 0.42, 0., 0./) !elbow
  62. BopStackInput%MINORS1(12,1:4)= (/2., 0.8, 0., 0./) !unionA
  63. BopStackInput%MINORS1(13,1:4)= (/2., 0.8, 0., 0./) !unionA
  64. BopStackInput%MINORS1(14,1:4)= (/2., 1.5, 0., 0./) !elbow
  65. BopStackInput%MINORS1(15,1:4)= (/2., 0., 425., 0./) !valve
  66. BopStackInput%MINORS1(16,1:4)= (/2., 2., 0., 0./) !tee
  67. BopStackInput%MINORS1(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR
  68. BopStackInput%MINORS1(18,1:4)= (/1., 2., 0., 0./) !tee
  69. BopStackInput%MINORS1(19,1:4)= (/1., 1.5, 0., 0./) !elbow
  70. BopStackInput%MINORS1(20,1:4)= (/1., 0.42, 0., 0./) !elbow
  71. BopStackInput%MINORS1(21,1:4)= (/1., 0.42, 0., 0./) !elbow
  72. BopStackInput%MINORS1(22,1:4)= (/1., 1.5, 0., 0./) !elbow
  73. BopStackInput%MINORS1(23,1:4)= (/1., 0., 105., 0./) !valve
  74. BopStackInput%MINORS1(24,1:4)= (/1., 0.9, 0., 0./) !tee
  75. BopStackInput%MINORS1(25,1:4)= (/1., 0., 0., 0.5/) !FT
  76. BopStackInput%MINORS1(26,1:4)= (/1., 0., 0., 3.4/) !filter
  77. BopStackInput%MINORS1(27,1:4)= (/1., 0., 105., 0./) !valve
  78. BopStackInput%MINORS1(28,1:4)= (/1., 0.9, 0., 0./) !tee
  79. BopStackInput%MINORS1(29,1:4)= (/1., 1.5, 0., 0./) !elbow
  80. BopStackInput%MINORS1(30,1:4)= (/1., 1.5, 0., 0./) !elbow
  81. BopStackInput%MINORS1(31,1:4)= (/1., 0., 9.2, 0./) !valve
  82. BopStackInput%MINORS1(32,1:4)= (/1., 0.8, 0., 0./) !unionA
  83. BopStackInput%MINORS1(33,1:4)= (/1., 0.8, 0., 0./) !unionA
  84. BopStackInput%MINORS1(34,1:4)= (/0.75, 0.35, 0., 0./) !contraction
  85. ALLOCATE (RamLine%MINORDIAMETER_RAMLINE(RamLine%NO_MINORSRAMLINE),RamLine%AREAMINOR_RAMLINE(RamLine%NO_MINORSRAMLINE),RamLine%LF_RAMLINE(RamLine%NO_MINORSRAMLINE),RamLine%CV_RAMLINE(RamLine%NO_MINORSRAMLINE) &
  86. ,RamLine%NOTE_RAMLINE(RamLine%NO_MINORSRAMLINE),RAMS%minlosspa(6,RamLine%NO_MINORSRAMLINE),RAMS%minloss(6,RamLine%NO_MINORSRAMLINE))
  87. DO I=1,RamLine%NO_MINORSRAMLINE
  88. RamLine%MINORDIAMETER_RAMLINE(I)=BopStackInput%MINORS1(I,1)
  89. RamLine%LF_RAMLINE(I)=BopStackInput%MINORS1(I,2)
  90. RamLine%CV_RAMLINE(I)=BopStackInput%MINORS1(I,3)
  91. RamLine%NOTE_RAMLINE(I)=BopStackInput%MINORS1(I,4)
  92. RamLine%AREAMINOR_RAMLINE(I)=PI*(RamLine%MINORDIAMETER_RAMLINE(I)*0.0254)**2/4. !D(in), AREA(m)
  93. ENDDO
  94. !===========================================================================
  95. ! RAMLINE PIPNING LOSSES INPUT
  96. !===========================================================================
  97. RamLine%NO_PIPINGSRAMLINE=15
  98. ALLOCATE (BopStackInput%PIPINGS_RAMLINE(RamLine%NO_PIPINGSRAMLINE,3))
  99. ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
  100. BopStackInput%PIPINGS_RAMLINE(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance
  101. BopStackInput%PIPINGS_RAMLINE(2,1:3)= (/2., 730., 0.03/) !Acc.end.horizontal
  102. BopStackInput%PIPINGS_RAMLINE(3,1:3)= (/2., 2000., 0.03/) !Acc.end.vertical
  103. BopStackInput%PIPINGS_RAMLINE(4,1:3)= (/2., 6000., 0.05/) !Hyd.hose
  104. BopStackInput%PIPINGS_RAMLINE(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1
  105. BopStackInput%PIPINGS_RAMLINE(6,1:3)= (/2., 210., 0.03/) !Add.from.bend
  106. BopStackInput%PIPINGS_RAMLINE(7,1:3)= (/1., 780., 0.03/) !Corner.horizontal1
  107. BopStackInput%PIPINGS_RAMLINE(8,1:3)= (/1., 780., 0.03/) !Corner.horizontal2
  108. BopStackInput%PIPINGS_RAMLINE(9,1:3)= (/1., 750., 0.03/) !Extra.length.back
  109. BopStackInput%PIPINGS_RAMLINE(10,1:3)= (/1., 800., 0.03/) !Corner.horizontal3
  110. BopStackInput%PIPINGS_RAMLINE(11,1:3)= (/1., 1650., 0.03/) !Corner.vertical2
  111. BopStackInput%PIPINGS_RAMLINE(12,1:3)= (/1., 340., 0.03/) !12.Valves.horizontal
  112. BopStackInput%PIPINGS_RAMLINE(13,1:3)= (/1., 1650., 0.03/) !Valves.vertical
  113. BopStackInput%PIPINGS_RAMLINE(14,1:3)= (/1., 31000., 10./) !Hyd.hose
  114. BopStackInput%PIPINGS_RAMLINE(15,1:3)= (/1., 526., 0.03/) !Add.from.bend
  115. ALLOCATE (RamLine%DIAM_RAMLINE_INCH(RamLine%NO_PIPINGSRAMLINE), &
  116. RamLine%AREA_RAMLINE(RamLine%NO_PIPINGSRAMLINE),RamLine%LENGT_RAMLINE(RamLine%NO_PIPINGSRAMLINE),RamLine%ROUGHNESS_RAMLINE(RamLine%NO_PIPINGSRAMLINE),RamLine%RELROUGH_RAMLINE(RamLine%NO_PIPINGSRAMLINE) &
  117. ,RAMS%Re_ramline(6,RamLine%NO_PIPINGSRAMLINE),RAMS%fric(6,RamLine%NO_PIPINGSRAMLINE),RAMS%fricloss(6,RamLine%NO_PIPINGSRAMLINE))
  118. DO I=1,RamLine%NO_PIPINGSRAMLINE
  119. RamLine%DIAM_RAMLINE_INCH(I)=BopStackInput%PIPINGS_RAMLINE(I,1)
  120. RamLine%LENGT_RAMLINE(I)=BopStackInput%PIPINGS_RAMLINE(I,2)
  121. RamLine%ROUGHNESS_RAMLINE(I)=BopStackInput%PIPINGS_RAMLINE(I,3)
  122. RamLine%AREA_RAMLINE(I)=PI*(RamLine%DIAM_RAMLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m)
  123. RamLine%RELROUGH_RAMLINE(I)=RamLine%ROUGHNESS_RAMLINE(I)/(RamLine%DIAM_RAMLINE_INCH(I)*25.4) !e/D
  124. !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m)
  125. RamLine%LENGT_RAMLINE(I)=RamLine%LENGT_RAMLINE(I)*.001 ! (m)
  126. ENDDO
  127. !===========================================================================
  128. ! ANNULAR PREVENTER MINOR LOSSES INPUT
  129. !===========================================================================
  130. AnnularComputational%NO_MinorsAnnularLine=29
  131. ALLOCATE (BopStackInput%MINORS_ANNULAR(AnnularComputational%NO_MinorsAnnularLine,4))
  132. ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
  133. BopStackInput%MINORS_ANNULAR(1,1:4)= (/2., 2., 0., 0./) !Acc.tee
  134. BopStackInput%MINORS_ANNULAR(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
  135. BopStackInput%MINORS_ANNULAR(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
  136. BopStackInput%MINORS_ANNULAR(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
  137. BopStackInput%MINORS_ANNULAR(5,1:4)= (/2., 0.9, 0., 0./) !tee
  138. BopStackInput%MINORS_ANNULAR(6,1:4)= (/2., 2., 0., 0./) !tee
  139. BopStackInput%MINORS_ANNULAR(7,1:4)= (/2., 0., 105., 0./) !valve
  140. BopStackInput%MINORS_ANNULAR(8,1:4)= (/2., 0.9, 0., 0./) !tee
  141. BopStackInput%MINORS_ANNULAR(9,1:4)= (/2., 0., 105., 0./) !valve
  142. BopStackInput%MINORS_ANNULAR(10,1:4)= (/2., 0.42, 0., 0./) !elbow
  143. BopStackInput%MINORS_ANNULAR(11,1:4)= (/2., 0.42, 0., 0./) !elbow
  144. BopStackInput%MINORS_ANNULAR(12,1:4)= (/2., 0.8, 0., 0./) !unionA
  145. BopStackInput%MINORS_ANNULAR(13,1:4)= (/2., 0.8, 0., 0./) !unionA
  146. BopStackInput%MINORS_ANNULAR(14,1:4)= (/2., 1.5, 0., 0./) !elbow
  147. BopStackInput%MINORS_ANNULAR(15,1:4)= (/2., 0., 425., 0./) !valve
  148. BopStackInput%MINORS_ANNULAR(16,1:4)= (/2., 2., 0., 0./) !tee
  149. BopStackInput%MINORS_ANNULAR(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR
  150. BopStackInput%MINORS_ANNULAR(18,1:4)= (/1., 2., 0., 0./) !tee
  151. BopStackInput%MINORS_ANNULAR(19,1:4)= (/1., 1.5, 0., 0./) !elbow
  152. BopStackInput%MINORS_ANNULAR(20,1:4)= (/1., 0.42, 0., 0./) !elbow
  153. BopStackInput%MINORS_ANNULAR(21,1:4)= (/1., 0.42, 0., 0./) !elbow
  154. BopStackInput%MINORS_ANNULAR(22,1:4)= (/1., 1.5, 0., 0./) !elbow
  155. BopStackInput%MINORS_ANNULAR(23,1:4)= (/1., 0., 3.2, 0./) !valve
  156. BopStackInput%MINORS_ANNULAR(24,1:4)= (/1., 2., 0., 0./) !tee
  157. BopStackInput%MINORS_ANNULAR(25,1:4)= (/1., 1.5, 0., 0./) !elbow
  158. BopStackInput%MINORS_ANNULAR(26,1:4)= (/1., 0.42, 0., 0./) !elbow
  159. BopStackInput%MINORS_ANNULAR(27,1:4)= (/1., 0.42, 0., 0./) !elbow
  160. BopStackInput%MINORS_ANNULAR(28,1:4)= (/1., 1.5, 0., 0./) !elbow
  161. BopStackInput%MINORS_ANNULAR(29,1:4)= (/1., 0., 3.2, 0./) !valve
  162. ALLOCATE (AnnularComputational%MINORDIAMETER_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%AREAMINOR_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%LF_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine) &
  163. ,AnnularComputational%CV_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%NOTE_ANNULARLINE(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%minlosspa_ANNULAR(AnnularComputational%NO_MinorsAnnularLine),AnnularComputational%minloss_ANNULAR(AnnularComputational%NO_MinorsAnnularLine))
  164. DO I=1,AnnularComputational%NO_MinorsAnnularLine
  165. AnnularComputational%MINORDIAMETER_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,1)
  166. AnnularComputational%LF_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,2)
  167. AnnularComputational%CV_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,3)
  168. AnnularComputational%NOTE_ANNULARLINE(I)=BopStackInput%MINORS_ANNULAR(I,4)
  169. AnnularComputational%AREAMINOR_ANNULARLINE(I)=PI*(AnnularComputational%MINORDIAMETER_ANNULARLINE(I)*0.0254)**2/4. !D(in), AREA(m)
  170. ENDDO
  171. !===========================================================================
  172. ! ANNULAR PREVENTER PIPNING LOSSES INPUT
  173. !===========================================================================
  174. AnnularComputational%NO_PipingsAnnularLine=10
  175. ALLOCATE (BopStackInput%PIPINGS_ANNULAR(AnnularComputational%NO_PipingsAnnularLine,3))
  176. ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
  177. BopStackInput%PIPINGS_ANNULAR(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance
  178. BopStackInput%PIPINGS_ANNULAR(2,1:3)= (/2., 730., 0.03/) !Acc.endhorizontal
  179. BopStackInput%PIPINGS_ANNULAR(3,1:3)= (/2., 2000., 0.03/) !Acc.endvertical
  180. BopStackInput%PIPINGS_ANNULAR(4,1:3)= (/2., 6000., 0.03/) !Hyd.hose
  181. BopStackInput%PIPINGS_ANNULAR(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1
  182. BopStackInput%PIPINGS_ANNULAR(6,1:3)= (/2., 210., 0.03/) !Add.frombend
  183. BopStackInput%PIPINGS_ANNULAR(7,1:3)= (/2., 1000., 0.03/) !manifold
  184. BopStackInput%PIPINGS_ANNULAR(8,1:3)= (/1., 46000., 0.03/) !pipe
  185. BopStackInput%PIPINGS_ANNULAR(9,1:3)= (/2., 1000., 0.03/) !manifold
  186. BopStackInput%PIPINGS_ANNULAR(10,1:3)= (/1., 46000., 0.03/) !pipe
  187. ALLOCATE (AnnularComputational%DIAM_ANNULARLINE_INCH(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%AREA_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%LENGT_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine) &
  188. ,AnnularComputational%ROUGHNESS_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%RELROUGH_ANNULARLINE(AnnularComputational%NO_PipingsAnnularLine) &
  189. ,AnnularComputational%Re_ANNULARline(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%fricANNULAR(AnnularComputational%NO_PipingsAnnularLine),AnnularComputational%friclossANNULAR(AnnularComputational%NO_PipingsAnnularLine))
  190. DO I=1,AnnularComputational%NO_PipingsAnnularLine
  191. AnnularComputational%DIAM_ANNULARLINE_INCH(I)=BopStackInput%PIPINGS_ANNULAR(I,1)
  192. AnnularComputational%LENGT_ANNULARLINE(I)=BopStackInput%PIPINGS_ANNULAR(I,2)
  193. AnnularComputational%ROUGHNESS_ANNULARLINE(I)=BopStackInput%PIPINGS_ANNULAR(I,3)
  194. AnnularComputational%AREA_ANNULARLINE(I)=PI*(AnnularComputational%DIAM_ANNULARLINE_INCH(I)*0.0254)**2/4. !D(in), AREA(m)
  195. AnnularComputational%RELROUGH_ANNULARLINE(I)=AnnularComputational%ROUGHNESS_ANNULARLINE(I)/(AnnularComputational%DIAM_ANNULARLINE_INCH(I)*25.4)
  196. !DIAM_ANNULARLINE_MM(I)=DIAM_ANNULARLINE_MM(I)*.001 ! (m)
  197. AnnularComputational%LENGT_ANNULARLINE(I)=AnnularComputational%LENGT_ANNULARLINE(I)*.001 ! (m)
  198. ENDDO
  199. !===========================================================================
  200. ! AIR PUMP LOSSES INPUT
  201. !===========================================================================
  202. RamLine%NO_PIPINGS_AIRPLINE=1
  203. ALLOCATE (BopStackInput%PIPINGS_AIRPUMP(RamLine%NO_PIPINGS_AIRPLINE,3))
  204. ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
  205. BopStackInput%PIPINGS_AIRPUMP(1,1:3)= (/2., 10000., 0.03/) !Avg.acc.distance
  206. ALLOCATE (RamLine%DIAM_AIR_INCH(RamLine%NO_PIPINGS_AIRPLINE),RamLine%Re_air(RamLine%NO_PIPINGS_AIRPLINE),RamLine%AREA_AIR(RamLine%NO_PIPINGS_AIRPLINE), &
  207. RamLine%LENGT_AIR(RamLine%NO_PIPINGS_AIRPLINE),RamLine%ROUGHNESS_AIRPLINE(RamLine%NO_PIPINGS_AIRPLINE),RamLine%REL_ROUGHAIR(RamLine%NO_PIPINGS_AIRPLINE), &
  208. RamLine%fric_air(RamLine%NO_PIPINGS_AIRPLINE),RamLine%fricloss_air(RamLine%NO_PIPINGS_AIRPLINE))
  209. DO I=1,RamLine%NO_PIPINGS_AIRPLINE
  210. RamLine%DIAM_AIR_INCH(I)=BopStackInput%PIPINGS_AIRPUMP(I,1)
  211. RamLine%LENGT_AIR(I)=BopStackInput%PIPINGS_AIRPUMP(I,2)
  212. RamLine%ROUGHNESS_AIRPLINE(I)=BopStackInput%PIPINGS_AIRPUMP(I,3)
  213. RamLine%AREA_AIR(I)=PI*(RamLine%DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m)
  214. RamLine%REL_ROUGHAIR(I)=RamLine%ROUGHNESS_AIRPLINE(I)/(RamLine%DIAM_AIR_INCH(I)*25.4)
  215. !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m)
  216. RamLine%LENGT_AIR(I)=RamLine%LENGT_AIR(I)*.001 ! (m)
  217. ENDDO
  218. !================================================================
  219. RamLine%NO_MINORS_AIRPLINE=6
  220. ALLOCATE (BopStackInput%MINORS_AIRPUMP(RamLine%NO_MINORS_AIRPLINE,4))
  221. ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
  222. BopStackInput%MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee
  223. BopStackInput%MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow
  224. BopStackInput%MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter
  225. BopStackInput%MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve
  226. BopStackInput%MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve
  227. BopStackInput%MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA
  228. ALLOCATE (RamLine%MINORDIAM_AIR_INCH(RamLine%NO_MINORS_AIRPLINE),RamLine%MINORAREA_AIR(RamLine%NO_MINORS_AIRPLINE), &
  229. RamLine%LF_AIR(RamLine%NO_MINORS_AIRPLINE),RamLine%CV_AIR(RamLine%NO_MINORS_AIRPLINE),RamLine%NOTE_AIR(RamLine%NO_MINORS_AIRPLINE) &
  230. ,RamLine%minlosspa_air(RamLine%NO_MINORS_AIRPLINE),RamLine%minloss_air(RamLine%NO_MINORS_AIRPLINE))
  231. DO I=1,RamLine%NO_MINORS_AIRPLINE
  232. RamLine%MINORDIAM_AIR_INCH(I)=BopStackInput%MINORS_AIRPUMP(I,1)
  233. RamLine%LF_AIR(I)=BopStackInput%MINORS_AIRPUMP(I,2)
  234. RamLine%CV_AIR(I)=BopStackInput%MINORS_AIRPUMP(I,3)
  235. RamLine%NOTE_AIR(I)=BopStackInput%MINORS_AIRPUMP(I,4)
  236. RamLine%MINORAREA_AIR(I)=PI*(RamLine%MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m)
  237. ENDDO
  238. END
  239. SUBROUTINE pumps_charge_bottle()
  240. USE VARIABLES
  241. USE CAccumulatorVariables
  242. USE CBopStackVariables
  243. USE CBopControlPanelVariables
  244. USE CEquipmentsConstants
  245. ! use CSimulationVariables
  246. implicit none
  247. !Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
  248. !write(*,*) 'pumps_charge_bottle'
  249. if(BopControlPanel%ByePassValve == -1.0) then
  250. BopStackAcc%ByPassOld= -1.0
  251. elseif(BopControlPanel%ByePassValve == 1.0) then
  252. BopStackAcc%ByPassOld= 1.0
  253. endif
  254. !=====================================================================
  255. ! ACCUMULATOR
  256. !=====for a 10 gal bottle,precharge=1000psig curve BOSCH-isotherm=====
  257. !for charging bottles by the pump
  258. !((((((((IN OUTER LOOP))))))
  259. ! ba1=1003; ba2=.03375; ba3=4.014; ba4=.2458;
  260. if (RamLine%AIRP_SWITCH==0) Pumps%DELTAV_AIR=0
  261. RamLine%FVR=RamLine%FVR+Pumps%DELTAV_AIR+Pumps%DELTAV_ELECP
  262. RamLine%pacc_before=RamLine%P_ACC
  263. RamLine%P_ACC=RamLine%B1*exp(RamLine%B2*RamLine%FVR/BopStackAcc%NOBOTTLES)+RamLine%B3*exp(RamLine%B4*RamLine%FVR/BopStackAcc%NOBOTTLES) ! adiabatic(psig)<<<< 8=no. of bottles
  264. !=====================================================================
  265. if(BopStackAcc%ByPassOld == 1.0) then
  266. if (BopStackAcc%pram_reg<BopStackAcc%PRAMS_REGSET) then
  267. !pram_reg=pram_reg+(p_acc-pacc_before)
  268. BopStackAcc%PressureDifference= (RamLine%P_ACC-RamLine%pacc_before)
  269. else
  270. !pram_reg=PRAMS_REGSET
  271. BopStackAcc%PressureDifference= BopStackAcc%PRAMS_REGSET - BopStackAcc%pram_reg
  272. endif
  273. !old=pram_reg
  274. !difference= new-old
  275. if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then
  276. BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
  277. else
  278. if (BopStackAcc%pram_reg<BopStackAcc%PRAMS_REGSET) then
  279. BopStackAcc%pram_reg=BopStackAcc%pram_reg+(RamLine%P_ACC-RamLine%pacc_before)
  280. else
  281. BopStackAcc%pram_reg=BopStackAcc%PRAMS_REGSET
  282. endif
  283. endif
  284. else !if(ByPassOld == -1.0) then
  285. !old=pram_reg
  286. !new=p_acc- MAXVAL(RAM%loss_before)
  287. !difference= new-old
  288. BopStackAcc%PressureDifference= RamLine%P_ACC- MAXVAL(RAM%loss_before) - BopStackAcc%pram_reg
  289. if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then
  290. BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
  291. else
  292. BopStackAcc%pram_reg= RamLine%P_ACC- MAXVAL(RAM%loss_before)
  293. endif
  294. endif
  295. !Pannular_reg= min(p_acc,Pannular_regset)
  296. end
  297. SUBROUTINE airpump_code()
  298. USE VARIABLES
  299. use CSounds
  300. implicit none
  301. INTEGER I
  302. Pumps%QAIR=Pumps%Qiter+.1 !(gpm) maximum flow for the start
  303. RamLine%diffp_air=-10
  304. RamLine%losses_air=10
  305. !===================================================================
  306. ! AIR OPERATED PUMP
  307. !=================for air consumption at 8 bar======================
  308. do while (RamLine%diffp_air<0)
  309. Pumps%QAIR=Pumps%QAIR-.1
  310. ! Qup=QAIR_PUMP;
  311. ! bba1 =31.8; bba2 =-725.7 ; bba3 =4154;
  312. Pumps%P_AIRP=RamLine%BBA1*Pumps%QAIR**2+RamLine%BBA2*Pumps%QAIR+RamLine%BBA3 !(psig)
  313. RamLine%kinetic_air=sg*wdens*(Pumps%QAIR*6.30902e-5/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
  314. RamLine%diffp_air=Pumps%P_AIRP+RamLine%kinetic_air-RamLine%P_ACC
  315. end do !returns Qup
  316. do while (abs((RamLine%diffp_air-RamLine%losses_air)/RamLine%diffp_air)>Pumps%TOL_AIR) !finding correct QAIR_pump for 1 timecounter_ram
  317. if (RamLine%diffp_air-RamLine%losses_air>0) then
  318. Pumps%QAIR=Pumps%QAIR+.01
  319. else
  320. Pumps%QAIR=Pumps%QAIR-.01
  321. endif
  322. !===================================================================
  323. ! AIR OPERATED PUMP
  324. ! Maximator - Model: GX (35)
  325. !=================for air consumption at 8 bar======================
  326. Pumps%P_AIRP=RamLine%BBA1*Pumps%QAIR**2+RamLine%BBA2*Pumps%QAIR+RamLine%BBA3 !(psig)
  327. RamLine%kinetic_air=sg*wdens*(Pumps%QAIR*6.30902e-005/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
  328. RamLine%diffp_air=Pumps%P_AIRP+RamLine%kinetic_air-RamLine%P_ACC
  329. !===========================LOSSES====================================
  330. do i=1,RamLine%NO_PIPINGS_AIRPLINE
  331. RamLine%Re_air(i)=Pumps%QAIR*6.30902e-005*RamLine%DIAM_AIR_INCH(I)*0.0254/(RamLine%AREA_AIR(i)*nu)
  332. enddo
  333. do i=1,RamLine%NO_PIPINGS_AIRPLINE
  334. if (RamLine%Re_air(i)<Re_cr) then
  335. RamLine%fric_air(i)=64/RamLine%Re_air(i)
  336. else
  337. RamLine%fric_air(i)=1/(-1.8*log10((RamLine%REL_ROUGHAIR(i)/3.7)**1.11+6.9/RamLine%Re_air(i)))**2
  338. endif
  339. RamLine%fricloss_air(i)=((RamLine%fric_air(i)*(wdens*sg*RamLine%LENGT_AIR(i)*(Pumps%QAIR*6.30902e-005/RamLine%AREA_AIR(i))**2))/(2*RamLine%DIAM_AIR_INCH(I)*0.0254))/6895
  340. enddo
  341. RamLine%pipe_loss1air=sum(RamLine%fricloss_air) !loss before regulator(psi)
  342. do i=1,RamLine%NO_MINORS_AIRPLINE
  343. if (RamLine%LF_AIR(i)/=0) then
  344. RamLine%minlosspa_air(i)=RamLine%LF_AIR(i)*wdens*sg*(Pumps%QAIR*6.30902e-005/RamLine%MINORAREA_AIR(i))**2/2 !(Pa)
  345. RamLine%minloss_air(i)=RamLine%minlosspa_air(i)/6895 !(psi)
  346. elseif (RamLine%CV_AIR(i)/=0) then
  347. RamLine%minlosspa_air(i)=1000*sg*((11.7*Pumps%QAIR*6.30902e-005*3600)/(RamLine%CV_AIR(i)))**2 !(pa)
  348. RamLine%minloss_air(i)=RamLine%minlosspa_air(i)/6895 !(psi)
  349. else
  350. RamLine%minlosspa_air(i)=RamLine%NOTE_AIR(i)*1e5 !(pa)
  351. RamLine%minloss_air(i)=RamLine%minlosspa_air(i)/6895 !(psi)
  352. endif
  353. enddo
  354. RamLine%minor_loss1air=sum(RamLine%minloss_air) !loss before regulator(psi)
  355. RamLine%static_loss1air=0
  356. RamLine%losses_air=RamLine%pipe_loss1air+RamLine%minor_loss1air+RamLine%static_loss1air !(psi)
  357. !=========================================================================
  358. end do !returns correct QAIR_PUMP for 1 counter
  359. RamLine%counter_airp=RamLine%counter_airp+1
  360. Pumps%Qiter=Pumps%QAIR
  361. BopStackAcc%Cumulative_AirVolume= BopStackAcc%Cumulative_AirVolume + ((Pumps%QAIR * RamLine%DeltaT_BOP / 60.0 ) / (6.71*0.004329004) ) ! =strokes
  362. !write(*,*) 'Cumulative_AirVolume=' , Cumulative_AirVolume
  363. if ( BopStackAcc%Cumulative_AirVolume > 1.0 ) then
  364. BopStackAcc%SoundKoomeyAirPump= 120.0
  365. BopStackAcc%Cumulative_AirVolume= BopStackAcc%Cumulative_AirVolume - 1.0
  366. else
  367. BopStackAcc%SoundKoomeyAirPump= 0.0
  368. endif
  369. !SoundKoomeyAirPump= int ( (QAIR_PUMP/ (6.71*0.004329004)) ) ! 6.71: Volume per stroke (in^3) , 0.004329004: in^3 to gal
  370. ! 2.0 : two air pumps 60:seconds
  371. !write(*,*) 'sedaaaa=' ,(QAIR_PUMP/ (6.71*0.004329004)) *DeltaT_BOP/(60.0*2.0)
  372. call SetSoundKoomeyAirPump(BopStackAcc%SoundKoomeyAirPump)
  373. Pumps%DELTAV_AIR=Pumps%QAIR*RamLine%DeltaT_BOP/60. !(galon) delta_t=1sec , Q(gpm)
  374. !write(*,*) 'QAIR_PUMP=' , QAIR_PUMP
  375. !((((((((IN OUTER LOOP))))))
  376. !fvr_air=fvr_air+deltav_air !=fvr_after (galon) for next timecounter_ram
  377. !========================================================
  378. !WRITE(50,50) QAIR_PUMP,p_airp, &
  379. !p_acc,diffp_air,losses_air,deltav_air
  380. 50 FORMAT(6(f15.5))
  381. end
  382. SUBROUTINE bop_code(ramtype,H_RAMBOP,RNUMBER)
  383. USE VARIABLES
  384. USE CAccumulatorVariables
  385. USE CBopControlPanelVariables
  386. USE CEquipmentsConstants
  387. ! use CSimulationVariables
  388. USE TD_GeneralData
  389. use CUnityOutputs
  390. implicit none
  391. integer ramtype, I
  392. real H_RAMBOP
  393. INTEGER RNUMBER
  394. !Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
  395. !====================================================
  396. ! BOP back pressure IN PRESENCE OF DP
  397. !====================================================
  398. if (RAM(RNUMBER)%bop_type==2) then
  399. RAM(RNUMBER)%checkp= RAM(RNUMBER)%p_bop
  400. if ( RAM(RNUMBER)%vdis_tot<ShearRam%VA) then
  401. RAM(RNUMBER)%p_bop=ShearRam%PA
  402. elseif (ShearRam%VA<= RAM(RNUMBER)%vdis_tot .and. RAM(RNUMBER)%vdis_tot<=ShearRam%VB) then
  403. RAM(RNUMBER)%p_bop=ShearRam%PA+ShearRam%PB*(( RAM(RNUMBER)%vdis_tot-ShearRam%VA)/(ShearRam%VB-ShearRam%VA))
  404. else
  405. RAM(RNUMBER)%p_bop=ShearRam%PA
  406. endif
  407. if ( RAM(RNUMBER)%checkp/=ShearRam%PA .and. RAM(RNUMBER)%p_bop==ShearRam%PA) then
  408. RAM(RNUMBER)%Q=RAM(RNUMBER)%Qzero
  409. else
  410. RAM(RNUMBER)%Q=RAM(RNUMBER)%flow
  411. endif
  412. endif
  413. !====================================================
  414. ! BOP back pressure without DP
  415. !====================================================
  416. if (RAM(RNUMBER)%bop_type==3) then
  417. RAM(RNUMBER)%p_bop=ShearRam%PA
  418. ! Q=flow
  419. endif
  420. RAM(RNUMBER)%clock=0
  421. !======================Losses============================
  422. RAM(RNUMBER)%loss_after=0 !initial value
  423. RAM(RNUMBER)%diffp_ram=1000 !initial value
  424. RAM(RNUMBER)%loss_before=0
  425. !Q=0.0055; %initial flow rate (m^3/s)
  426. RAM(RNUMBER)%Q=RAM(RNUMBER)%flow
  427. do while (abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)/ RAM(RNUMBER)%diffp_ram>RAM(RNUMBER)%tol)
  428. if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) exit
  429. ! while abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)>10
  430. RAM(RNUMBER)%clock= RAM(RNUMBER)%clock+1
  431. if ( RAM(RNUMBER)%clock>20) then
  432. ! tclock=clock
  433. RAM(RNUMBER)%tol= RAM(RNUMBER)%TOLZERO+(floor( RAM(RNUMBER)%clock/10)-1)*.001
  434. endif
  435. ! if (clock==1) continue
  436. if ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after> RAM(RNUMBER)%diffp_ram) then
  437. RAM(RNUMBER)%Q=RAM(RNUMBER)%Q-.1
  438. elseif ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after<= RAM(RNUMBER)%diffp_ram) then
  439. RAM(RNUMBER)%Q=RAM(RNUMBER)%Q+.01
  440. endif
  441. !====================Before Regulator=========================
  442. !pipe_loss1=3.2; % should be replaced by formula
  443. do i=1,RamLine%NO_PIPINGSRAMLINE
  444. RAMS%Re_ramline(RNUMBER,i)=RAM(RNUMBER)%Q*6.30902e-5*RamLine%DIAM_RAMLINE_INCH(i)*0.0254/(RamLine%AREA_RAMLINE(i)*nu)
  445. enddo
  446. do i=1,RamLine%NO_PIPINGSRAMLINE
  447. if ( RAMS%Re_ramline(RNUMBER,i)<Re_cr) then
  448. RAMS%fric(RNUMBER,i)=64/ RAMS%Re_ramline(RNUMBER,i)
  449. else
  450. RAMS%fric(RNUMBER,i)=1/(-1.8*log10((RamLine%RELROUGH_RAMLINE(i)/3.7)**1.11+6.9/ RAMS%Re_ramline(RNUMBER,i)))**2
  451. endif
  452. RAMS%fricloss(RNUMBER,i)=(( RAMS%fric(RNUMBER,i)*(wdens*sg*RamLine%LENGT_RAMLINE(i)*(RAM(RNUMBER)%Q*6.30902e-5/RamLine%AREA_RAMLINE(i))**2))/(2*RamLine%DIAM_RAMLINE_INCH(i)*0.0254))/6895
  453. enddo
  454. RAM(RNUMBER)%pipe_loss1=sum( RAMS%fricloss(RNUMBER,1:6)) !loss before regulator(psi)
  455. ! Q*6.30902e-5 for (gpm) to (m^3/sec)
  456. do i=1,RamLine%NO_MINORSRAMLINE
  457. if (RamLine%LF_RAMLINE(i)/=0) then
  458. RAMS%minlosspa(RNUMBER,i)=RamLine%LF_RAMLINE(i)*wdens*sg*(RAM(RNUMBER)%Q*6.30902e-5/RamLine%AREAMINOR_RAMLINE(i))**2/2 !(Pa)
  459. RAMS%minloss(RNUMBER,i)= RAMS%minlosspa(RNUMBER,i)/6895 !(psi)
  460. elseif (RamLine%CV_RAMLINE(i)/=0) then
  461. RAMS%minlosspa(RNUMBER,i)=1000*sg*((11.7*RAM(RNUMBER)%Q*6.30902e-5*3600)/(RamLine%CV_RAMLINE(i)))**2 !(pa)
  462. RAMS%minloss(RNUMBER,i)= RAMS%minlosspa(RNUMBER,i)/6895 !(psi)
  463. else
  464. RAMS%minlosspa(RNUMBER,i)=RamLine%NOTE_RAMLINE(i)*1e5 !(pa)
  465. RAMS%minloss(RNUMBER,i)= RAMS%minlosspa(RNUMBER,i)/6895 !(psi)
  466. endif
  467. enddo
  468. RAMS%minloss(RNUMBER,17)= 5.*RAM(RNUMBER)%Q ! <==== regulator loss (psig)
  469. RAM(RNUMBER)%minor_loss1=sum( RAMS%minloss(RNUMBER,1:16)) !loss before regulator(psi)
  470. RAM(RNUMBER)%static_loss1=0
  471. RAM(RNUMBER)%kinetic_loss1=sg*wdens*(RAM(RNUMBER)%Q*6.30902e-5/((1/4.)*pi*(.72*0.254e-1)**2))**2/(2*6895) !(psi)
  472. !.72 for regulator diameter)
  473. RAM(RNUMBER)%loss_before= RAM(RNUMBER)%pipe_loss1+ RAM(RNUMBER)%minor_loss1+ RAM(RNUMBER)%static_loss1+ RAM(RNUMBER)%kinetic_loss1 !(psi)
  474. !===================after Regulator======================
  475. ! all in (psi)
  476. RAM(RNUMBER)%pipe_loss2=sum( RAMS%fricloss(RNUMBER,7:RamLine%NO_PIPINGSRAMLINE)) !7=after regulator<<<<<<<
  477. RAM(RNUMBER)%minor_loss2=sum( RAMS%minloss(RNUMBER,17:RamLine%NO_MINORSRAMLINE)) !17=after regulator<<<<<<<
  478. RAM(RNUMBER)%deltah=H_RAMBOP-ShearRam%H_REGRAM
  479. ! RAM(RNUMBER)%static_loss2pa= RAM(RNUMBER)%deltah*sg*wdens*gravity; %(pa)
  480. RAM(RNUMBER)%static_loss2= RAM(RNUMBER)%deltah*sg*wdens*gravity/6895 !(psi)
  481. RAM(RNUMBER)%kinetic_loss2=0
  482. RAM(RNUMBER)%loss_after= RAM(RNUMBER)%pipe_loss2+ RAM(RNUMBER)%minor_loss2+ RAM(RNUMBER)%static_loss2 !(psi)
  483. !=======================================================
  484. if(BopControlPanel%ByePassValve == -1.0) then
  485. BopStackAcc%ByPassOld= -1.0
  486. elseif(BopControlPanel%ByePassValve == 1.0) then
  487. BopStackAcc%ByPassOld= 1.0
  488. endif
  489. ! write(*,*) 'ByPassOld=', ByPassOld
  490. !==========================p_regulator======================
  491. if (BopStackAcc%PRAMS_REGSET<RamLine%P_ACC- RAM(RNUMBER)%loss_before) then
  492. if(BopStackAcc%ByPassOld == 1.0) then
  493. !old=pram_reg
  494. !new=PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
  495. !difference= new-old
  496. BopStackAcc%PressureDifference= BopStackAcc%PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) - BopStackAcc%pram_reg
  497. if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then
  498. BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
  499. else
  500. BopStackAcc%pram_reg= BopStackAcc%PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
  501. endif
  502. !pram_reg=PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
  503. else !(ByPassOld == -1.0)
  504. !old=pram_reg
  505. !new=p_acc- RAM(RNUMBER)%loss_before
  506. !difference= new-old
  507. BopStackAcc%PressureDifference= RamLine%P_ACC- RAM(RNUMBER)%loss_before - BopStackAcc%pram_reg
  508. if (ABS(BopStackAcc%PressureDifference) > BaseDifferenceP) then
  509. BopStackAcc%pram_reg= BopStackAcc%pram_reg + (BopStackAcc%PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
  510. else
  511. BopStackAcc%pram_reg= RamLine%P_ACC- RAM(RNUMBER)%loss_before
  512. endif
  513. endif
  514. !pram_reg=p_acc- RAM(RNUMBER)%loss_before
  515. else
  516. BopStackAcc%pram_reg=RamLine%P_ACC- RAM(RNUMBER)%loss_before- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
  517. endif
  518. !===========================================================
  519. !====================Flow Rate calculation==================
  520. RAM(RNUMBER)%diffp_ram=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17)- RAM(RNUMBER)%p_bop
  521. !write(*,*) 'Q calculation'
  522. end do ! returns correct Q for one timecounter_ram
  523. !write(*,*)'RAM(RNUMBER)%Q= ' , RAM(RNUMBER)%Q
  524. !write(*,*) 'UpperRamsLeakMalf , Bottles_Charged_MalfActive=' , UpperRamsLeakMalf , Bottles_Charged_MalfActive
  525. if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) then
  526. RAM(RNUMBER)%Q= 5.0 ! gpm
  527. !write(*,*) 'malffffffffff'
  528. endif
  529. RAM(RNUMBER)%flow=RAM(RNUMBER)%Q
  530. !====================p_accumulator for next iterate==================
  531. ! deltav=Q*1*1000; %delta_t=1sec (lit)
  532. ! fvr=fvr-deltav; %=fvr_after (lit)
  533. ! p_acc=0.001178*fvr^3+0.02019*fvr^2+16.1*fvr+2379; %(psia)
  534. ! vdis_bottles=fvr_tot-fvr; %from the start***needed for p_bop calculating (lit)
  535. !========for a 10 gal bottle,precharge=1000psig curve BOSCH======
  536. RAM(RNUMBER)%deltav_bottles=RAM(RNUMBER)%Q*RamLine%DeltaT_BOP/60. !(galon) delta_t=1sec , Q(gpm)
  537. RamLine%FVR=RamLine%FVR- RAM(RNUMBER)%deltav_bottles !=fvr_after (galon)
  538. ! b1=993.7; b2=0.164; b3=5.492; b4=0.9796;
  539. RAM(RNUMBER)%p_acccheck=RamLine%P_ACC
  540. RamLine%P_ACC=RamLine%B1*exp(RamLine%B2*RamLine%FVR/BopStackAcc%NOBOTTLES)+RamLine%B3*exp(RamLine%B4*RamLine%FVR/BopStackAcc%NOBOTTLES) !(psig)<<<< 8=no. of bottles
  541. !formula is derived for fvr (galon)
  542. !vdis_bottles=fvr_tot-fvr
  543. RAM(RNUMBER)%vdis_bottles= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%deltav_bottles
  544. RamLine%NoActiveRmas=6.-real(Annular%Annular_closed+RamLine%ShearBop_closed+PipeRam1%closed+PipeRam2%closed+ChokeLine%closed+KillLine%closed)
  545. RAM(RNUMBER)%vdis_elecp= RAM(RNUMBER)%vdis_elecp+(Pumps%DELTAV_ELECP/RamLine%NoActiveRmas) !overal discharged
  546. RAM(RNUMBER)%fvr_air= RAM(RNUMBER)%fvr_air+(Pumps%DELTAV_AIR/RamLine%NoActiveRmas) !=fvr_after (galon) for next timecounter_ram
  547. !write(*,*) 'deltav_air , NoActiveRmas' , deltav_air , NoActiveRmas
  548. RAM(RNUMBER)%vdis_tot= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%fvr_air+ RAM(RNUMBER)%vdis_elecp !overal
  549. ! write(*,*) RAM(RNUMBER)%vdis_tot, vdis_bottles, RAM(RNUMBER)%fvr_air, vdis_elecp !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  550. if (ramtype==1) then !for shear ram
  551. if (RamLine%ShearRamIsClosing) then
  552. ShearRam%IDshearBop=(2.*(ShearRam%NeededVolumeShearRams- RAM(RNUMBER)%vdis_tot)*231./ShearRam%AbopShearRam) +ShearRam%ShearIsNotAllowed*ShearRam%ODDrillpipe_inShearRam
  553. !write(*,*) 'stop now' !, IDshearBop, NeededVolumeShearRams, RAM(RNUMBER)%vdis_tot, AbopShearRam
  554. endif
  555. if (RamLine%ShearRamIsOpening) then
  556. ShearRam%IDshearBop=ShearRam%IDshearBopBase-2.*(ShearRam%NeededVolumeShearRams- RAM(RNUMBER)%vdis_tot)*231./ShearRam%AbopShearRam
  557. endif
  558. if ( RAM(RNUMBER)%vdis_tot>ShearRam%NeededVolumeShearRams) then
  559. RamLine%ShearBop_closed=1
  560. !ShearBop_closed_withPossibility= ShearBop_closed * TD_BOPConnectionPossibility(3)
  561. BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17)
  562. RamLine%P_ACC= RAM(RNUMBER)%p_acccheck
  563. if (RamLine%ShearRamIsClosing) then
  564. ShearRam%IDshearBop=0. + ShearRam%ShearIsNotAllowed*ShearRam%ODDrillpipe_inShearRam
  565. BopControlPanel%MiddleRamsCloseLED = LedOn
  566. BopStackInput%MiddleRamsCloseLEDMine = LedOn
  567. BopControlPanel%MiddleRamsOpenLED = LedOff
  568. BopStackInput%MiddleRamsOpenLEDMine = LedOff
  569. if (TD_BOP%BOPConnectionPossibility(3) == 1 .and. ShearRam%ShearIsNotAllowed==0) then
  570. CALL CloseMiddleRams
  571. RamLine%ShearBop_Situation_forTD= 1 ! closed - for TD code
  572. endif
  573. endif
  574. if (RamLine%ShearRamIsOpening) then
  575. ShearRam%IDshearBop=ShearRam%IDshearBopBase
  576. BopControlPanel%MiddleRamsOpenLED = LedOn
  577. BopStackInput%MiddleRamsOpenLEDMine = LedOn
  578. BopControlPanel%MiddleRamsCloseLED = LedOff
  579. BopStackInput%MiddleRamsCloseLEDMine = LedOff
  580. CALL OpenMiddleRams
  581. RamLine%ShearBop_Situation_forTD= 0 ! open - for TD code
  582. endif
  583. endif
  584. ShearRam%IDshearBopFinal= ShearRam%IDshearBop ! for output data
  585. endif
  586. if (ramtype==2) then !for pipe ram1
  587. if (PipeRam1%IsClosing) then
  588. PipeRam1%ID=(2.*(PipeRam1%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A)+max(PipeRam1%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase)
  589. endif
  590. if (PipeRam1%IsOpening) then
  591. PipeRam1%ID=PipeRam1%IDBase-2.*(PipeRam1%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A
  592. endif
  593. if ( RAM(RNUMBER)%vdis_tot>PipeRam1%NeededVolume) then
  594. PipeRam1%closed=1
  595. !PipeRam1_Situation_forTD= PipeRam1_closed * TD_BOPConnectionPossibility(2)
  596. BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17)
  597. RamLine%P_ACC= RAM(RNUMBER)%p_acccheck
  598. if (PipeRam1%IsClosing) then
  599. PipeRam1%ID=max(PipeRam1%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase)
  600. BopControlPanel%UpperRamsCloseLED = LedOn
  601. BopStackInput%UpperRamsCloseLEDMine = LedOn
  602. BopControlPanel%UpperRamsOpenLED = LedOff
  603. BopStackInput%UpperRamsOpenLEDMine = LedOff
  604. if (TD_BOP%BOPConnectionPossibility(2) == 1) then
  605. CALL CloseUpperRams ! for C code
  606. call Set_BlowoutFromAnnular(.true.)
  607. PipeRam1%Situation_forTD= 1 ! closed - for TD code
  608. endif
  609. endif
  610. if (PipeRam1%IsOpening) then
  611. PipeRam1%ID=PipeRam1%IDBase
  612. BopControlPanel%UpperRamsOpenLED = LedOn
  613. BopStackInput%UpperRamsOpenLEDMine = LedOn
  614. BopControlPanel%UpperRamsCloseLED = LedOff
  615. BopStackInput%UpperRamsCloseLEDMine = LedOff
  616. Call OpenUpperRams ! for C code
  617. PipeRam1%Situation_forTD= 0 ! open - for TD code
  618. endif
  619. endif
  620. ShearRam%IDPipeRam1Final= PipeRam1%ID ! for output data
  621. endif
  622. if (ramtype==3) then !for pipe ram2
  623. if (PipeRam2%IsClosing) then
  624. PipeRam2%ID=(2.*(PipeRam2%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A)+max(PipeRam2%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase)
  625. endif
  626. if (PipeRam2%IsOpening) then
  627. PipeRam2%ID=PipeRam1%IDBase-2.*(PipeRam2%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./PipeRam1%A
  628. endif
  629. if ( RAM(RNUMBER)%vdis_tot>PipeRam2%NeededVolume) then
  630. PipeRam2%closed=1
  631. !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4)
  632. BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17)
  633. RamLine%P_ACC= RAM(RNUMBER)%p_acccheck
  634. if (PipeRam2%IsClosing) then
  635. PipeRam2%ID=max(PipeRam2%ODDrillpipe_in,PipeRam1%ODDrillpipe_inBase)
  636. BopControlPanel%LowerRamsCloseLED = LedOn
  637. BopStackInput%LowerRamsCloseLEDMine = LedOn
  638. BopControlPanel%LowerRamsOpenLED = LedOff
  639. BopStackInput%LowerRamsOpenLEDMine = LedOff
  640. if (TD_BOP%BOPConnectionPossibility(4) == 1) then
  641. CALL CloseLowerRams
  642. PipeRam2%Situation_forTD= 1 ! closed - for TD code
  643. endif
  644. endif
  645. if (PipeRam2%IsOpening) then
  646. PipeRam2%ID=PipeRam1%IDBase
  647. BopControlPanel%LowerRamsOpenLED = LedOn
  648. BopStackInput%LowerRamsOpenLEDMine = LedOn
  649. BopControlPanel%LowerRamsCloseLED = LedOff
  650. BopStackInput%LowerRamsCloseLEDMine = LedOff
  651. CALL OpenLowerRams
  652. PipeRam2%Situation_forTD= 0 ! open - for TD code
  653. endif
  654. endif
  655. ShearRam%IDPipeRam2Final= PipeRam2%ID ! for output data
  656. endif
  657. if (ramtype==4) then !for Choke Line
  658. if (ChokeLine%IsClosing) then
  659. ChokeLine%ID=(2.*(ChokeLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./ChokeLine%Abop)+max(ChokeLine%ODDrillpipe_in,ChokeLine%ODDrillpipe_inBase)
  660. endif
  661. if (ChokeLine%IsOpening) then
  662. ChokeLine%ID=ChokeLine%IDBase-2.*(ChokeLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./ChokeLine%Abop
  663. endif
  664. if ( RAM(RNUMBER)%vdis_tot>ChokeLine%NeededVolume) then
  665. ChokeLine%closed=1
  666. BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17)
  667. RamLine%P_ACC= RAM(RNUMBER)%p_acccheck
  668. if (ChokeLine%IsClosing) then
  669. ChokeLine%ID=max(ChokeLine%ODDrillpipe_in,ChokeLine%ODDrillpipe_inBase)
  670. BopControlPanel%ChokeLineCloseLED = LedOn
  671. BopStackInput%ChokeLineCloseLEDMine = LedOn
  672. BopControlPanel%ChokeLineOpenLED = LedOff
  673. BopStackInput%ChokeLineOpenLEDMine = LedOff
  674. CALL CloseChokeLine
  675. endif
  676. if (ChokeLine%IsOpening) then
  677. ChokeLine%ID=ChokeLine%IDBase
  678. BopControlPanel%ChokeLineOpenLED = LedOn
  679. BopStackInput%ChokeLineOpenLEDMine = LedOn
  680. BopControlPanel%ChokeLineCloseLED = LedOff
  681. BopStackInput%ChokeLineCloseLEDMine = LedOff
  682. CALL OpenChokeLine
  683. endif
  684. endif
  685. endif
  686. if (ramtype==5) then !for Kill Line
  687. if (KillLine%IsClosing) then
  688. KillLine%ID=(2.*(KillLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./KillLine%Abop)+max(KillLine%ODDrillpipe_in,KillLine%ODDrillpipe_inBase)
  689. endif
  690. if (KillLine%IsOpening) then
  691. KillLine%ID=KillLine%IDBase-2.*(KillLine%NeededVolume- RAM(RNUMBER)%vdis_tot)*231./KillLine%Abop
  692. endif
  693. if ( RAM(RNUMBER)%vdis_tot>KillLine%NeededVolume) then
  694. KillLine%closed=1
  695. BopStackAcc%pram_reg=BopStackAcc%pram_reg+RAMS%minloss(RNUMBER,17)
  696. RamLine%P_ACC= RAM(RNUMBER)%p_acccheck
  697. if (KillLine%IsClosing) then
  698. KillLine%ID=max(KillLine%ODDrillpipe_in,KillLine%ODDrillpipe_inBase)
  699. BopControlPanel%KillLineCloseLED = LedOn
  700. BopStackInput%KillLineCloseLedMine = LedOn
  701. BopControlPanel%KillLineOpenLED = LedOff
  702. BopStackInput%KillLineOpenLedMine = LedOff
  703. CALL CloseKillLine
  704. endif
  705. if (KillLine%IsOpening) then
  706. KillLine%ID=KillLine%IDBase
  707. BopControlPanel%KillLineOpenLED = LedOn
  708. BopStackInput%KillLineOpenLedMine = LedOn
  709. BopControlPanel%KillLineCloseLED = LedOff
  710. BopStackInput%KillLineCloseLedMine = LedOff
  711. CALL OpenKillLine
  712. endif
  713. endif
  714. endif
  715. !if (ramtype==4) then !for annular
  716. ! if (AnnularIsClosing) then
  717. ! IDAnnular=((NeededVolumeAnnular-vdis_tot)*231./AbopAnnular)+ODDrillpipe_inAnnular
  718. ! endif
  719. !
  720. ! if (AnnularIsOpening) then
  721. ! IDAnnular=IDAnnularBase-(NeededVolumeAnnular-vdis_tot)*231./AbopAnnular
  722. ! endif
  723. !
  724. ! if (vdis_tot>NeededVolumeAnnular) then
  725. !
  726. ! Annular_closed=1
  727. ! p_acc= RAM(RNUMBER)%p_acccheck
  728. !
  729. ! if (AnnularIsClosing) then
  730. ! IDAnnular=ODDrillpipe_inAnnular
  731. ! AnnularCloseLed = LedOn
  732. ! AnnularOpenLed = LedOff
  733. ! endif
  734. !
  735. ! if (AnnularIsOpening) then
  736. ! IDAnnular=IDAnnularBase
  737. ! AnnularOpenLed = LedOn
  738. ! AnnularCloseLed = LedOff
  739. ! endif
  740. !
  741. ! endif
  742. !
  743. !endif
  744. end
  745. SUBROUTINE bop_codeAnnular(RNUMBER)
  746. USE VARIABLES
  747. USE CBopControlPanelVariables
  748. USE CEquipmentsConstants
  749. USE TD_GeneralData
  750. implicit none
  751. INTEGER RNUMBER, I
  752. !Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
  753. !====================================================
  754. ! BOP back pressure without DP
  755. !====================================================
  756. !if (bop_type==3) then
  757. !p_annular=510.725-(30.145*IDAnnular)
  758. AnnularComputational%p_annular=448-(19.7*Annular%IDAnnular)
  759. ! Q=flow
  760. ! endif
  761. RAM(RNUMBER)%clock=0
  762. !======================Losses============================
  763. RAM(RNUMBER)%loss_after=0 !initial value
  764. RAM(RNUMBER)%diffp_ram=1000 !initial value
  765. RAM(RNUMBER)%loss_before=0
  766. !Q=0.0055; %initial flow rate (m^3/s)
  767. RAM(RNUMBER)%Q=RAM(RNUMBER)%flow
  768. !write(*,*) 'Q1=' , Q
  769. !write(*,*) 'tol=' , tol
  770. do while (abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)/ RAM(RNUMBER)%diffp_ram>Annular%tolAnnular)
  771. if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) exit
  772. ! while abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)>10
  773. RAM(RNUMBER)%clock= RAM(RNUMBER)%clock+1
  774. if ( RAM(RNUMBER)%clock>20) then
  775. ! tclock=clock
  776. Annular%tolAnnular=Annular%tolzeroAnnular+(floor( RAM(RNUMBER)%clock/10)-1)*.001
  777. endif
  778. ! if (clock==1) continue
  779. if ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after> RAM(RNUMBER)%diffp_ram) then
  780. RAM(RNUMBER)%Q=RAM(RNUMBER)%Q-.1
  781. elseif ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after<= RAM(RNUMBER)%diffp_ram) then
  782. RAM(RNUMBER)%Q=RAM(RNUMBER)%Q+.01
  783. endif
  784. !====================Before Regulator=========================
  785. do i=1,AnnularComputational%NO_PipingsAnnularLine
  786. AnnularComputational%Re_ANNULARline(i)=RAM(RNUMBER)%Q*6.30902e-5*AnnularComputational%DIAM_ANNULARLINE_INCH(i)*0.0254/(AnnularComputational%AREA_ANNULARLINE(i)*nu)
  787. enddo
  788. do i=1,AnnularComputational%NO_PipingsAnnularLine
  789. if (AnnularComputational%Re_ANNULARline(i)<Re_cr) then
  790. AnnularComputational%fricANNULAR(i)=64/AnnularComputational%Re_ANNULARline(i)
  791. else
  792. AnnularComputational%fricANNULAR(i)=1/(-1.8*log10((AnnularComputational%RELROUGH_ANNULARLINE(i)/3.7)**1.11+6.9/AnnularComputational%Re_ANNULARline(i)))**2
  793. endif
  794. AnnularComputational%friclossANNULAR(i)=((AnnularComputational%fricANNULAR(i)*(wdens*sg*AnnularComputational%LENGT_ANNULARLINE(i)*(RAM(RNUMBER)%Q*6.30902e-5/AnnularComputational%AREA_ANNULARLINE(i))**2))/(2*AnnularComputational%DIAM_ANNULARLINE_INCH(i)*0.0254))/6895
  795. enddo
  796. RAM(RNUMBER)%pipe_loss1=sum(AnnularComputational%friclossANNULAR(1:6)) !loss before regulator(psi)
  797. do i=1,AnnularComputational%NO_MinorsAnnularLine
  798. if (AnnularComputational%LF_ANNULARLINE(i)/=0) then
  799. AnnularComputational%minlosspa_ANNULAR(i)=AnnularComputational%LF_ANNULARLINE(i)*wdens*sg*(RAM(RNUMBER)%Q*6.30902e-5/AnnularComputational%AREAMINOR_ANNULARLINE(i))**2/2 !(Pa)
  800. AnnularComputational%minloss_ANNULAR(i)=AnnularComputational%minlosspa_ANNULAR(i)/6895 !(psi)
  801. elseif (AnnularComputational%CV_ANNULARLINE(i)/=0) then
  802. AnnularComputational%minlosspa_ANNULAR(i)=1000*sg*((11.7*RAM(RNUMBER)%Q*6.30902e-5*3600)/(AnnularComputational%CV_ANNULARLINE(i)))**2 !(pa)
  803. AnnularComputational%minloss_ANNULAR(i)=AnnularComputational%minlosspa_ANNULAR(i)/6895 !(psi)
  804. else
  805. AnnularComputational%minlosspa_ANNULAR(i)=AnnularComputational%NOTE_ANNULARLINE(i)*1e5 !(pa)
  806. AnnularComputational%minloss_ANNULAR(i)=AnnularComputational%minlosspa_ANNULAR(i)/6895 !(psi)
  807. endif
  808. enddo
  809. AnnularComputational%minloss_ANNULAR(17)= 3.4*RAM(RNUMBER)%Q ! <==== regulator loss (psig)
  810. RAM(RNUMBER)%minor_loss1=sum(AnnularComputational%minloss_ANNULAR(1:16)) !loss before regulator(psi)
  811. RAM(RNUMBER)%static_loss1=0
  812. RAM(RNUMBER)%kinetic_loss1=sg*wdens*(RAM(RNUMBER)%Q*6.30902e-5/((1/4.)*pi*(.72*0.254e-1)**2))**2/(2*6895) !(psi)
  813. !.72 for regulator diameter)
  814. RAM(RNUMBER)%loss_before= RAM(RNUMBER)%pipe_loss1+ RAM(RNUMBER)%minor_loss1+ RAM(RNUMBER)%static_loss1+ RAM(RNUMBER)%kinetic_loss1 !(psi)
  815. !===================after Regulator======================
  816. ! all in (psi)
  817. RAM(RNUMBER)%pipe_loss2=sum(AnnularComputational%friclossANNULAR(7:AnnularComputational%NO_PipingsAnnularLine)) !7=after regulator<<<<<<<
  818. RAM(RNUMBER)%minor_loss2=sum(AnnularComputational%minloss_ANNULAR(17:AnnularComputational%NO_MinorsAnnularLine)) !17=after regulator<<<<<<<
  819. RAM(RNUMBER)%deltah=Annular%H_AnnularBop-ShearRam%H_REGRAM
  820. ! RAM(RNUMBER)%static_loss2pa= RAM(RNUMBER)%deltah*sg*wdens*gravity; %(pa)
  821. RAM(RNUMBER)%static_loss2= RAM(RNUMBER)%deltah*sg*wdens*gravity/6895 !(psi)
  822. RAM(RNUMBER)%kinetic_loss2=0
  823. RAM(RNUMBER)%loss_after= RAM(RNUMBER)%pipe_loss2+ RAM(RNUMBER)%minor_loss2+ RAM(RNUMBER)%static_loss2 !(psi)
  824. !=======================================================
  825. !==========================p_regulator======================
  826. if (Annular%Pannular_regset<RamLine%P_ACC- RAM(RNUMBER)%loss_before) then
  827. !!new= Pannular_regset-minloss_ANNULAR(17)
  828. !
  829. !CALL Pannular_regDelay%AddToFirst( Pannular_regset-minloss_ANNULAR(17) )
  830. !CALL Pannular_regDelay%Remove(Pannular_regDelay%Length())
  831. !Pannular_reg= Pannular_regDelay%Last()
  832. Annular%Pannular_reg= Annular%Pannular_regset-AnnularComputational%minloss_ANNULAR(17)
  833. ! RAM(RNUMBER)%loss_after= RAM(RNUMBER)%loss_after-minloss(17); %minloss(17)=regulator loss
  834. else
  835. !!new= p_acc- RAM(RNUMBER)%loss_before-minloss_ANNULAR(17)
  836. !
  837. !CALL Pannular_regDelay%AddToFirst( p_acc- RAM(RNUMBER)%loss_before-minloss_ANNULAR(17) )
  838. !CALL Pannular_regDelay%Remove(Pannular_regDelay%Length())
  839. !Pannular_reg= Pannular_regDelay%Last()
  840. Annular%Pannular_reg= RamLine%P_ACC- RAM(RNUMBER)%loss_before-AnnularComputational%minloss_ANNULAR(17)
  841. endif
  842. !===========================================================
  843. !====================Flow Rate calculation==================
  844. RAM(RNUMBER)%diffp_ram=Annular%Pannular_reg+AnnularComputational%minloss_ANNULAR(17)-AnnularComputational%p_annular
  845. end do ! returns correct Q for one timecounter_ram
  846. if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) then
  847. RAM(RNUMBER)%Q= 5.0 ! gpm
  848. !write(*,*) 'malffffffffff'
  849. endif
  850. RAM(RNUMBER)%flow=RAM(RNUMBER)%Q
  851. !write(*,*) 'minloss_ANNULAR(17)=' , minloss_ANNULAR(17)
  852. !write(*,*) '%loss_after=' ,RAM(RNUMBER)%loss_after
  853. !====================p_accumulator for next iterate==================
  854. ! deltav=Q*1*1000; %delta_t=1sec (lit)
  855. ! fvr=fvr-deltav; %=fvr_after (lit)
  856. ! p_acc=0.001178*fvr^3+0.02019*fvr^2+16.1*fvr+2379; %(psia)
  857. ! vdis_bottles=fvr_tot-fvr; %from the start***needed for p_BOP calculating (lit)
  858. !========for a 10 gal bottle,precharge=1000psig curve BOSCH======
  859. RAM(RNUMBER)%deltav_bottles=RAM(RNUMBER)%Q*RamLine%DeltaT_BOP/60. !(galon) delta_t=1sec , Q(gpm)
  860. RamLine%FVR=RamLine%FVR- RAM(RNUMBER)%deltav_bottles !=fvr_after (galon)
  861. ! b1=993.7; b2=0.164; b3=5.492; b4=0.9796;
  862. RAM(RNUMBER)%p_acccheck=RamLine%P_ACC
  863. RamLine%P_ACC=RamLine%B1*exp(RamLine%B2*RamLine%FVR/BopStackAcc%NOBOTTLES)+RamLine%B3*exp(RamLine%B4*RamLine%FVR/BopStackAcc%NOBOTTLES) !(psig)<<<< 8=no. of bottles
  864. !formula is derived for fvr (galon)
  865. !vdis_bottles=fvr_tot-fvr
  866. RAM(RNUMBER)%vdis_bottles= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%deltav_bottles
  867. RamLine%NoActiveRmas=6.-real(Annular%Annular_closed+RamLine%ShearBop_closed+PipeRam1%closed+PipeRam2%closed+ChokeLine%closed+KillLine%closed)
  868. RAM(RNUMBER)%vdis_elecp= RAM(RNUMBER)%vdis_elecp+(Pumps%DELTAV_ELECP/RamLine%NoActiveRmas) !overal discharged
  869. RAM(RNUMBER)%fvr_air= RAM(RNUMBER)%fvr_air+(Pumps%DELTAV_AIR/RamLine%NoActiveRmas) !=fvr_after (galon) for next timecounter_ram
  870. RAM(RNUMBER)%vdis_tot= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%fvr_air+ RAM(RNUMBER)%vdis_elecp !overal
  871. !write(*,*) 'RAM(RNUMBER)%vdis_tot=' , RAM(RNUMBER)%vdis_tot!, vdis_bottles,fvr_air, vdis_elecp !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  872. !write(*,*) 'a)IDAnnular=' , IDAnnular
  873. ! WRITE(*,*) 'a)NeededVolumeAnnular=' , NeededVolumeAnnular
  874. !
  875. ! write(*,*) 'AbopAnnular= ' , AbopAnnular
  876. ! write(*,*) 'max=' , max(ODDrillpipe_inAnnular,ODDrillpipe_inAnnularBase)
  877. !if (ramtype==4) then !for annular
  878. if (Annular%AnnularIsClosing) then
  879. Annular%IDAnnular=(2.*(Annular%NeededVolumeAnnular- RAM(RNUMBER)%vdis_tot)*231./Annular%AbopAnnular)+max(Annular%ODDrillpipe_inAnnular,Annular%ODDrillpipe_inAnnularBase)
  880. !write(*,*) 'b)IDAnnular=' , IDAnnular
  881. endif
  882. if (Annular%AnnularIsOpening) then
  883. Annular%IDAnnular=Annular%IDAnnularBase-2.*(Annular%NeededVolumeAnnular- RAM(RNUMBER)%vdis_tot)*231./Annular%AbopAnnular
  884. endif
  885. if ( RAM(RNUMBER)%vdis_tot>Annular%NeededVolumeAnnular) then
  886. Annular%Annular_closed=1
  887. !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1)
  888. !pram_reg=pram_reg+minloss_ANNULAR(17)
  889. Annular%Pannular_reg= Annular%Pannular_reg+AnnularComputational%minloss_ANNULAR(17)
  890. RamLine%P_ACC= RAM(RNUMBER)%p_acccheck
  891. if (Annular%AnnularIsClosing) then
  892. Annular%IDAnnular=max(Annular%ODDrillpipe_inAnnular,Annular%ODDrillpipe_inAnnularBase)
  893. BopControlPanel%AnnularCloseLED = LedOn
  894. BopStackInput%AnnularCloseLedMine = LedOn
  895. BopControlPanel%AnnularOpenLED = LedOff
  896. BopStackInput%AnnularOpenLedMine = LedOff
  897. if (TD_BOP%BOPConnectionPossibility(1) == 1) then
  898. CALL CloseAnnular
  899. Annular%Annular_Situation_forTD= 1 ! closed - for TD code
  900. endif
  901. endif
  902. if (Annular%AnnularIsOpening) then
  903. Annular%IDAnnular=Annular%IDAnnularBase
  904. BopControlPanel%AnnularOpenLED = LedOn
  905. BopStackInput%AnnularOpenLedMine = LedOn
  906. BopControlPanel%AnnularCloseLED = LedOff
  907. BopStackInput%AnnularCloseLedMine = LedOff
  908. CALL OpenAnnular
  909. Annular%Annular_Situation_forTD= 0 ! open - for TD code
  910. endif
  911. endif
  912. ShearRam%IDAnnularFinal= Annular%IDAnnular ! for output data
  913. !endif
  914. end