Class LagrangianSlugTracker
- All Implemented Interfaces:
Serializable
Implements full Lagrangian tracking of individual slugs through the pipeline, modeling:
- Hydrodynamic slug initiation from flow instabilities
- Terrain-induced slug initiation at low points
- Slug growth by liquid pickup from stratified film
- Slug decay by shedding to trailing Taylor bubble
- Slug-bubble unit dynamics (front/tail velocities)
- Slug merging when front catches preceding tail
- Wake effects between consecutive slugs
- Statistical output (length distribution, frequency, volumes)
OLGA Compatibility: This model follows the OLGA slug tracking methodology:
- Slugs are tracked as discrete entities with position, length, velocity
- Film region between slugs is modeled as stratified flow
- Mass exchange between slug body and film is computed from pickup/shedding
- Slug frequency from mechanistic or empirical correlations
References:
- Bendiksen, K.H. et al. (1991) - The Dynamic Two-Fluid Model OLGA
- Nydal, O.J. and Banerjee, S. (1996) - Dynamic Slug Tracking Simulations
- Kjølaas, J. et al. (2013) - Lagrangian slug flow modeling and sensitivity
- Issa, R.I. and Kempf, M.H.W. (2003) - Simulation of slug flow in horizontal and nearly horizontal pipes
- Version:
- 2.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a single slug-bubble unit in Lagrangian tracking.static enumSource of slug generation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleAverage slug length (m).private doubleBase holdup in slug body.private booleanEnable hydrodynamic slug generation at inlet.private booleanEnable random/stochastic slug initiation.private booleanEnable terrain-induced slug generation.private booleanEnable wake interaction between slugs.private static final doubleprivate doubleInitial slug length at generation (diameters).private doubleMinimum liquid holdup for slug initiation.private doubleSlug frequency at inlet (1/s).private doubleTime of last slug arrival at outlet (s).private doubleMaximum slug length observed (m).private doubleMaximum slug length (diameters).private doubleMaximum slug volume at outlet (m³).private doubleMaximum wake acceleration factor.private doubleDistance threshold for slug merging (m).private doubleMinimum holdup in film region.private doubleMinimum stable slug length (diameters).List of inter-arrival times at outlet (s).private doubleSlug frequency at outlet (1/s).List of slug lengths at outlet for distribution.List of slug volumes at outlet.private RandomRandom number generator for stochastic initiation.private doubleReference mixture velocity (m/s).private static final longprivate doubleSimulation time for statistics (s).private intCounter for slug IDs.private List<LagrangianSlugTracker.SlugBubbleUnit> List of active slugs in the pipeline.private doubleTime since last inlet slug generation (s).private doubleTotal mass borrowed from Eulerian field (kg).private doubleTotal mass returned to Eulerian field (kg).private intTotal slugs dissipated.private intTotal slugs exited at outlet.private intTotal slugs generated.private intTotal slugs merged.private doubleWake length behind slug (diameters). -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.LagrangianSlugTracker(long seed) Constructor with random seed for reproducibility. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadvanceSlug(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection[] sections, double dt) Advance a single slug by one time step.voidadvanceTimeStep(PipeSection[] sections, double dt) Advance all slugs by one time step.private doublecalculateDriftVelocity(double D, double theta, double deltaRho, double rhoL) Calculate drift velocity using Bendiksen (1984) correlation.private doublecalculateEquilibriumLength(PipeSection section) Calculate equilibrium slug length using Barnea-Taitel model.private doublecalculateFilmHoldup(PipeSection section) Calculate film holdup from section properties.private voidcalculateMassExchange(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection section, double dt) Calculate mass exchange at slug front and tail.private doublecalculatePipeLength(PipeSection[] sections) Calculate total pipe length.private doublecalculateSlugBodyHoldup(double U_M) Calculate slug body holdup using Gregory et al. (1978).private voidCalculate slug front and tail velocities using Bendiksen correlation.private voidcheckInletSlugGeneration(PipeSection[] sections, double dt) Check for inlet slug generation based on frequency correlation.private voidcheckSlugInitiation(PipeSection[] sections, double dt) Check conditions for slug initiation.private voidcheckStochasticInitiation(PipeSection[] sections, double dt) Check for stochastic slug initiation from instabilities.private voidclearSlugFlags(PipeSection[] sections) Clear slug flags on all sections.private intfindSectionIndex(double position, PipeSection[] sections) Find section index containing a position.generateInletSlug(PipeSection inlet) Generate a new slug at the inlet.generateInstabilitySlug(PipeSection section, int sectionIndex, PipeSection[] sections) Generate slug from flow instability.doubleGet average slug length.doubleGet inlet slug frequency.doubleGet mass conservation error.doubleGet maximum observed slug length.doubleGet maximum slug volume at outlet.Get inter-arrival times at outlet.doubleGet outlet slug frequency.Get outlet slug lengths for distribution analysis.Get outlet slug volumes.intGet number of active slugs.doubleGet slug frequency (deprecated, use getInletSlugFrequency).getSlugs()Get all active slugs.Get detailed statistics string.doubleGet total mass borrowed from Eulerian cells.doubleGet total mass returned to Eulerian cells.intGet total slugs dissipated.intGet total slugs exited at outlet.intGet total slugs generated.intGet total slugs merged.private voidhandleSlugMerging(PipeSection[] sections) Handle merging of slugs that have caught up to each other.initializeTerrainSlug(LiquidAccumulationTracker.SlugCharacteristics characteristics, PipeSection[] sections) Initialize slug from terrain-induced accumulation.private voidmarkSlugSections(PipeSection[] sections) Mark sections that are within slug bodies or bubbles.private voidmergeSlugPair(LagrangianSlugTracker.SlugBubbleUnit survivor, LagrangianSlugTracker.SlugBubbleUnit absorbed, PipeSection[] sections) Merge two slugs into one.private voidRecord slug statistics as it exits at outlet.private voidremoveInactiveSlugs(PipeSection[] sections) Remove slugs that have exited the pipe or dissipated.voidreset()Reset tracker state.private voidreturnMassToEulerian(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection[] sections) Return mass from dissipating slug to Eulerian cells.voidsetEnableInletSlugGeneration(boolean enable) Enable or disable inlet slug generation.voidsetEnableStochasticInitiation(boolean enable) Enable or disable stochastic slug initiation.voidsetEnableTerrainSlugGeneration(boolean enable) Enable or disable terrain slug generation.voidsetEnableWakeEffects(boolean enable) Enable or disable wake effects.voidsetInitialSlugLengthDiameters(double diameters) Set initial slug length in diameters.voidsetInitiationHoldupThreshold(double threshold) Set initiation holdup threshold.voidsetMaxSlugLengthDiameters(double diameters) Set maximum slug length in diameters.voidsetMaxWakeAcceleration(double factor) Set maximum wake acceleration factor.voidsetMinSlugLengthDiameters(double diameters) Set minimum slug length in diameters.voidsetReferenceVelocity(double velocity) Set reference mixture velocity.voidsetWakeLengthDiameters(double diameters) Set wake length in diameters.private voidSort slugs by front position (downstream to upstream).toJson()Get JSON representation of current state.private voidupdateBubbleLength(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection section) Update Taylor bubble length.private voidUpdate slug statistics.private voidupdateWakeEffects(PipeSection[] sections) Update wake effects between consecutive slugs.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
GRAVITY
private static final double GRAVITY- See Also:
-
slugs
List of active slugs in the pipeline. -
slugIdCounter
private int slugIdCounterCounter for slug IDs. -
random
Random number generator for stochastic initiation. -
enableInletSlugGeneration
private boolean enableInletSlugGenerationEnable hydrodynamic slug generation at inlet. -
enableTerrainSlugGeneration
private boolean enableTerrainSlugGenerationEnable terrain-induced slug generation. -
enableStochasticInitiation
private boolean enableStochasticInitiationEnable random/stochastic slug initiation. -
initiationHoldupThreshold
private double initiationHoldupThresholdMinimum liquid holdup for slug initiation. -
timeSinceLastInletSlug
private double timeSinceLastInletSlugTime since last inlet slug generation (s). -
minSlugLengthDiameters
private double minSlugLengthDiametersMinimum stable slug length (diameters). -
maxSlugLengthDiameters
private double maxSlugLengthDiametersMaximum slug length (diameters). -
initialSlugLengthDiameters
private double initialSlugLengthDiametersInitial slug length at generation (diameters). -
baseSlugHoldup
private double baseSlugHoldupBase holdup in slug body. -
minFilmHoldup
private double minFilmHoldupMinimum holdup in film region. -
mergeDistanceThreshold
private double mergeDistanceThresholdDistance threshold for slug merging (m). -
enableWakeEffects
private boolean enableWakeEffectsEnable wake interaction between slugs. -
wakeLengthDiameters
private double wakeLengthDiametersWake length behind slug (diameters). -
maxWakeAcceleration
private double maxWakeAccelerationMaximum wake acceleration factor. -
totalSlugsGenerated
private int totalSlugsGeneratedTotal slugs generated. -
totalSlugsMerged
private int totalSlugsMergedTotal slugs merged. -
totalSlugsDissipated
private int totalSlugsDissipatedTotal slugs dissipated. -
totalSlugsExited
private int totalSlugsExitedTotal slugs exited at outlet. -
inletSlugFrequency
private double inletSlugFrequencySlug frequency at inlet (1/s). -
outletSlugFrequency
private double outletSlugFrequencySlug frequency at outlet (1/s). -
averageSlugLength
private double averageSlugLengthAverage slug length (m). -
maxObservedSlugLength
private double maxObservedSlugLengthMaximum slug length observed (m). -
maxSlugVolumeAtOutlet
private double maxSlugVolumeAtOutletMaximum slug volume at outlet (m³). -
simulationTime
private double simulationTimeSimulation time for statistics (s). -
outletSlugLengths
-
outletSlugVolumes
-
outletInterArrivalTimes
-
lastOutletArrivalTime
private double lastOutletArrivalTimeTime of last slug arrival at outlet (s). -
totalMassBorrowed
private double totalMassBorrowedTotal mass borrowed from Eulerian field (kg). -
totalMassReturned
private double totalMassReturnedTotal mass returned to Eulerian field (kg). -
referenceMixtureVelocity
private double referenceMixtureVelocityReference mixture velocity (m/s).
-
-
Constructor Details
-
LagrangianSlugTracker
public LagrangianSlugTracker()Default constructor. -
LagrangianSlugTracker
public LagrangianSlugTracker(long seed) Constructor with random seed for reproducibility.- Parameters:
seed- random seed
-
-
Method Details
-
advanceTimeStep
Advance all slugs by one time step.This is the main entry point for the Lagrangian tracking algorithm. Called each time step to:
- Check for new slug initiation (inlet, terrain, instability)
- Update velocity of each slug (Bendiksen correlation)
- Calculate mass exchange (pickup/shedding)
- Advance positions
- Update slug lengths
- Handle slug merging
- Remove exited/dissipated slugs
- Update Eulerian section properties
- Update statistics
- Parameters:
sections- pipe sections arraydt- time step (s)
-
checkSlugInitiation
Check conditions for slug initiation.- Parameters:
sections- pipe sectionsdt- time step (s)
-
checkInletSlugGeneration
Check for inlet slug generation based on frequency correlation.Uses the Zabaras (2000) frequency correlation modified for inclination. Slugs are generated probabilistically based on expected frequency.
- Parameters:
sections- pipe sectionsdt- time step (s)
-
generateInletSlug
Generate a new slug at the inlet.- Parameters:
inlet- inlet pipe section- Returns:
- new slug unit
-
initializeTerrainSlug
public LagrangianSlugTracker.SlugBubbleUnit initializeTerrainSlug(LiquidAccumulationTracker.SlugCharacteristics characteristics, PipeSection[] sections) Initialize slug from terrain-induced accumulation.Called externally when liquid accumulation tracker detects slug-out conditions at a terrain low point.
- Parameters:
characteristics- slug characteristics from accumulation trackersections- pipe sections- Returns:
- new slug unit
-
checkStochasticInitiation
Check for stochastic slug initiation from instabilities.- Parameters:
sections- pipe sectionsdt- time step (s)
-
generateInstabilitySlug
private LagrangianSlugTracker.SlugBubbleUnit generateInstabilitySlug(PipeSection section, int sectionIndex, PipeSection[] sections) Generate slug from flow instability.- Parameters:
section- section where instability occurssectionIndex- index of the sectionsections- all pipe sections- Returns:
- new slug unit
-
advanceSlug
private void advanceSlug(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection[] sections, double dt) Advance a single slug by one time step.- Parameters:
slug- the slug to advancesections- pipe sectionsdt- time step (s)
-
calculateSlugVelocities
private void calculateSlugVelocities(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection section) Calculate slug front and tail velocities using Bendiksen correlation.The slug front moves at the Taylor bubble velocity: V_front = C0 * U_m + U_drift
The tail velocity is determined by mass balance: V_tail = V_front - (pickup - shedding) / (A * (H_slug - H_film))
- Parameters:
slug- the slug unitsection- pipe section at slug location
-
calculateDriftVelocity
private double calculateDriftVelocity(double D, double theta, double deltaRho, double rhoL) Calculate drift velocity using Bendiksen (1984) correlation.- Parameters:
D- pipe diameter (m)theta- pipe inclination (radians)deltaRho- density difference (kg/m³)rhoL- liquid density (kg/m³)- Returns:
- drift velocity (m/s)
-
calculateMassExchange
private void calculateMassExchange(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection section, double dt) Calculate mass exchange at slug front and tail.Pickup rate at front: liquid is scooped from stratified film Shedding rate at tail: liquid is shed into film behind slug
- Parameters:
slug- the slug unitsection- pipe sectiondt- time step (s)
-
updateBubbleLength
Update Taylor bubble length.- Parameters:
slug- the slug unitsection- pipe section
-
calculateSlugBodyHoldup
private double calculateSlugBodyHoldup(double U_M) Calculate slug body holdup using Gregory et al. (1978).- Parameters:
U_M- mixture velocity (m/s)- Returns:
- slug body holdup (0.5-1.0)
-
calculateFilmHoldup
Calculate film holdup from section properties.- Parameters:
section- pipe section- Returns:
- film holdup
-
calculateEquilibriumLength
Calculate equilibrium slug length using Barnea-Taitel model.- Parameters:
section- pipe section- Returns:
- equilibrium slug length (m)
-
updateWakeEffects
Update wake effects between consecutive slugs.OLGA wake model: A slug following closely behind another experiences accelerated motion due to reduced liquid hold-up in the wake region.
- Parameters:
sections- pipe sections
-
handleSlugMerging
Handle merging of slugs that have caught up to each other.- Parameters:
sections- pipe sections
-
mergeSlugPair
private void mergeSlugPair(LagrangianSlugTracker.SlugBubbleUnit survivor, LagrangianSlugTracker.SlugBubbleUnit absorbed, PipeSection[] sections) Merge two slugs into one.- Parameters:
survivor- the surviving slug (following)absorbed- the absorbed slug (preceding)sections- pipe sections
-
removeInactiveSlugs
Remove slugs that have exited the pipe or dissipated.- Parameters:
sections- pipe sections
-
recordSlugAtOutlet
Record slug statistics as it exits at outlet.- Parameters:
slug- the exiting slug
-
returnMassToEulerian
private void returnMassToEulerian(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection[] sections) Return mass from dissipating slug to Eulerian cells.- Parameters:
slug- the dissipating slugsections- pipe sections
-
clearSlugFlags
Clear slug flags on all sections.- Parameters:
sections- pipe sections
-
markSlugSections
Mark sections that are within slug bodies or bubbles.- Parameters:
sections- pipe sections
-
sortSlugsByPosition
private void sortSlugsByPosition()Sort slugs by front position (downstream to upstream). -
findSectionIndex
Find section index containing a position.- Parameters:
position- position along pipe (m)sections- pipe sections- Returns:
- section index, or -1 if not found
-
calculatePipeLength
Calculate total pipe length.- Parameters:
sections- pipe sections- Returns:
- pipe length (m)
-
updateStatistics
private void updateStatistics()Update slug statistics. -
getSlugs
Get all active slugs.- Returns:
- list of slug units (copy)
-
getSlugCount
public int getSlugCount()Get number of active slugs.- Returns:
- slug count
-
getTotalSlugsGenerated
public int getTotalSlugsGenerated()Get total slugs generated.- Returns:
- count
-
getTotalSlugsMerged
public int getTotalSlugsMerged()Get total slugs merged.- Returns:
- count
-
getTotalSlugsDissipated
public int getTotalSlugsDissipated()Get total slugs dissipated.- Returns:
- count
-
getTotalSlugsExited
public int getTotalSlugsExited()Get total slugs exited at outlet.- Returns:
- count
-
getInletSlugFrequency
public double getInletSlugFrequency()Get inlet slug frequency.- Returns:
- frequency (1/s)
-
getOutletSlugFrequency
public double getOutletSlugFrequency()Get outlet slug frequency.- Returns:
- frequency (1/s)
-
getAverageSlugLength
public double getAverageSlugLength()Get average slug length.- Returns:
- length (m)
-
getMaxSlugLength
public double getMaxSlugLength()Get maximum observed slug length.- Returns:
- length (m)
-
getMaxSlugVolumeAtOutlet
public double getMaxSlugVolumeAtOutlet()Get maximum slug volume at outlet.- Returns:
- volume (m³)
-
getSlugFrequency
public double getSlugFrequency()Get slug frequency (deprecated, use getInletSlugFrequency).- Returns:
- inlet slug frequency (1/s)
-
setReferenceVelocity
public void setReferenceVelocity(double velocity) Set reference mixture velocity.- Parameters:
velocity- velocity (m/s)
-
setMinSlugLengthDiameters
public void setMinSlugLengthDiameters(double diameters) Set minimum slug length in diameters.- Parameters:
diameters- minimum length (diameters)
-
setMaxSlugLengthDiameters
public void setMaxSlugLengthDiameters(double diameters) Set maximum slug length in diameters.- Parameters:
diameters- maximum length (diameters)
-
setInitialSlugLengthDiameters
public void setInitialSlugLengthDiameters(double diameters) Set initial slug length in diameters.- Parameters:
diameters- initial length (diameters)
-
setEnableInletSlugGeneration
public void setEnableInletSlugGeneration(boolean enable) Enable or disable inlet slug generation.- Parameters:
enable- true to enable
-
setEnableTerrainSlugGeneration
public void setEnableTerrainSlugGeneration(boolean enable) Enable or disable terrain slug generation.- Parameters:
enable- true to enable
-
setEnableWakeEffects
public void setEnableWakeEffects(boolean enable) Enable or disable wake effects.- Parameters:
enable- true to enable
-
setEnableStochasticInitiation
public void setEnableStochasticInitiation(boolean enable) Enable or disable stochastic slug initiation.- Parameters:
enable- true to enable
-
setInitiationHoldupThreshold
public void setInitiationHoldupThreshold(double threshold) Set initiation holdup threshold.- Parameters:
threshold- holdup threshold (0-1)
-
setWakeLengthDiameters
public void setWakeLengthDiameters(double diameters) Set wake length in diameters.- Parameters:
diameters- wake length (diameters)
-
setMaxWakeAcceleration
public void setMaxWakeAcceleration(double factor) Set maximum wake acceleration factor.- Parameters:
factor- acceleration factor (>= 1.0)
-
getMassConservationError
public double getMassConservationError()Get mass conservation error.- Returns:
- error (kg), should be ~0
-
getTotalMassBorrowedFromEulerian
public double getTotalMassBorrowedFromEulerian()Get total mass borrowed from Eulerian cells.- Returns:
- mass (kg)
-
getTotalMassReturnedToEulerian
public double getTotalMassReturnedToEulerian()Get total mass returned to Eulerian cells.- Returns:
- mass (kg)
-
getOutletSlugLengths
-
getOutletSlugVolumes
-
getOutletInterArrivalTimes
-
reset
public void reset()Reset tracker state. -
getStatisticsString
-
toJson
-