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.

MudSystem_Variables.f90 12 KiB

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