Simulation Core
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

501 строка
16 KiB

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