MODULE MudSystemVARIABLES use DynamicDoubleArray use DynamicIntegerArray use CDownHoleVariables use CBopControlPanelVariables use CEquipmentsConstants ! ! use CSimulationVariables use CAccumulatorVariables use CBopStackVariables use CChokeControlPanelVariables use CStandPipeManifoldVariables USE CReservoirVariables IMPLICIT NONE integer, parameter :: BlownThreshold = 10 ! temporary varibales for solving pressure jerks -- 1399-11-09 integer MudSystemDotPump1BlownCount, MudSystemDotPump2BlownCount, MudSystemDotPump3BlownCount !integer Pump1BlownInTimeStep, Pump2BlownInTimeStep, Pump3BlownInTimeStep !logical Pump1BlownStarted, Pump2BlownStarted, Pump3BlownStarted !integer, parameter :: BlownThresholdInSecond = 5 real(8) MudSystemDottotal_add,MudSystemDottotal_injected real(8) MudSystemDotDeltaWellCap,MudSystemDotWellCapOld,MudSystemDotAnnCapOld,MudSystemDotDeltaAnnCap !======================================================================== ! KICK VARIABLES !======================================================================== REAL(8) MudSystemDotKickDeltaVinAnnulus, MudSystemDotKickVolumeinAnnulus REAL(8) MudSystemDotKick_Forehead_X,MudSystemDotKick_RemainedVolume_in_LastSection,MudSystemDotBackheadX,MudSystemDotKickDv,MudSystemDotKickDx,MudSystemDotMinKickDv,MudSystemDotOld_KickBackHead_X,MudSystemDotKick_Density INTEGER MudSystemDotNewInfluxElementCreated,MudSystemDotKick_Forehead_section,MudSystemDotMudSection,MudSystemDotOp_KickLoc,MudSystemDotAnn_KickLoc,MudSystemDotFirstSetKickMigration,MudSystemDotOld_KickBackHead_Section Integer MudSystemDotiLoc,MudSystemDotChokeLine_KickLoc,MudSystemDotKickNumber,MudSystemDotNewInfluxNumber,MudSystemDotSoundGasThroughChoke LOGICAL MudSystemDotDrillingMode !real(8) HZ_ADD integer MudSystemDotFlow_timeCounter,MudSystemDotMudSys_timeCounter,MudSystemDotFluidFlowCounter !======================================================================== ! MUD CIRCULATION !======================================================================== REAL(8), ALLOCATABLE:: MudSystemDotXstart_PipeSection(:),MudSystemDotXend_PipeSection(:),MudSystemDotPipeSection_VolumeCapacity(:),MudSystemDotArea_PipeSectionFt(:),MudSystemDotOD_PipeSectionInch(:),MudSystemDotID_PipeSectionInch(:),MudSystemDotAngle_PipeSection(:) REAL(8), ALLOCATABLE:: MudSystemDotXstart_OpSection(:),MudSystemDotXend_OpSection(:),MudSystemDotArea_OpSectionFt(:),MudSystemDotOD_OpSectionInch(:),MudSystemDotID_OpSectionInch(:),MudSystemDotOpSection_VolumeCapacity(:),MudSystemDotGeoTypeOp(:),MudSystemDotAngle_OpSection(:) REAL(8), ALLOCATABLE:: MudSystemDotTDXstart_MudElementArray(:) , MudSystemDotTDXend_MudElementArray(:) , MudSystemDotTDDensity_MudElementArray(:) INTEGER, ALLOCATABLE:: MudSystemDotGeoType(:) real(8) MudSystemDotStMudVolumeSum,MudSystemDotSt_MudSaved_Density,MudSystemDotSt_Saved_MudDischarged_Volume,MudSystemDotSt_Saved_MudDischarged_Volume_Final,MudSystemDotMudVolume_InjectedToBH,MudSystemDotMudVolume_Injec2tedFromAnn real MudSystemDotBitMudDensity REAL(8) MudSystemDotxx,MudSystemDotNewVolume,MudSystemDotUtubeEmptyVolume,MudSystemDotNe2wDensity, MudSystemDotMudCircVerticalDepth ! ,TrueMinValue REAL MudSystemDotDirectionCoef INTEGER MudSystemDotisection,MudSystemDotOpSection,MudSystemDotimud,MudSystemDotSuctionMud,MudSystemDotNoStringMudElements,MudSystemDotImudCount,MudSystemDotNoCasingMudElements,MudSystemDotNoHorizontalMudElements,MudSystemDotAddedElementsToString Integer MudSystemDotTDNoHorizontalMudElements, MudSystemDotTDNoStringMudElements, MudSystemDotTDNoCasingMudElements Integer MudSystemDotistring,MudSystemDoticasing,MudSystemDotiisection,MudSystemDotNoPipeSections,MudSystemDotFirstMudSet INTEGER MudSystemDotNoBottomHoleMudElements,MudSystemDotNoStringMudElementsForPlot,MudSystemDotF_StringIntervalCounts_Old INTEGER MudSystemDotFirstSetUtube1,MudSystemDotFirstSetUtube2,MudSystemDotFirstAdded,MudSystemDotNewPipeFilling,MudSystemDotHz_MudOrKick_Utube,MudSystemDotUtubeFilling,MudSystemDottotalLength REAL(8) MudSystemDotDeltaVolumeOp,MudSystemDotDeltaVTemp,MudSystemDotOldPosition,MudSystemDotStringFlowRate,MudSystemDotStringFlowRateFinal,MudSystemDotAnnulusFlowRateFinal,MudSystemDotTD_RemoveVolume_Remained,MudSystemDotDeltaVolumePipe,MudSystemDotDeltaVolumeAnnulusCapacity REAL MudSystemDotAnnulusFlowRate,MudSystemDotChokeLineFlowRate Logical:: MudSystemDotUtubePossibility,MudSystemDotMudIsChanged,MudSystemDotAddedPipe,MudSystemDotUtubeMode1Activated,MudSystemDotUtubeMode2Activated,MudSystemDotWellisNOTFull,MudSystemDotChokeLineNOTFull Logical:: MudSystemDotShoeLost,MudSystemDotShoeFractured,MudSystemDotKickexpansion_DueToMudLost,MudSystemDotLostInTripOutIsDone Integer MudSystemDotUGBOSuccessionCounter, MudSystemDotUGBOSuccessionCounterOld REAL(8) MudSystemDotArea_ChokeLineFt, MudSystemDotChokeLine_VolumeCapacity,MudSystemDotTotalAddedVolume,MudSystemDotLackageMudVolumeAfterFilling, MudSystemDotLackageMudVolume, MudSystemDotNewInflux_Density 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 real(8) MudSystemDotChoke_Kick_Saved_Volume,MudSystemDotChoke_Saved_MudDischarged_Volume,MudSystemDotChoke_KickSaved_Density,MudSystemDotChoke_MudSaved_Density,MudSystemDotChokeMudVolumeSum integer MudSystemDotSaved_Op_MudOrKick,MudSystemDotSaved_Ann_MudOrKick,MudSystemDotSaved_Choke_MudOrKick real(8) MudSystemDotChoke_Saved_MudDischarged_Volume_Final,MudSystemDotChoke_Kick_Saved_Volume_Final real(8) MudSystemDotQlost,MudSystemDotFormationLostPressure,MudSystemDotShoeMudPressure,MudSystemDotShoeLostCoef, MudSystemDotShoeMudViscosity, MudSystemDotShoeMudDensity ,MudSystemDotOldAnnulusCapacity logical:: MudSystemDotAnn_to_Choke_2mud 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 type(DynamicDoubleArrayType) :: MudSystemDotHz_MudDischarged_Volume,MudSystemDotHz_Mud_Backhead_X,MudSystemDotHz_Mud_Forehead_X,MudSystemDotHz_Density,MudSystemDotHz_RemainedVolume_in_LastSection,MudSystemDotHz_EmptyVolume_inBackheadLocation, & MudSystemDotOp_MudDischarged_Volume,MudSystemDotOp_Mud_Backhead_X,MudSystemDotOp_Mud_Forehead_X,MudSystemDotOp_Density,MudSystemDotOp_RemainedVolume_in_LastSection,MudSystemDotOp_EmptyVolume_inBackheadLocation type(DynamicDoubleArrayType) :: MudSystemDotChokeLine_MudDischarged_Volume,MudSystemDotChokeLine_Mud_Backhead_X,MudSystemDotChokeLine_Mud_Forehead_X,MudSystemDotChokeLine_Density,MudSystemDotChokeLine_RemainedVolume_in_LastSection, & MudSystemDotChokeLine_EmptyVolume_inBackheadLocation type(DynamicDoubleArrayType) :: MudSystemDotSt_MudDischarged_Volume,MudSystemDotSt_Mud_Backhead_X,MudSystemDotSt_Mud_Forehead_X,St_Density,MudSystemDotSt_RemainedVolume_in_LastSection, & MudSystemDotSt_EmptyVolume_inBackheadLocation,MudSystemDotAnn_MudDischarged_Volume,Ann_Mud_Backhead_X,Ann_Mud_Forehead_X, & Ann_Density,Ann_RemainedVolume_in_LastSection,Ann_EmptyVolume_inBackheadLocation 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, & Op_Mud_Backhead_section,Op_Mud_Forehead_section,Hz_MudOrKick,St_MudOrKick,Ann_MudOrKick,Op_MudOrKick,ChokeLine_MudOrKick,MudTypeOp_MudElement,MudType_MudElement type(DynamicIntegerArrayType) :: ChokeLine_Mud_Backhead_section,ChokeLine_Mud_Forehead_section,Ann_CuttingMud type(DynamicDoubleArrayType) :: Xend_MudElement,Xstart_MudElement,Density_MudElement,PipeID_MudElement,PipeOD_MudElement,Angle_MudElement, & Xstart_OpMudElement,Xend_OpMudElement,Density_OpMudElement,PipeID_OpMudElement,PipeOD_OpMudElement!,Angle_OpMudElement type(DynamicDoubleArrayType) :: TVDstart_MudElement, TVDend_MudElement, TVDstart_OpMudElement, TVDend_OpMudElement type(CFluid), allocatable :: StringMudElement(:), CasingMudElement(:) real(8) PressureGauge75,PressureGauge76 !======================================================================== ! MALFUNCTION VARIABLES !======================================================================== INTEGER StandPipeGauge1Malf, StandPipeGauge2Malf, StandPipePressure_DataDisplayMalf,StandPipePressureChokeMalf,DrillPipePressureMalf integer TripTankPressure_DataDisplayMalf,PitGainLossGaugeMalf,ReturnMudFlowGaugeMalf,MudTanksVolumeGaugeMalf !======================================================================== ! TRIP TANK VARIABLES !======================================================================== logical condition32Final,condition33Final,condition34Final REAL(8) TripTank_Vol,TripTank_Dens,ReturnToTrip_Q,ActiveToTrip_Q,TripTankPump_Q,ReturnToTrip_Dens,ActiveToTrip_Dens,ReturnToTrip_deltaV,ActiveToTrip_deltaV REAL(8) MassFlowRate_ReturnToTrip,MassFlowRate_ActiveToTrip,TripTankPump_deltaV,MassFlowRate_TripTankPump,NetMassFlux_tripTank REAL(8) TripTank_MinVol_Allowded,TripTank_MaxVol_Allowded !!====================================================================== !! MUD VOLUME TOTALIZER !!====================================================================== REAL(8) RefrencePitVolume_DrillWatch ! for DrillWatch REAL(8) MudTank1_vol,MudTank2_vol,MudTank3_vol,MudTank4_vol REAL(8) MVT_MinVol_Allowded,MVT_MaxVol_Allowded,MudTanksVolume REAL(8) PitGainLossZero,MVTCoarse,MVTFine,RefrencePitVolume,PitGainLossZero_Old,MVTCoarseKnob_Old,MVTFineKnob_Old REAL(8) ActiveTankDensity,TripTankDensityCalc,SuctionDensity_Old,AnnulusSuctionDensity_Old,StringDensity_Old,ChokeLineDensity_Old,ChokeManifoldDumpVolume LOGICAL FirstSet_Time !!====================================================================== !! MUD FLOW-FILL INDICATOR !!====================================================================== REAL(8) TotalStrokes1MFFI,TotalStrokes2MFFI,TotalStrokesPump1,TotalStrokesPump2,GraphTotalStrokes REAL(8) PedalMeter,ReturnFlowRate,ReturnFlowPercent,MFFI_MinPercent_Allowded,MFFI_MaxPercent_Allowded REAL(8) TotalFillStrokes1MFFI,TotalFillStrokes2MFFI,TotalFilledStrokesBy1MFFI,TotalFilledStrokesBy2MFFI,TotalFilledStrokesBy1and2MFFI !================================================================================= !============================================================================ ! MUD & ENVIRONMENT VARIABLES !============================================================================ REAL:: SG=1.12,WDENS=1000,GRAVITY=9.81,RE_CR=2000!,NU=9e-6 !specific gravity of liquid !water density(kg/m^3) PARAMETER PII=3.14159265 INTEGER NO_MudMinors,NO_PIPINGSMUDLINE REAL(8) Pumps_Height,String_Height,STpipeGauge_Height,Pits_Height,ChokeManifold_Height,WellChokeExit_Height REAL(8) STGauge_Pressure,String_Input_Pressure,Well_Output_Pressure,Pressure_BeforeChokes,Pressure_AfterChokes REAL(8) OpenArea32,OpenArea33,OpenArea34,OpenArea35,deltaPchoke,WellOutletDensity,ChokeOutletDensity REAL Q_flow32,Q_flow33,Q_flow34,Q_flow35 REAL(8) DeltaT_Mudline,ActiveTankVolume,ReserveTankVolume,CementTankVolumeCalc,ActiveTankSettled,ActiveTankFloorArea,TripTankFloorArea REAL(8) TripTankVolumeCalc,BellNippleDensity,BellNippleVolume,MudBucketDensity,MudBucketVolume,BellNippleDumpVolume REAL(8) ReserveTankDensity,CementTankDensityCalc,Mp1Density,Mp2Density,Mp3Density,PumpsDumpVolume real PumpsDumpFlowRate REAL(8) Density_Ch real(8) Suction_Density_MudSystem,Suction_Density_PumpsToWell,CompressedMudDensity Logical WellToPitsOpen,WellToChokeManifoldOpen,MudChecked,WellHeadIsOpen logical Pump1OffFailure,Pump2OffFailure,Pump3OffFailure,ChokeLineGaugeToTanks,WellToChokeLineGauge REAL,ALLOCATABLE:: MudMinors(:,:),AREA_MUDLINE(:),MINORDIAMETER_MUDLINE(:),NOTE_MUDLINE(:),AREAMINOR_MUDLINE(:),LF_MUDLINE(:),CV_MUDLINE(:) REAL,ALLOCATABLE:: DIAM_MUDLINE_INCH(:),LENGT_MUDLINE(:),ROUGHNESS_MUDLINE(:),RELROUGH_MUDLINE(:),PIPINGS_MUDLINE(:,:) TYPE, PUBLIC :: MUD_TypeVars REAL Q,nu,Mud_Density,Mud_SG REAL minlosspa_MUDLINE,minloss_MUDLINE ! MINORS REAL Re_MUDline,fric,fricloss,static_loss,total_loss ! MUDLINE END TYPE MUD_TypeVars TYPE(MUD_TypeVars), DIMENSION(1:10) :: MUD !MUD(1)%Q : ------------- !MUD(2)%Q : PumpsToString !MUD(3)%Q : BellNippleToPits-FullWell !MUD(4)%Q : WellToChokeManifold !MUD(5)%Q : ActiveTankToTripTank !MUD(6)%Q : TripTankToActiveTank !MUD(7)%Q : WellToBellNipple !MUD(8)%Q : BellNippleToWell-NonFullWell !MUD(9)%Q : StandPipeManifoldToChokeManifold-Through ChokeLine !MUD(10)%Q : PumpsToWell_KillLine TYPE, PUBLIC :: MUD_TypeVars2D !! MINORS !REAL,ALLOCATABLE:: minlosspa_MUDLINE(:,:),minloss_MUDLINE(:,:) !! MUDLINE !REAL,ALLOCATABLE:: Re_MUDline(:,:),fric(:,:),fricloss(:,:) END TYPE MUD_TypeVars2D TYPE(MUD_TypeVars2D) :: MUDS END MODULE