Class LagrangianSlugTracker

java.lang.Object
neqsim.process.equipment.pipeline.twophasepipe.LagrangianSlugTracker
All Implemented Interfaces:
Serializable

public class LagrangianSlugTracker extends Object implements Serializable
OLGA-style Lagrangian slug tracking model.

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:
  • 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 slugIdCounter
      Counter for slug IDs.
    • random

      private Random random
      Random number generator for stochastic initiation.
    • enableInletSlugGeneration

      private boolean enableInletSlugGeneration
      Enable hydrodynamic slug generation at inlet.
    • enableTerrainSlugGeneration

      private boolean enableTerrainSlugGeneration
      Enable terrain-induced slug generation.
    • enableStochasticInitiation

      private boolean enableStochasticInitiation
      Enable random/stochastic slug initiation.
    • initiationHoldupThreshold

      private double initiationHoldupThreshold
      Minimum liquid holdup for slug initiation.
    • timeSinceLastInletSlug

      private double timeSinceLastInletSlug
      Time since last inlet slug generation (s).
    • minSlugLengthDiameters

      private double minSlugLengthDiameters
      Minimum stable slug length (diameters).
    • maxSlugLengthDiameters

      private double maxSlugLengthDiameters
      Maximum slug length (diameters).
    • initialSlugLengthDiameters

      private double initialSlugLengthDiameters
      Initial slug length at generation (diameters).
    • baseSlugHoldup

      private double baseSlugHoldup
      Base holdup in slug body.
    • minFilmHoldup

      private double minFilmHoldup
      Minimum holdup in film region.
    • mergeDistanceThreshold

      private double mergeDistanceThreshold
      Distance threshold for slug merging (m).
    • enableWakeEffects

      private boolean enableWakeEffects
      Enable wake interaction between slugs.
    • wakeLengthDiameters

      private double wakeLengthDiameters
      Wake length behind slug (diameters).
    • maxWakeAcceleration

      private double maxWakeAcceleration
      Maximum wake acceleration factor.
    • totalSlugsGenerated

      private int totalSlugsGenerated
      Total slugs generated.
    • totalSlugsMerged

      private int totalSlugsMerged
      Total slugs merged.
    • totalSlugsDissipated

      private int totalSlugsDissipated
      Total slugs dissipated.
    • totalSlugsExited

      private int totalSlugsExited
      Total slugs exited at outlet.
    • inletSlugFrequency

      private double inletSlugFrequency
      Slug frequency at inlet (1/s).
    • outletSlugFrequency

      private double outletSlugFrequency
      Slug frequency at outlet (1/s).
    • averageSlugLength

      private double averageSlugLength
      Average slug length (m).
    • maxObservedSlugLength

      private double maxObservedSlugLength
      Maximum slug length observed (m).
    • maxSlugVolumeAtOutlet

      private double maxSlugVolumeAtOutlet
      Maximum slug volume at outlet (m³).
    • simulationTime

      private double simulationTime
      Simulation time for statistics (s).
    • outletSlugLengths

      private List<Double> outletSlugLengths
      List of slug lengths at outlet for distribution.
    • outletSlugVolumes

      private List<Double> outletSlugVolumes
      List of slug volumes at outlet.
    • outletInterArrivalTimes

      private List<Double> outletInterArrivalTimes
      List of inter-arrival times at outlet (s).
    • lastOutletArrivalTime

      private double lastOutletArrivalTime
      Time of last slug arrival at outlet (s).
    • totalMassBorrowed

      private double totalMassBorrowed
      Total mass borrowed from Eulerian field (kg).
    • totalMassReturned

      private double totalMassReturned
      Total mass returned to Eulerian field (kg).
    • referenceMixtureVelocity

      private double referenceMixtureVelocity
      Reference 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

      public void advanceTimeStep(PipeSection[] sections, double dt)
      Advance all slugs by one time step.

      This is the main entry point for the Lagrangian tracking algorithm. Called each time step to:

      1. Check for new slug initiation (inlet, terrain, instability)
      2. Update velocity of each slug (Bendiksen correlation)
      3. Calculate mass exchange (pickup/shedding)
      4. Advance positions
      5. Update slug lengths
      6. Handle slug merging
      7. Remove exited/dissipated slugs
      8. Update Eulerian section properties
      9. Update statistics
      Parameters:
      sections - pipe sections array
      dt - time step (s)
    • checkSlugInitiation

      private void checkSlugInitiation(PipeSection[] sections, double dt)
      Check conditions for slug initiation.
      Parameters:
      sections - pipe sections
      dt - time step (s)
    • checkInletSlugGeneration

      private void checkInletSlugGeneration(PipeSection[] sections, double dt)
      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 sections
      dt - time step (s)
    • generateInletSlug

      private LagrangianSlugTracker.SlugBubbleUnit generateInletSlug(PipeSection inlet)
      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 tracker
      sections - pipe sections
      Returns:
      new slug unit
    • checkStochasticInitiation

      private void checkStochasticInitiation(PipeSection[] sections, double dt)
      Check for stochastic slug initiation from instabilities.
      Parameters:
      sections - pipe sections
      dt - time step (s)
    • generateInstabilitySlug

      private LagrangianSlugTracker.SlugBubbleUnit generateInstabilitySlug(PipeSection section, int sectionIndex, PipeSection[] sections)
      Generate slug from flow instability.
      Parameters:
      section - section where instability occurs
      sectionIndex - index of the section
      sections - 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 advance
      sections - pipe sections
      dt - 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 unit
      section - 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 unit
      section - pipe section
      dt - time step (s)
    • updateBubbleLength

      private void updateBubbleLength(LagrangianSlugTracker.SlugBubbleUnit slug, PipeSection section)
      Update Taylor bubble length.
      Parameters:
      slug - the slug unit
      section - 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

      private double calculateFilmHoldup(PipeSection section)
      Calculate film holdup from section properties.
      Parameters:
      section - pipe section
      Returns:
      film holdup
    • calculateEquilibriumLength

      private double calculateEquilibriumLength(PipeSection section)
      Calculate equilibrium slug length using Barnea-Taitel model.
      Parameters:
      section - pipe section
      Returns:
      equilibrium slug length (m)
    • updateWakeEffects

      private void updateWakeEffects(PipeSection[] sections)
      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

      private void handleSlugMerging(PipeSection[] sections)
      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

      private void removeInactiveSlugs(PipeSection[] sections)
      Remove slugs that have exited the pipe or dissipated.
      Parameters:
      sections - pipe sections
    • recordSlugAtOutlet

      private void recordSlugAtOutlet(LagrangianSlugTracker.SlugBubbleUnit slug)
      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 slug
      sections - pipe sections
    • clearSlugFlags

      private void clearSlugFlags(PipeSection[] sections)
      Clear slug flags on all sections.
      Parameters:
      sections - pipe sections
    • markSlugSections

      private void markSlugSections(PipeSection[] sections)
      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

      private int findSectionIndex(double position, PipeSection[] sections)
      Find section index containing a position.
      Parameters:
      position - position along pipe (m)
      sections - pipe sections
      Returns:
      section index, or -1 if not found
    • calculatePipeLength

      private double calculatePipeLength(PipeSection[] sections)
      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

      public List<Double> getOutletSlugLengths()
      Get outlet slug lengths for distribution analysis.
      Returns:
      list of slug lengths (m)
    • getOutletSlugVolumes

      public List<Double> getOutletSlugVolumes()
      Get outlet slug volumes.
      Returns:
      list of slug volumes (m³)
    • getOutletInterArrivalTimes

      public List<Double> getOutletInterArrivalTimes()
      Get inter-arrival times at outlet.
      Returns:
      list of inter-arrival times (s)
    • reset

      public void reset()
      Reset tracker state.
    • getStatisticsString

      public String getStatisticsString()
      Get detailed statistics string.
      Returns:
      statistics summary
    • toJson

      public String toJson()
      Get JSON representation of current state.
      Returns:
      JSON string