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.
 
 
 
 
 
 

214 lines
13 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. integer, parameter :: BlownThreshold = 10
  15. ! temporary varibales for solving pressure jerks -- 1399-11-09
  16. integer MudSystemDotPump1BlownCount, MudSystemDotPump2BlownCount, MudSystemDotPump3BlownCount
  17. !integer Pump1BlownInTimeStep, Pump2BlownInTimeStep, Pump3BlownInTimeStep
  18. !logical Pump1BlownStarted, Pump2BlownStarted, Pump3BlownStarted
  19. !integer, parameter :: BlownThresholdInSecond = 5
  20. real(8) MudSystemDottotal_add,MudSystemDottotal_injected
  21. real(8) MudSystemDotDeltaWellCap,MudSystemDotWellCapOld,MudSystemDotAnnCapOld,MudSystemDotDeltaAnnCap
  22. !========================================================================
  23. ! KICK VARIABLES
  24. !========================================================================
  25. REAL(8) MudSystemDotKickDeltaVinAnnulus, MudSystemDotKickVolumeinAnnulus
  26. REAL(8) MudSystemDotKick_Forehead_X,MudSystemDotKick_RemainedVolume_in_LastSection,MudSystemDotBackheadX,MudSystemDotKickDv,MudSystemDotKickDx,MudSystemDotMinKickDv,MudSystemDotOld_KickBackHead_X,MudSystemDotKick_Density
  27. INTEGER MudSystemDotNewInfluxElementCreated,MudSystemDotKick_Forehead_section,MudSystemDotMudSection,MudSystemDotOp_KickLoc,MudSystemDotAnn_KickLoc,MudSystemDotFirstSetKickMigration,MudSystemDotOld_KickBackHead_Section
  28. Integer MudSystemDotiLoc,MudSystemDotChokeLine_KickLoc,MudSystemDotKickNumber,MudSystemDotNewInfluxNumber,MudSystemDotSoundGasThroughChoke
  29. LOGICAL MudSystemDotDrillingMode
  30. !real(8) HZ_ADD
  31. integer MudSystemDotFlow_timeCounter,MudSystemDotMudSys_timeCounter,MudSystemDotFluidFlowCounter
  32. !========================================================================
  33. ! MUD CIRCULATION
  34. !========================================================================
  35. REAL(8), ALLOCATABLE:: MudSystemDotXstart_PipeSection(:),MudSystemDotXend_PipeSection(:),MudSystemDotPipeSection_VolumeCapacity(:),MudSystemDotArea_PipeSectionFt(:),MudSystemDotOD_PipeSectionInch(:),MudSystemDotID_PipeSectionInch(:),MudSystemDotAngle_PipeSection(:)
  36. REAL(8), ALLOCATABLE:: MudSystemDotXstart_OpSection(:),MudSystemDotXend_OpSection(:),MudSystemDotArea_OpSectionFt(:),MudSystemDotOD_OpSectionInch(:),MudSystemDotID_OpSectionInch(:),MudSystemDotOpSection_VolumeCapacity(:),MudSystemDotGeoTypeOp(:),MudSystemDotAngle_OpSection(:)
  37. REAL(8), ALLOCATABLE:: MudSystemDotTDXstart_MudElementArray(:) , MudSystemDotTDXend_MudElementArray(:) , MudSystemDotTDDensity_MudElementArray(:)
  38. INTEGER, ALLOCATABLE:: MudSystemDotGeoType(:)
  39. real(8) MudSystemDotStMudVolumeSum,MudSystemDotSt_MudSaved_Density,MudSystemDotSt_Saved_MudDischarged_Volume,MudSystemDotSt_Saved_MudDischarged_Volume_Final,MudSystemDotMudVolume_InjectedToBH,MudSystemDotMudVolume_Injec2tedFromAnn
  40. real MudSystemDotBitMudDensity
  41. REAL(8) MudSystemDotxx,MudSystemDotNewVolume,MudSystemDotUtubeEmptyVolume,MudSystemDotNe2wDensity, MudSystemDotMudCircVerticalDepth
  42. ! ,TrueMinValue
  43. REAL MudSystemDotDirectionCoef
  44. INTEGER MudSystemDotisection,MudSystemDotOpSection,MudSystemDotimud,MudSystemDotSuctionMud,MudSystemDotNoStringMudElements,MudSystemDotImudCount,MudSystemDotNoCasingMudElements,MudSystemDotNoHorizontalMudElements,MudSystemDotAddedElementsToString
  45. Integer MudSystemDotTDNoHorizontalMudElements, MudSystemDotTDNoStringMudElements, MudSystemDotTDNoCasingMudElements
  46. Integer MudSystemDotistring,MudSystemDoticasing,MudSystemDotiisection,MudSystemDotNoPipeSections,MudSystemDotFirstMudSet
  47. INTEGER MudSystemDotNoBottomHoleMudElements,MudSystemDotNoStringMudElementsForPlot,MudSystemDotF_StringIntervalCounts_Old
  48. INTEGER MudSystemDotFirstSetUtube1,MudSystemDotFirstSetUtube2,MudSystemDotFirstAdded,MudSystemDotNewPipeFilling,MudSystemDotHz_MudOrKick_Utube,MudSystemDotUtubeFilling,MudSystemDottotalLength
  49. REAL(8) MudSystemDotDeltaVolumeOp,MudSystemDotDeltaVTemp,MudSystemDotOldPosition,MudSystemDotStringFlowRate,MudSystemDotStringFlowRateFinal,MudSystemDotAnnulusFlowRateFinal,MudSystemDotTD_RemoveVolume_Remained,MudSystemDotDeltaVolumePipe,MudSystemDotDeltaVolumeAnnulusCapacity
  50. REAL MudSystemDotAnnulusFlowRate,MudSystemDotChokeLineFlowRate
  51. Logical:: MudSystemDotUtubePossibility,MudSystemDotMudIsChanged,MudSystemDotAddedPipe,MudSystemDotUtubeMode1Activated,MudSystemDotUtubeMode2Activated,MudSystemDotWellisNOTFull,MudSystemDotChokeLineNOTFull
  52. Logical:: MudSystemDotShoeLost,MudSystemDotShoeFractured,MudSystemDotKickexpansion_DueToMudLost,MudSystemDotLostInTripOutIsDone
  53. Integer MudSystemDotUGBOSuccessionCounter, MudSystemDotUGBOSuccessionCounterOld
  54. REAL(8) MudSystemDotArea_ChokeLineFt, MudSystemDotChokeLine_VolumeCapacity,MudSystemDotTotalAddedVolume,MudSystemDotLackageMudVolumeAfterFilling, MudSystemDotLackageMudVolume, MudSystemDotNewInflux_Density
  55. real(8) MudSystemDotDensityMixTol,MudSystemDotHz_Density_Utube,MudSystemDotCuttingDensityMixTol,MudSystemDotOp_Kick_Saved_Volume,MudSystemDotOp_MudSaved_Density,MudSystemDotOp_KickSaved_Density,MudSystemDotOp_Saved_MudDischarged_Volume,MudSystemDotOpMudVolumeSum,MudSystemDotOp_NeededVolume_ToFill
  56. real(8) MudSystemDotChoke_Kick_Saved_Volume,MudSystemDotChoke_Saved_MudDischarged_Volume,MudSystemDotChoke_KickSaved_Density,MudSystemDotChoke_MudSaved_Density,MudSystemDotChokeMudVolumeSum
  57. integer MudSystemDotSaved_Op_MudOrKick,MudSystemDotSaved_Ann_MudOrKick,MudSystemDotSaved_Choke_MudOrKick
  58. real(8) MudSystemDotChoke_Saved_MudDischarged_Volume_Final,MudSystemDotChoke_Kick_Saved_Volume_Final
  59. real(8) MudSystemDotQlost,MudSystemDotFormationLostPressure,MudSystemDotShoeMudPressure,MudSystemDotShoeLostCoef, MudSystemDotShoeMudViscosity, MudSystemDotShoeMudDensity ,MudSystemDotOldAnnulusCapacity
  60. logical:: MudSystemDotAnn_to_Choke_2mud
  61. real(8) MudSystemDotAnnMudVolumeSum,MudSystemDotAnn_MudSaved_Density,MudSystemDotAnn_KickSaved_Density,MudSystemDotAnn_Saved_MudDischarged_Volume,MudSystemDotAnn_Kick_Saved_Volume,MudSystemDotAnn_Saved_MudDischarged_Volume_Final, MudSystemDotAnn_Kick_Saved_Volume_Final
  62. type(DynamicDoubleArrayType) :: MudSystemDotHz_MudDischarged_Volume,MudSystemDotHz_Mud_Backhead_X,MudSystemDotHz_Mud_Forehead_X,MudSystemDotHz_Density,MudSystemDotHz_RemainedVolume_in_LastSection,MudSystemDotHz_EmptyVolume_inBackheadLocation, &
  63. MudSystemDotOp_MudDischarged_Volume,MudSystemDotOp_Mud_Backhead_X,MudSystemDotOp_Mud_Forehead_X,MudSystemDotOp_Density,MudSystemDotOp_RemainedVolume_in_LastSection,MudSystemDotOp_EmptyVolume_inBackheadLocation
  64. type(DynamicDoubleArrayType) :: MudSystemDotChokeLine_MudDischarged_Volume,MudSystemDotChokeLine_Mud_Backhead_X,MudSystemDotChokeLine_Mud_Forehead_X,MudSystemDotChokeLine_Density,MudSystemDotChokeLine_RemainedVolume_in_LastSection, &
  65. MudSystemDotChokeLine_EmptyVolume_inBackheadLocation
  66. type(DynamicDoubleArrayType) :: MudSystemDotSt_MudDischarged_Volume,MudSystemDotSt_Mud_Backhead_X,MudSystemDotSt_Mud_Forehead_X,St_Density,MudSystemDotSt_RemainedVolume_in_LastSection, &
  67. MudSystemDotSt_EmptyVolume_inBackheadLocation,MudSystemDotAnn_MudDischarged_Volume,Ann_Mud_Backhead_X,Ann_Mud_Forehead_X, &
  68. Ann_Density,Ann_RemainedVolume_in_LastSection,Ann_EmptyVolume_inBackheadLocation
  69. 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, &
  70. Op_Mud_Backhead_section,Op_Mud_Forehead_section,Hz_MudOrKick,St_MudOrKick,Ann_MudOrKick,Op_MudOrKick,ChokeLine_MudOrKick,MudTypeOp_MudElement,MudType_MudElement
  71. type(DynamicIntegerArrayType) :: ChokeLine_Mud_Backhead_section,ChokeLine_Mud_Forehead_section,Ann_CuttingMud
  72. type(DynamicDoubleArrayType) :: Xend_MudElement,Xstart_MudElement,Density_MudElement,PipeID_MudElement,PipeOD_MudElement,Angle_MudElement, &
  73. Xstart_OpMudElement,Xend_OpMudElement,Density_OpMudElement,PipeID_OpMudElement,PipeOD_OpMudElement!,Angle_OpMudElement
  74. type(DynamicDoubleArrayType) :: TVDstart_MudElement, TVDend_MudElement, TVDstart_OpMudElement, TVDend_OpMudElement
  75. type(CFluid), allocatable :: StringMudElement(:), CasingMudElement(:)
  76. real(8) PressureGauge75,PressureGauge76
  77. !========================================================================
  78. ! MALFUNCTION VARIABLES
  79. !========================================================================
  80. INTEGER StandPipeGauge1Malf, StandPipeGauge2Malf, StandPipePressure_DataDisplayMalf,StandPipePressureChokeMalf,DrillPipePressureMalf
  81. integer TripTankPressure_DataDisplayMalf,PitGainLossGaugeMalf,ReturnMudFlowGaugeMalf,MudTanksVolumeGaugeMalf
  82. !========================================================================
  83. ! TRIP TANK VARIABLES
  84. !========================================================================
  85. logical condition32Final,condition33Final,condition34Final
  86. REAL(8) TripTank_Vol,TripTank_Dens,ReturnToTrip_Q,ActiveToTrip_Q,TripTankPump_Q,ReturnToTrip_Dens,ActiveToTrip_Dens,ReturnToTrip_deltaV,ActiveToTrip_deltaV
  87. REAL(8) MassFlowRate_ReturnToTrip,MassFlowRate_ActiveToTrip,TripTankPump_deltaV,MassFlowRate_TripTankPump,NetMassFlux_tripTank
  88. REAL(8) TripTank_MinVol_Allowded,TripTank_MaxVol_Allowded
  89. !!======================================================================
  90. !! MUD VOLUME TOTALIZER
  91. !!======================================================================
  92. REAL(8) RefrencePitVolume_DrillWatch ! for DrillWatch
  93. REAL(8) MudTank1_vol,MudTank2_vol,MudTank3_vol,MudTank4_vol
  94. REAL(8) MVT_MinVol_Allowded,MVT_MaxVol_Allowded,MudTanksVolume
  95. REAL(8) PitGainLossZero,MVTCoarse,MVTFine,RefrencePitVolume,PitGainLossZero_Old,MVTCoarseKnob_Old,MVTFineKnob_Old
  96. REAL(8) ActiveTankDensity,TripTankDensityCalc,SuctionDensity_Old,AnnulusSuctionDensity_Old,StringDensity_Old,ChokeLineDensity_Old,ChokeManifoldDumpVolume
  97. LOGICAL FirstSet_Time
  98. !!======================================================================
  99. !! MUD FLOW-FILL INDICATOR
  100. !!======================================================================
  101. REAL(8) TotalStrokes1MFFI,TotalStrokes2MFFI,TotalStrokesPump1,TotalStrokesPump2,GraphTotalStrokes
  102. REAL(8) PedalMeter,ReturnFlowRate,ReturnFlowPercent,MFFI_MinPercent_Allowded,MFFI_MaxPercent_Allowded
  103. REAL(8) TotalFillStrokes1MFFI,TotalFillStrokes2MFFI,TotalFilledStrokesBy1MFFI,TotalFilledStrokesBy2MFFI,TotalFilledStrokesBy1and2MFFI
  104. !=================================================================================
  105. !============================================================================
  106. ! MUD & ENVIRONMENT VARIABLES
  107. !============================================================================
  108. REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000!,NU=9e-6
  109. !specific gravity of liquid
  110. !water density(kg/m^3)
  111. PARAMETER PII=3.14159265
  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. TYPE, PUBLIC :: MUD_TypeVars
  128. REAL Q,nu,Mud_Density,Mud_SG
  129. REAL minlosspa_MUDLINE,minloss_MUDLINE ! MINORS
  130. REAL Re_MUDline,fric,fricloss,static_loss,total_loss ! MUDLINE
  131. END TYPE MUD_TypeVars
  132. TYPE(MUD_TypeVars), DIMENSION(1:10) :: MUD
  133. !MUD(1)%Q : -------------
  134. !MUD(2)%Q : PumpsToString
  135. !MUD(3)%Q : BellNippleToPits-FullWell
  136. !MUD(4)%Q : WellToChokeManifold
  137. !MUD(5)%Q : ActiveTankToTripTank
  138. !MUD(6)%Q : TripTankToActiveTank
  139. !MUD(7)%Q : WellToBellNipple
  140. !MUD(8)%Q : BellNippleToWell-NonFullWell
  141. !MUD(9)%Q : StandPipeManifoldToChokeManifold-Through ChokeLine
  142. !MUD(10)%Q : PumpsToWell_KillLine
  143. TYPE, PUBLIC :: MUD_TypeVars2D
  144. !! MINORS
  145. !REAL,ALLOCATABLE:: minlosspa_MUDLINE(:,:),minloss_MUDLINE(:,:)
  146. !! MUDLINE
  147. !REAL,ALLOCATABLE:: Re_MUDline(:,:),fric(:,:),fricloss(:,:)
  148. END TYPE MUD_TypeVars2D
  149. TYPE(MUD_TypeVars2D) :: MUDS
  150. END MODULE