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.
 
 
 
 
 
 

184 lines
12 KiB

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