Simulation Core
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

512 rindas
21 KiB

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