Simulation Core
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

MudSystemStartup.f90 21 KiB

před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
před 1 rokem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. SUBROUTINE NormalCirculation_StartUp() ! is called in module FluidFlowMain
  2. USE MudSystemVARIABLES
  3. use SimulationVariables !@@@
  4. use CTanks
  5. use SimulationVariables
  6. USE CMudPropertiesVariables
  7. Use GeoElements_FluidModule
  8. use KickVARIABLESModule
  9. Use CUnityOutputs
  10. Use CShoeVariables
  11. use SimulationVariables
  12. implicit none
  13. ! temporary varibales for solving pressure jerks -- 1399-11-09
  14. !Pump1BlownInTimeStep = 0
  15. !Pump2BlownInTimeStep = 0
  16. !Pump3BlownInTimeStep = 0
  17. !Pump1BlownStarted = .FALSE.
  18. !Pump2BlownStarted = .FALSE.
  19. !Pump3BlownStarted = .FALSE.
  20. data%State%MudSystem%Pump1BlownCount = 0
  21. data%State%MudSystem%Pump2BlownCount = 0
  22. data%State%MudSystem%Pump3BlownCount = 0
  23. data%State%MudSystem%DeltaWellCap=0.
  24. data%State%MudSystem%WellCapOld = 0.
  25. data%State%MudSystem%AnnCapOld=0.
  26. data%State%MudSystem%DeltaAnnCap=0.
  27. data%State%MPumps%Total_Stroke_Counter_For_Plot = 0.0
  28. data%State%MudSystem%DeltaT_Mudline=0.1 !second
  29. Call Set_FlowKellyDisconnect(.false.)
  30. Call Set_FlowPipeDisconnect(.false.)
  31. !HZ_ADD= 0.d0
  32. data%State%MudSystem%Flow_timeCounter= 0
  33. data%State%MudSystem%MudSys_timeCounter= 0
  34. data%State%MudSystem%FluidFlowCounter = 0
  35. !========================================================================
  36. ! MUD CIRCULATION STARTUP
  37. !========================================================================
  38. data%State%MudSystem%FormationLostPressure= Shoe%LeakOff * Shoe%ShoeDepth
  39. data%State%MudSystem%ShoeFractured= .false.
  40. data%State%MudSystem%UGBOSuccessionCounter = 0 ! also in starup
  41. data%State%MudSystem%UGBOSuccessionCounterOld = 0 ! also in starup
  42. data%State%MudSystem%ChokeLineFlowRate= 0.0
  43. data%State%MudSystem%StringFlowRate= 0.0
  44. data%State%MudSystem%AnnulusFlowRate= 0.0
  45. data%State%MudSystem%MudVolume_InjectedFromAnn= 0.D0
  46. data%State%MudSystem%MudVolume_InjectedToBH= 0.D0
  47. data%State%MudSystem%DensityMixTol= 0.1 !(ppg)
  48. data%State%MudSystem%CuttingDensityMixTol= 0.5
  49. data%State%MudSystem%NewPipeFilling= 1
  50. data%State%MudSystem%UtubeFilling= 1
  51. data%State%MudSystem%UtubeEmptyVolume= 0.0
  52. data%State%MudSystem%UtubeMode1Activated= .false.
  53. data%State%MudSystem%UtubeMode2Activated= .false.
  54. data%State%MudSystem%UtubePossibility= .false.
  55. !KickMigration_2SideBit = .FALSE.
  56. data%State%MudSystem%KickDx= (Reservoir%AutoMigrationRate/3600.)*data%State%MudSystem%DeltaT_Mudline !AutoMigrationRate (ft/h)= ft per DeltaT_Mudline
  57. data%State%MudSystem%NewInfluxElementCreated= 0
  58. data%State%MudSystem%NewInfluxNumber= 0
  59. !KickVolumeinAnnulus= 0.0
  60. data%State%MudSystem%KickDeltaVinAnnulus= 0.0
  61. KickVARIABLES%GasKickPumpFlowRate= 0.0
  62. data%State%MudSystem%FirstMudSet= 0
  63. data%State%MudSystem%FirstSetUtube1=0
  64. data%State%MudSystem%FirstSetUtube2=0
  65. data%State%MudSystem%SuctionMud=1
  66. data%State%MudSystem%ImudCount= 1
  67. imud=1
  68. data%State%MudSystem%iLoc= 1 ! for Kick
  69. data%State%MudSystem%Suction_Density_MudSystem= MudProperties%ActiveDensity
  70. data%State%MudSystem%SuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg)
  71. data%State%MudSystem%StringDensity_Old= MudProperties%ActiveDensity ! initial(ppg)
  72. data%State%MudSystem%AnnulusSuctionDensity_Old= MudProperties%ActiveDensity ! initial(ppg)
  73. data%State%MudSystem%ChokeLineDensity_Old= MudProperties%ActiveDensity ! initial(ppg)
  74. data%State%MudSystem%TotalAddedVolume= 0.
  75. data%State%MudSystem%xx=0.
  76. END SUBROUTINE NormalCirculation_StartUp
  77. SUBROUTINE MudSystem_StartUp()
  78. USE CMudPropertiesVariables
  79. USE MudSystemVARIABLES
  80. use SimulationVariables !@@@
  81. use CDataDisplayConsole
  82. use SimulationVariables
  83. USE CHOKEVARIABLES
  84. use SimulationVariables !@
  85. use SimulationVariables
  86. USE CBopStackVariables
  87. use CPumpsVariables
  88. use CPumps
  89. use CTanks
  90. use SimulationVariables
  91. use KickVARIABLESModule
  92. implicit none
  93. CALL MUDLINE_LOSS_INPUTS()
  94. !data%State%MPumps%Total_Pump_GPM=10. ! Initial Value
  95. data%State%MUD%Q=0. ! Commented by mahmood
  96. data%State%MudSystem%Q_flow32=0.
  97. data%State%MudSystem%Q_flow33=0.
  98. data%State%MudSystem%Q_flow34=0.
  99. data%State%MudSystem%Q_flow35=0.
  100. data%State%MudSystem%DeltaT_Mudline=0.1 !second
  101. KickVARIABLES%GasKickPumpFlowRate= 0.
  102. data%State%MudSystem%BellNippleVolume= 0.
  103. data%State%MudSystem%BellNippleDensity= 0.
  104. data%State%MudSystem%MudBucketVolume= 0.
  105. data%State%MudSystem%MudBucketDensity= 0.
  106. data%State%MudSystem%BellNippleDumpVolume= 0.
  107. !BellNippleDumpRate= 0.
  108. !BellNippleToPitsRate= 0.0
  109. data%State%MudSystem%MudChecked= .true.
  110. data%State%MudSystem%condition32Final= .TRUE.
  111. data%State%MudSystem%condition33Final= .TRUE.
  112. data%State%MudSystem%condition34Final= .TRUE.
  113. data%State%MudSystem%PressureGauge75= 0.0
  114. data%State%MudSystem%PressureGauge76 = 0.0
  115. !!======================================================================
  116. !! TRIP TANK
  117. !!======================================================================
  118. data%State%MudSystem%TripTank_MinVol_Allowded= 50.*42. !(bbl to gal, initial value)
  119. data%State%MudSystem%TripTank_MaxVol_Allowded= 50. *42. !(bbl to gal, initial value)
  120. data%State%MudSystem%ActiveTankFloorArea= (MudProperties%ActiveTotalTankCapacityGal) / (7.48051948*100./12.) ! (ft^2) - Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3
  121. data%State%MudSystem%TripTankFloorArea= (50.*42.) / (7.48051948*100./12.) ! (ft^2) - 50.*42.=Trip Tank Capacity in BBl*42= Gal , Tank Height= 100 inch , 12=inch to ft 7.48051948=gal to ft^3
  122. data%State%MudSystem%TripTank_Vol= MudProperties%InitialTripTankMudVolumeGal !(gal)
  123. data%State%MudSystem%TripTank_Dens= 1.
  124. data%EquipmentControl%DataDisplayConsole%TripTankGauge=0.
  125. data%State%MudSystem%ReturnToTrip_Q= 1.
  126. data%State%MudSystem%ActiveToTrip_Q= 1.
  127. data%State%MudSystem%TripTankPump_Q= .8
  128. data%State%MudSystem%ReturnToTrip_Dens=1.0 ! ppg(lbm/gal)
  129. data%State%MudSystem%ActiveToTrip_Dens=1.0
  130. !!======================================================================
  131. !! MUD VOLUME TOTALIZER
  132. !!======================================================================
  133. data%State%MudSystem%Mp1Density= 0.0 !(VALVE82)
  134. data%State%MudSystem%Mp2Density= 0.0 !(VALVE83)
  135. data%State%MudSystem%Mp3Density= 0.0 !(VALVE84)
  136. data%State%MudSystem%ReserveTankVolume= MudProperties%ReserveMudVolumeGal ! initial volume (gal)
  137. data%State%MudSystem%ReserveTankDensity= MudProperties%ReserveDensity ! initial
  138. data%State%MudSystem%CementTankVolumeCalc= data%EquipmentControl%Tank%CementTankVolume !movaghat--- initial volume (gal)
  139. data%State%MudSystem%CementTankDensityCalc= data%EquipmentControl%Tank%CementTankDensity !movaghat--- initial
  140. data%State%MudSystem%PumpsDumpVolume=0.0
  141. data%State%MudSystem%PumpsDumpFlowRate= 0.0
  142. data%State%MudSystem%ActiveTankVolume= MudProperties%ActiveMudVolumeGal ! initial volume (gal)
  143. data%State%MudSystem%RefrencePitVolume= data%State%MudSystem%ActiveTankVolume/42. !(bbl)
  144. data%State%MudSystem%RefrencePitVolume_DrillWatch= data%State%MudSystem%ActiveTankVolume/42. !(bbl)
  145. data%State%MudSystem%MVT_MinVol_Allowded= 0.
  146. data%State%MudSystem%MVT_MaxVol_Allowded= 0.
  147. data%State%MudSystem%MudTank1_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal)
  148. data%State%MudSystem%MudTank2_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal)
  149. data%State%MudSystem%MudTank3_vol= MudProperties%ActiveMudVolumeGal/3. ! (gal)
  150. data%State%MudSystem%ActiveTankSettled= MudProperties%ActiveSettledContentsGal ! (gal)
  151. data%State%MudSystem%MudTank4_vol= MudProperties%InitialTripTankMudVolumeGal ! (gal)
  152. data%State%MudSystem%TripTankVolumeCalc= MudProperties%InitialTripTankMudVolumeGal ! initial volume (gal)
  153. data%State%MudSystem%ActiveTankDensity= MudProperties%ActiveDensity ! initial(ppg)
  154. data%State%MudSystem%TripTankDensityCalc= data%EquipmentControl%Tank%TripTankDensity ! initial(ppg)
  155. data%State%MudSystem%ChokeManifoldDumpVolume= 0.0
  156. data%State%MudSystem%PitGainLossZero= 0.
  157. data%State%MudSystem%PitGainLossZero_Old= data%State%MudSystem%PitGainLossZero
  158. data%State%MudSystem%MVTCoarseKnob_Old= data%EquipmentControl%DataDisplayConsole%MVTCoarseKnob
  159. data%State%MudSystem%MVTFineKnob_Old= data%EquipmentControl%DataDisplayConsole%MVTFineKnob
  160. data%State%MudSystem%FirstSet_Time= .true.
  161. data%State%MudSystem%PedalMeter= MudProperties%PedalFlowMeter !1600. !(gpm)
  162. data%State%MudSystem%ReturnFlowRate=0.
  163. data%State%MudSystem%TotalStrokes1MFFI =0.
  164. data%State%MudSystem%TotalStrokes2MFFI =0.
  165. data%State%MudSystem%TotalStrokesPump1=0.
  166. data%State%MudSystem%TotalStrokesPump2=0.
  167. data%State%MudSystem%GraphTotalStrokes=0.
  168. data%State%Choke%TotalStrokes1 =0.
  169. data%State%Choke%TotalStrokes2 =0.
  170. end
  171. SUBROUTINE MUDLINE_LOSS_INPUTS()
  172. USE MudSystemVARIABLES
  173. use SimulationVariables !@@@
  174. USE CBopStackVariables
  175. use CPumpsVariables
  176. use CPumps
  177. implicit none
  178. INTEGER I
  179. !===========================================================================
  180. ! MUDLINE MINOR LOSSES INPUT
  181. !===========================================================================
  182. data%State%MudSystem%NO_MudMinors=4
  183. ALLOCATE (data%State%MudSystem%MudMinors(data%State%MudSystem%NO_MudMinors,4))
  184. ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
  185. data%State%MudSystem%MudMinors(1,1)= data%Configuration%Pumps%MudPump1Output
  186. data%State%MudSystem%MudMinors(1,2:4)= (/1.5*8., 0., 0./) !elbow (MLnumber=1,,PumpsToString)
  187. data%State%MudSystem%MudMinors(2,1)= data%Configuration%Pumps%MudPump1Output
  188. data%State%MudSystem%MudMinors(2,2:4)= (/1.5*6., 0., 0./) !elbow (MLnumber=2,,STGaugeToString)
  189. data%State%MudSystem%MudMinors(3,1:4)= (/0., 0., 0., 0./) !elbow (MLnumber=3,,WellToPits)
  190. data%State%MudSystem%MudMinors(4,1)= data%Configuration%BopStack%ChokeLineId
  191. data%State%MudSystem%MudMinors(4,2:4)= (/1.5*7., 0., 0./) !elbow (MLnumber=4,,WellToChokeManifold)
  192. ALLOCATE (data%State%MudSystem%MINORDIAMETER_MUDLINE(data%State%MudSystem%NO_MudMinors),data%State%MudSystem%AREAMINOR_MUDLINE(data%State%MudSystem%NO_MudMinors),data%State%MudSystem%LF_MUDLINE(data%State%MudSystem%NO_MudMinors),data%State%MudSystem%CV_MUDLINE(data%State%MudSystem%NO_MudMinors) &
  193. ,data%State%MudSystem%NOTE_MUDLINE(data%State%MudSystem%NO_MudMinors))
  194. DO I=1,data%State%MudSystem%NO_MudMinors
  195. data%State%MudSystem%MINORDIAMETER_MUDLINE(I)=data%State%MudSystem%MudMinors(I,1)
  196. data%State%MudSystem%LF_MUDLINE(I)=data%State%MudSystem%MudMinors(I,2)
  197. data%State%MudSystem%CV_MUDLINE(I)=data%State%MudSystem%MudMinors(I,3)
  198. data%State%MudSystem%NOTE_MUDLINE(I)=data%State%MudSystem%MudMinors(I,4)
  199. data%State%MudSystem%AREAMINOR_MUDLINE(I)=PII*(data%State%MudSystem%MINORDIAMETER_MUDLINE(I)*0.0254)**2/4. !D(in), AREA(m^2)
  200. ENDDO
  201. !===========================================================================
  202. ! MUDLINE PIPNING LOSSES INPUT
  203. !===========================================================================
  204. data%State%MudSystem%NO_PIPINGSMUDLINE=4
  205. ALLOCATE (data%State%MudSystem%PIPINGS_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE,3))
  206. ! ID(INCH) L(FEET) ROUGHNESS(MM)=e DESCRIPTION
  207. data%State%MudSystem%PIPINGS_MUDLINE(1,1)= data%Configuration%Pumps%MudPump1Output
  208. data%State%MudSystem%PIPINGS_MUDLINE(1,2:3)= (/265., 0.03/) !(MLnumber=1,,PumpsToString)
  209. data%State%MudSystem%PIPINGS_MUDLINE(2,1)= data%Configuration%Pumps%MudPump1Output
  210. data%State%MudSystem%PIPINGS_MUDLINE(2,2:3)= (/100., 0.03/) !(MLnumber=2,,STGaugeToString)
  211. data%State%MudSystem%PIPINGS_MUDLINE(3,1:3)= (/0., 0., 0./) !(MLnumber=3,,WellToPits)
  212. data%State%MudSystem%PIPINGS_MUDLINE(4,1)= data%Configuration%BopStack%ChokeLineId
  213. data%State%MudSystem%PIPINGS_MUDLINE(4,2)= data%Configuration%BopStack%ChokeLineLength
  214. data%State%MudSystem%PIPINGS_MUDLINE(4,3)= 0.03 !(MLnumber=4,,WellToChokeManifold)
  215. data%State%MudSystem%Area_ChokeLineFt= PII*((data%Configuration%BopStack%ChokeLineId/12.)**2)/4. !D(in), AREA(ft^2)
  216. data%State%MudSystem%ChokeLine_VolumeCapacity= data%State%MudSystem%Area_ChokeLineFt* data%Configuration%BopStack%ChokeLineLength* 7.48051948 ! (gal)
  217. ALLOCATE (data%State%MudSystem%DIAM_MUDLINE_INCH(data%State%MudSystem%NO_PIPINGSMUDLINE), &
  218. data%State%MudSystem%AREA_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE),data%State%MudSystem%LENGT_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE),data%State%MudSystem%ROUGHNESS_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE),data%State%MudSystem%RELROUGH_MUDLINE(data%State%MudSystem%NO_PIPINGSMUDLINE))
  219. DO I=1,data%State%MudSystem%NO_PIPINGSMUDLINE
  220. data%State%MudSystem%DIAM_MUDLINE_INCH(I)=data%State%MudSystem%PIPINGS_MUDLINE(I,1)
  221. data%State%MudSystem%LENGT_MUDLINE(I)=data%State%MudSystem%PIPINGS_MUDLINE(I,2)
  222. data%State%MudSystem%ROUGHNESS_MUDLINE(I)=data%State%MudSystem%PIPINGS_MUDLINE(I,3)
  223. data%State%MudSystem%AREA_MUDLINE(I)=PII*(data%State%MudSystem%DIAM_MUDLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m^2)
  224. data%State%MudSystem%RELROUGH_MUDLINE(I)=data%State%MudSystem%ROUGHNESS_MUDLINE(I)/(data%State%MudSystem%DIAM_MUDLINE_INCH(I)*25.4) !e/D
  225. !DIAM_MUDLINE_MM(I)=DIAM_MUDLINE_MM(I)*.001 ! (m)
  226. data%State%MudSystem%LENGT_MUDLINE(I)=data%State%MudSystem%LENGT_MUDLINE(I)*.3048 ! (m)
  227. ENDDO
  228. !===========================================================================
  229. ! MUDLINE STATIC LOSSES INPUT
  230. !===========================================================================
  231. ! Height are in (meter)
  232. data%State%MudSystem%Pumps_Height= 0.
  233. data%State%MudSystem%STpipeGauge_Height= 2. !(m)
  234. data%State%MudSystem%Pits_Height= 1. !(m)
  235. data%State%MudSystem%ChokeManifold_Height= 1.*0.3048 !(ft to meter)
  236. data%State%MudSystem%WellChokeExit_Height= data%Configuration%BopStack%GroundLevel-data%Configuration%BopStack%KillHeight
  237. END
  238. SUBROUTINE MUDLINE_LOSSES(MLnumber)
  239. USE MudSystemVARIABLES
  240. use SimulationVariables !@@@
  241. implicit none
  242. integer I
  243. INTEGER MLnumber
  244. !===============================PIPE LOSS===================================
  245. data%State%MUD(MLnumber)%Re_MUDline=data%State%MUD(MLnumber)%Q*6.30902e-5*data%State%MudSystem%DIAM_MUDLINE_INCH(MLnumber)*0.0254/(data%State%MudSystem%AREA_MUDLINE(MLnumber)*data%State%MUD(MLnumber)%nu) !<<<<<< nu: DOROST SHAVAD.ALAN DAR STARTUP SET SHODE
  246. !write(*,*) 'data%State%MUD(MLnumber)%Re_MUDline=' , data%State%MUD(MLnumber)%Re_MUDline
  247. ! Q*6.30902e-5 for (gpm) to (m^3/sec)
  248. if ( data%State%MUD(MLnumber)%Re_MUDline<Re_cr) then
  249. data%State%MUD(MLnumber)%fric=64/ data%State%MUD(MLnumber)%Re_MUDline
  250. else
  251. data%State%MUD(MLnumber)%fric=1/(-1.8*log10((data%State%MudSystem%RELROUGH_MUDLINE(MLnumber)/3.7)**1.11+6.9/ data%State%MUD(MLnumber)%Re_MUDline))**2
  252. endif
  253. data%State%MUD(MLnumber)%fricloss=((data%State%MUD(MLnumber)%fric*(wdens*data%State%MUD(MLnumber)%Mud_SG*data%State%MudSystem%LENGT_MUDLINE(MLnumber)*(data%State%MUD(MLnumber)%Q*6.30902e-5/data%State%MudSystem%AREA_MUDLINE(MLnumber))**2))/(2*data%State%MudSystem%DIAM_MUDLINE_INCH(MLnumber)*0.0254))/6895
  254. !==============================MINOR LOSS===================================
  255. if (data%State%MudSystem%LF_MUDLINE(MLnumber)/=0) then
  256. data%State%MUD(MLnumber)%minlosspa_MUDLINE=data%State%MudSystem%LF_MUDLINE(MLnumber)*wdens*data%State%MUD(MLnumber)%Mud_SG*(data%State%MUD(MLnumber)%Q*6.30902e-5/data%State%MudSystem%AREAMINOR_MUDLINE(MLnumber))**2/2 !(Pa)
  257. data%State%MUD(MLnumber)%minloss_MUDLINE= data%State%MUD(MLnumber)%minlosspa_MUDLINE/6895 !(psi)
  258. elseif (data%State%MudSystem%CV_MUDLINE(MLnumber)/=0) then
  259. data%State%MUD(MLnumber)%minlosspa_MUDLINE=1000*data%State%MUD(MLnumber)%Mud_SG*((11.7*data%State%MUD(MLnumber)%Q*6.30902e-5*3600)/(data%State%MudSystem%CV_MUDLINE(MLnumber)))**2 !(pa)
  260. data%State%MUD(MLnumber)%minloss_MUDLINE= data%State%MUD(MLnumber)%minlosspa_MUDLINE/6895 !(psi)
  261. else
  262. data%State%MUD(MLnumber)%minlosspa_MUDLINE=data%State%MudSystem%NOTE_MUDLINE(MLnumber)*1e5 !(pa)
  263. data%State%MUD(MLnumber)%minloss_MUDLINE= data%State%MUD(MLnumber)%minlosspa_MUDLINE/6895 !(psi)
  264. endif
  265. !==========================STATIC & KINETIC LOSS=============================
  266. data%State%MudSystem%String_Height= 50.*0.3048 !<<<<<<<<<<<<<<< (foot) to (meter). az khanom tarmigh
  267. data%State%MUD(1)%static_loss=(data%State%MudSystem%String_Height- data%State%MudSystem%Pumps_Height)*0.0 !(MLnumber=1,,PumpsToString)
  268. data%State%MUD(2)%static_loss=(data%State%MudSystem%String_Height- data%State%MudSystem%STpipeGauge_Height)*data%State%MUD(2)%Mud_SG*wdens*gravity/6895 ! (psi) (MLnumber=2,,STGaugeToString)
  269. data%State%MUD(3)%static_loss=0. !(MLnumber=1,,WellToPits)
  270. data%State%MUD(4)%static_loss=(data%State%MudSystem%ChokeManifold_Height- data%State%MudSystem%WellChokeExit_Height)*data%State%MUD(4)%Mud_SG*wdens*gravity/6895 !(MLnumber=4,,WellToChokeManifold)
  271. ! data%State%RAM(RNUMBER)%kinetic_loss1=data%State%MUD(MLnumber)%Mud_SG*data%State%MUD(MLnumber)%Mud_Density*(data%State%RAM(RNUMBER)%Q*6.30902e-5/((1/4.)*pi*(.72*0.254e-1)**2))**2/(2*6895) !(psi)
  272. !============================TOTAL LOSS=======================================
  273. data%State%MUD(MLnumber)%total_loss= data%State%MUD(MLnumber)%fricloss+ data%State%MUD(MLnumber)%minloss_MUDLINE+ data%State%MUD(MLnumber)%static_loss!+ data%State%RAM(RNUMBER)%kinetic_loss1 !(psi)
  274. END
  275. SUBROUTINE DEALLOCATE_ARRAYS_MudSystem()
  276. USE MudSystemVARIABLES
  277. use SimulationVariables !@@@
  278. implicit none
  279. !===========================================================================
  280. ! RAMLINE MINOR LOSSES INPUT
  281. !===========================================================================
  282. if (allocated(data%State%MudSystem%MudMinors)) DEALLOCATE (data%State%MudSystem%MudMinors)
  283. !===========================================================================
  284. ! RAMLINE PIPNING LOSSES INPUT
  285. !===========================================================================
  286. if (allocated(data%State%MudSystem%MINORDIAMETER_MUDLINE)) DEALLOCATE (data%State%MudSystem%MINORDIAMETER_MUDLINE)
  287. if (allocated(data%State%MudSystem%AREAMINOR_MUDLINE)) DEALLOCATE (data%State%MudSystem%AREAMINOR_MUDLINE)
  288. if (allocated(data%State%MudSystem%LF_MUDLINE)) DEALLOCATE (data%State%MudSystem%LF_MUDLINE)
  289. if (allocated(data%State%MudSystem%CV_MUDLINE)) DEALLOCATE (data%State%MudSystem%CV_MUDLINE)
  290. if (allocated(data%State%MudSystem%NOTE_MUDLINE)) DEALLOCATE (data%State%MudSystem%NOTE_MUDLINE)
  291. !===========================================================================
  292. ! ANNULAR MINOR LOSSES INPUT
  293. !===========================================================================
  294. if (allocated(data%State%MudSystem%PIPINGS_MUDLINE)) DEALLOCATE (data%State%MudSystem%PIPINGS_MUDLINE)
  295. !===========================================================================
  296. ! ANNULAR PIPNING LOSSES INPUT
  297. !===========================================================================
  298. if (allocated(data%State%MudSystem%DIAM_MUDLINE_INCH)) DEALLOCATE (data%State%MudSystem%DIAM_MUDLINE_INCH)
  299. if (allocated(data%State%MudSystem%AREA_MUDLINE)) DEALLOCATE (data%State%MudSystem%AREA_MUDLINE)
  300. if (allocated(data%State%MudSystem%LENGT_MUDLINE)) DEALLOCATE (data%State%MudSystem%LENGT_MUDLINE)
  301. if (allocated(data%State%MudSystem%ROUGHNESS_MUDLINE)) DEALLOCATE (data%State%MudSystem%ROUGHNESS_MUDLINE)
  302. if (allocated(data%State%MudSystem%RELROUGH_MUDLINE)) DEALLOCATE (data%State%MudSystem%RELROUGH_MUDLINE)
  303. END
  304. subroutine AddDynamicArray(array, value)
  305. implicit none
  306. REAL, allocatable, intent(inout) :: array(:)
  307. REAL, intent(in) :: value
  308. REAL, allocatable :: tempArr(:)
  309. integer :: i, isize
  310. !if(allocated(array)) then
  311. ! isize = size(array)
  312. ! allocate(tempArr(isize+1))
  313. ! do i=1,isize
  314. ! tempArr(i) = array(i)
  315. ! end do
  316. ! tempArr(isize+1) = value
  317. ! deallocate(array)
  318. ! call move_alloc(tempArr, array)
  319. !else
  320. ! allocate(array(1))
  321. ! array(1) = value
  322. !end if
  323. end subroutine