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.
 
 
 
 
 
 

233 lines
11 KiB

  1. MODULE MudSystemVARIABLES
  2. use DynamicDoubleArray
  3. use DynamicIntegerArray
  4. use CDownHoleVariables
  5. use CBopControlPanelVariables
  6. use CEquipmentsConstants
  7. use CSimulationVariables
  8. use CAccumulatorVariables
  9. use CBopStackVariables
  10. use CChokeControlPanelVariables
  11. use CStandPipeManifoldVariables
  12. USE CReservoirVariables
  13. IMPLICIT NONE
  14. ! temporary varibales for solving pressure jerks -- 1399-11-09
  15. integer Pump1BlownCount, Pump2BlownCount, Pump3BlownCount
  16. integer, parameter :: BlownThreshold = 10
  17. !integer Pump1BlownInTimeStep, Pump2BlownInTimeStep, Pump3BlownInTimeStep
  18. !logical Pump1BlownStarted, Pump2BlownStarted, Pump3BlownStarted
  19. !integer, parameter :: BlownThresholdInSecond = 5
  20. real(8) total_add,total_injected
  21. real(8) DeltaWellCap,WellCapOld,AnnCapOld,DeltaAnnCap
  22. !========================================================================
  23. ! KICK VARIABLES
  24. !========================================================================
  25. REAL(8) KickDeltaVinAnnulus, KickVolumeinAnnulus
  26. REAL(8) Kick_Forehead_X,Kick_RemainedVolume_in_LastSection,BackheadX,KickDv,KickDx,MinKickDv,Old_KickBackHead_X,Kick_Density
  27. INTEGER NewInfluxElementCreated,Kick_Forehead_section,MudSection,Op_KickLoc,Ann_KickLoc,FirstSetKickMigration,Old_KickBackHead_Section
  28. Integer iLoc,ChokeLine_KickLoc,KickNumber,NewInfluxNumber,SoundGasThroughChoke
  29. LOGICAL DrillingMode
  30. !real(8) HZ_ADD
  31. integer Flow_timeCounter,MudSys_timeCounter,FluidFlowCounter
  32. !========================================================================
  33. ! MUD CIRCULATION
  34. !========================================================================
  35. REAL(8), ALLOCATABLE:: Xstart_PipeSection(:),Xend_PipeSection(:),PipeSection_VolumeCapacity(:),Area_PipeSectionFt(:),OD_PipeSectionInch(:),ID_PipeSectionInch(:),Angle_PipeSection(:)
  36. REAL(8), ALLOCATABLE:: Xstart_OpSection(:),Xend_OpSection(:),Area_OpSectionFt(:),OD_OpSectionInch(:),ID_OpSectionInch(:),OpSection_VolumeCapacity(:),GeoTypeOp(:),Angle_OpSection(:)
  37. REAL(8), ALLOCATABLE:: TDXstart_MudElementArray(:) , TDXend_MudElementArray(:) , TDDensity_MudElementArray(:)
  38. INTEGER, ALLOCATABLE:: GeoType(:)
  39. real(8) StMudVolumeSum,St_MudSaved_Density,St_Saved_MudDischarged_Volume,St_Saved_MudDischarged_Volume_Final,MudVolume_InjectedToBH,MudVolume_InjectedFromAnn
  40. real BitMudDensity
  41. REAL(8) xx,TrueMinValue,NewVolume,UtubeEmptyVolume,NewDensity, MudCircVerticalDepth
  42. REAL DirectionCoef
  43. INTEGER isection,OpSection,imud,SuctionMud,NoStringMudElements,ImudCount,NoCasingMudElements,NoHorizontalMudElements,AddedElementsToString
  44. Integer TDNoHorizontalMudElements, TDNoStringMudElements, TDNoCasingMudElements
  45. Integer istring,icasing,iisection,NoPipeSections,FirstMudSet
  46. INTEGER NoBottomHoleMudElements,NoStringMudElementsForPlot,F_StringIntervalCounts_Old
  47. INTEGER FirstSetUtube1,FirstSetUtube2,FirstAdded,NewPipeFilling,Hz_MudOrKick_Utube,UtubeFilling,totalLength
  48. REAL(8) DeltaVolumeOp,DeltaVTemp,OldPosition,StringFlowRate,StringFlowRateFinal,AnnulusFlowRateFinal,TD_RemoveVolume_Remained,DeltaVolumePipe,DeltaVolumeAnnulusCapacity
  49. REAL AnnulusFlowRate,ChokeLineFlowRate
  50. Logical:: UtubePossibility,MudIsChanged,AddedPipe,UtubeMode1Activated,UtubeMode2Activated,WellisNOTFull,ChokeLineNOTFull
  51. Logical:: ShoeLost,ShoeFractured,Kickexpansion_DueToMudLost,LostInTripOutIsDone
  52. Integer UGBOSuccessionCounter, UGBOSuccessionCounterOld
  53. REAL(8) Area_ChokeLineFt, ChokeLine_VolumeCapacity,TotalAddedVolume,LackageMudVolumeAfterFilling, LackageMudVolume, NewInflux_Density
  54. real(8) DensityMixTol,Hz_Density_Utube,CuttingDensityMixTol,Op_Kick_Saved_Volume,Op_MudSaved_Density,Op_KickSaved_Density,Op_Saved_MudDischarged_Volume,OpMudVolumeSum,Op_NeededVolume_ToFill
  55. real(8) Choke_Kick_Saved_Volume,Choke_Saved_MudDischarged_Volume,Choke_KickSaved_Density,Choke_MudSaved_Density,ChokeMudVolumeSum
  56. integer Saved_Op_MudOrKick,Saved_Ann_MudOrKick,Saved_Choke_MudOrKick
  57. real(8) Choke_Saved_MudDischarged_Volume_Final,Choke_Kick_Saved_Volume_Final
  58. real(8) Qlost,FormationLostPressure,ShoeMudPressure,ShoeLostCoef, ShoeMudViscosity, ShoeMudDensity ,OldAnnulusCapacity
  59. logical:: Ann_to_Choke_2mud
  60. real(8) AnnMudVolumeSum,Ann_MudSaved_Density,Ann_KickSaved_Density,Ann_Saved_MudDischarged_Volume,Ann_Kick_Saved_Volume,Ann_Saved_MudDischarged_Volume_Final, Ann_Kick_Saved_Volume_Final
  61. type(DynamicDoubleArrayType) :: Hz_MudDischarged_Volume,Hz_Mud_Backhead_X,Hz_Mud_Forehead_X,Hz_Density,Hz_RemainedVolume_in_LastSection,Hz_EmptyVolume_inBackheadLocation, &
  62. Op_MudDischarged_Volume,Op_Mud_Backhead_X,Op_Mud_Forehead_X,Op_Density,Op_RemainedVolume_in_LastSection,Op_EmptyVolume_inBackheadLocation
  63. type(DynamicDoubleArrayType) :: ChokeLine_MudDischarged_Volume,ChokeLine_Mud_Backhead_X,ChokeLine_Mud_Forehead_X,ChokeLine_Density,ChokeLine_RemainedVolume_in_LastSection, &
  64. ChokeLine_EmptyVolume_inBackheadLocation
  65. type(DynamicDoubleArrayType) :: St_MudDischarged_Volume,St_Mud_Backhead_X,St_Mud_Forehead_X,St_Density,St_RemainedVolume_in_LastSection, &
  66. St_EmptyVolume_inBackheadLocation,Ann_MudDischarged_Volume,Ann_Mud_Backhead_X,Ann_Mud_Forehead_X, &
  67. Ann_Density,Ann_RemainedVolume_in_LastSection,Ann_EmptyVolume_inBackheadLocation
  68. type(DynamicIntegerArrayType) :: St_Mud_Backhead_section,St_Mud_Forehead_section,Ann_Mud_Backhead_section,Ann_Mud_Forehead_section,MudGeoType,Hz_Mud_Backhead_section,Hz_Mud_Forehead_section, &
  69. Op_Mud_Backhead_section,Op_Mud_Forehead_section,Hz_MudOrKick,St_MudOrKick,Ann_MudOrKick,Op_MudOrKick,ChokeLine_MudOrKick,MudTypeOp_MudElement,MudType_MudElement
  70. type(DynamicIntegerArrayType) :: ChokeLine_Mud_Backhead_section,ChokeLine_Mud_Forehead_section,Ann_CuttingMud
  71. type(DynamicDoubleArrayType) :: Xend_MudElement,Xstart_MudElement,Density_MudElement,PipeID_MudElement,PipeOD_MudElement,Angle_MudElement, &
  72. Xstart_OpMudElement,Xend_OpMudElement,Density_OpMudElement,PipeID_OpMudElement,PipeOD_OpMudElement!,Angle_OpMudElement
  73. type(DynamicDoubleArrayType) :: TVDstart_MudElement, TVDend_MudElement, TVDstart_OpMudElement, TVDend_OpMudElement
  74. type(CFluid), allocatable :: StringMudElement(:), CasingMudElement(:)
  75. real(8) PressureGauge75,PressureGauge76
  76. !========================================================================
  77. ! MALFUNCTION VARIABLES
  78. !========================================================================
  79. INTEGER StandPipeGauge1Malf, StandPipeGauge2Malf, StandPipePressure_DataDisplayMalf,StandPipePressureChokeMalf,DrillPipePressureMalf
  80. integer TripTankPressure_DataDisplayMalf,PitGainLossGaugeMalf,ReturnMudFlowGaugeMalf,MudTanksVolumeGaugeMalf
  81. !========================================================================
  82. ! TRIP TANK VARIABLES
  83. !========================================================================
  84. logical condition32Final,condition33Final,condition34Final
  85. REAL(8) TripTank_Vol,TripTank_Dens,ReturnToTrip_Q,ActiveToTrip_Q,TripTankPump_Q,ReturnToTrip_Dens,ActiveToTrip_Dens,ReturnToTrip_deltaV,ActiveToTrip_deltaV
  86. REAL(8) MassFlowRate_ReturnToTrip,MassFlowRate_ActiveToTrip,TripTankPump_deltaV,MassFlowRate_TripTankPump,NetMassFlux_tripTank
  87. REAL(8) TripTank_MinVol_Allowded,TripTank_MaxVol_Allowded
  88. !!======================================================================
  89. !! MUD VOLUME TOTALIZER
  90. !!======================================================================
  91. REAL(8) RefrencePitVolume_DrillWatch ! for DrillWatch
  92. REAL(8) MudTank1_vol,MudTank2_vol,MudTank3_vol,MudTank4_vol
  93. REAL(8) MVT_MinVol_Allowded,MVT_MaxVol_Allowded,MudTanksVolume
  94. REAL(8) PitGainLossZero,MVTCoarse,MVTFine,RefrencePitVolume,PitGainLossZero_Old,MVTCoarseKnob_Old,MVTFineKnob_Old
  95. REAL(8) ActiveTankDensity,TripTankDensityCalc,SuctionDensity_Old,AnnulusSuctionDensity_Old,StringDensity_Old,ChokeLineDensity_Old,ChokeManifoldDumpVolume
  96. LOGICAL FirstSet_Time
  97. !!======================================================================
  98. !! MUD FLOW-FILL INDICATOR
  99. !!======================================================================
  100. REAL(8) TotalStrokes1MFFI,TotalStrokes2MFFI,TotalStrokesPump1,TotalStrokesPump2,GraphTotalStrokes
  101. REAL(8) PedalMeter,ReturnFlowRate,ReturnFlowPercent,MFFI_MinPercent_Allowded,MFFI_MaxPercent_Allowded
  102. REAL(8) TotalFillStrokes1MFFI,TotalFillStrokes2MFFI,TotalFilledStrokesBy1MFFI,TotalFilledStrokesBy2MFFI,TotalFilledStrokesBy1and2MFFI
  103. !=================================================================================
  104. !============================================================================
  105. ! MUD & ENVIRONMENT VARIABLES
  106. !============================================================================
  107. REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000!,NU=9e-6
  108. !specific gravity of liquid
  109. !water density(kg/m^3)
  110. PARAMETER PII=3.14159265
  111. INTEGER NO_MudMinors,NO_PIPINGSMUDLINE
  112. REAL(8) Pumps_Height,String_Height,STpipeGauge_Height,Pits_Height,ChokeManifold_Height,WellChokeExit_Height
  113. REAL(8) STGauge_Pressure,String_Input_Pressure,Well_Output_Pressure,Pressure_BeforeChokes,Pressure_AfterChokes
  114. REAL(8) OpenArea32,OpenArea33,OpenArea34,OpenArea35,deltaPchoke,WellOutletDensity,ChokeOutletDensity
  115. REAL Q_flow32,Q_flow33,Q_flow34,Q_flow35
  116. REAL(8) DeltaT_Mudline,ActiveTankVolume,ReserveTankVolume,CementTankVolumeCalc,ActiveTankSettled,ActiveTankFloorArea,TripTankFloorArea
  117. REAL(8) TripTankVolumeCalc,BellNippleDensity,BellNippleVolume,MudBucketDensity,MudBucketVolume,BellNippleDumpVolume
  118. REAL(8) ReserveTankDensity,CementTankDensityCalc,Mp1Density,Mp2Density,Mp3Density,PumpsDumpVolume
  119. real PumpsDumpFlowRate
  120. REAL(8) Density_Ch
  121. real(8) Suction_Density_MudSystem,Suction_Density_PumpsToWell,CompressedMudDensity
  122. Logical WellToPitsOpen,WellToChokeManifoldOpen,MudChecked,WellHeadIsOpen
  123. logical Pump1OffFailure,Pump2OffFailure,Pump3OffFailure,ChokeLineGaugeToTanks,WellToChokeLineGauge
  124. REAL,ALLOCATABLE:: MudMinors(:,:),AREA_MUDLINE(:),MINORDIAMETER_MUDLINE(:),NOTE_MUDLINE(:),AREAMINOR_MUDLINE(:),LF_MUDLINE(:),CV_MUDLINE(:)
  125. REAL,ALLOCATABLE:: DIAM_MUDLINE_INCH(:),LENGT_MUDLINE(:),ROUGHNESS_MUDLINE(:),RELROUGH_MUDLINE(:),PIPINGS_MUDLINE(:,:)
  126. TYPE, PUBLIC :: MUD_TypeVars
  127. REAL Q,nu,Mud_Density,Mud_SG
  128. REAL minlosspa_MUDLINE,minloss_MUDLINE ! MINORS
  129. REAL Re_MUDline,fric,fricloss,static_loss,total_loss ! MUDLINE
  130. END TYPE MUD_TypeVars
  131. TYPE(MUD_TypeVars), DIMENSION(1:10) :: MUD
  132. !MUD(1)%Q : -------------
  133. !MUD(2)%Q : PumpsToString
  134. !MUD(3)%Q : BellNippleToPits-FullWell
  135. !MUD(4)%Q : WellToChokeManifold
  136. !MUD(5)%Q : ActiveTankToTripTank
  137. !MUD(6)%Q : TripTankToActiveTank
  138. !MUD(7)%Q : WellToBellNipple
  139. !MUD(8)%Q : BellNippleToWell-NonFullWell
  140. !MUD(9)%Q : StandPipeManifoldToChokeManifold-Through ChokeLine
  141. !MUD(10)%Q : PumpsToWell_KillLine
  142. TYPE, PUBLIC :: MUD_TypeVars2D
  143. !! MINORS
  144. !REAL,ALLOCATABLE:: minlosspa_MUDLINE(:,:),minloss_MUDLINE(:,:)
  145. !! MUDLINE
  146. !REAL,ALLOCATABLE:: Re_MUDline(:,:),fric(:,:),fricloss(:,:)
  147. END TYPE MUD_TypeVars2D
  148. TYPE(MUD_TypeVars2D) :: MUDS
  149. ! 1 : MLnumber=1,,PumpsToString
  150. ! 2 : MLnumber=2,,STGaugeToString
  151. ! 3 : MLnumber=3,,WellToPits
  152. END MODULE