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.
 
 
 
 
 
 

182 lines
12 KiB

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