Class TwoFluidConservationEquations

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

public class TwoFluidConservationEquations extends Object implements Serializable
Two-fluid conservation equations for transient multiphase pipe flow.

Implements the spatial discretization of the two-fluid model equations:

Conservation Equations

  • Gas Mass: ∂/∂t(α_g·ρ_g·A) + ∂/∂x(α_g·ρ_g·v_g·A) = Γ_g
  • Liquid Mass: ∂/∂t(α_L·ρ_L·A) + ∂/∂x(α_L·ρ_L·v_L·A) = Γ_L
  • Gas Momentum: ∂/∂t(α_g·ρ_g·v_g·A) + ∂/∂x(α_g·ρ_g·v_g²·A) = -α_g·A·∂P/∂x - τ_wg·S_g - τ_i·S_i - α_g·ρ_g·g·A·sin(θ)
  • Liquid Momentum: ∂/∂t(α_L·ρ_L·v_L·A) + ∂/∂x(α_L·ρ_L·v_L²·A) = -α_L·A·∂P/∂x - τ_wL·S_L + τ_i·S_i - α_L·ρ_L·g·A·sin(θ)
  • Mixture Energy: ∂/∂t(E_mix·A) + ∂/∂x((E_mix+P)·v_mix·A) = Q_wall + W_friction

Variable Indices

  • 0: Gas mass per length (α_g·ρ_g·A)
  • 1: Liquid mass per length (α_L·ρ_L·A)
  • 2: Gas momentum per length (α_g·ρ_g·v_g·A)
  • 3: Liquid momentum per length (α_L·ρ_L·v_L·A)
  • 4: Mixture energy per length (E_mix·A)
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • GRAVITY

      private static final double GRAVITY
      See Also:
    • NUM_EQUATIONS

      public static final int NUM_EQUATIONS
      Number of conservation equations (7 for three-phase with water-oil slip: gas mass, oil mass, water mass, gas momentum, oil momentum, water momentum, energy).
      See Also:
    • IDX_GAS_MASS

      public static final int IDX_GAS_MASS
      Index for gas mass.
      See Also:
    • IDX_OIL_MASS

      public static final int IDX_OIL_MASS
      Index for oil mass (separate from water).
      See Also:
    • IDX_WATER_MASS

      public static final int IDX_WATER_MASS
      Index for water mass (separate conservation equation).
      See Also:
    • IDX_GAS_MOMENTUM

      public static final int IDX_GAS_MOMENTUM
      Index for gas momentum.
      See Also:
    • IDX_OIL_MOMENTUM

      public static final int IDX_OIL_MOMENTUM
      Index for oil momentum (separate from water for slip).
      See Also:
    • IDX_WATER_MOMENTUM

      public static final int IDX_WATER_MOMENTUM
      Index for water momentum (separate for water-oil slip).
      See Also:
    • IDX_ENERGY

      public static final int IDX_ENERGY
      Index for energy.
      See Also:
    • IDX_LIQUID_MOMENTUM

      public static final int IDX_LIQUID_MOMENTUM
      Legacy index for liquid momentum (for compatibility - uses oil momentum).
      See Also:
    • wallFriction

      private WallFriction wallFriction
    • interfacialFriction

      private InterfacialFriction interfacialFriction
    • flowRegimeDetector

      private FlowRegimeDetector flowRegimeDetector
    • geometryCalc

      private GeometryCalculator geometryCalc
    • fluxCalculator

      private AUSMPlusFluxCalculator fluxCalculator
    • reconstructor

      private MUSCLReconstructor reconstructor
    • includeEnergyEquation

      private boolean includeEnergyEquation
    • includeMassTransfer

      private boolean includeMassTransfer
    • massTransferCoefficient

      private double massTransferCoefficient
    • enableHeatTransfer

      private boolean enableHeatTransfer
      Enable heat transfer to surroundings.
    • surfaceTemperature

      private double surfaceTemperature
      Surface temperature for heat transfer (K).
    • heatTransferCoefficient

      private double heatTransferCoefficient
      Heat transfer coefficient (W/(m²·K)).
    • enableWaterOilSlip

      private boolean enableWaterOilSlip
      Enable water-oil velocity slip (7-equation model). When true, oil and water have separate momentum equations allowing different velocities.
  • Constructor Details

    • TwoFluidConservationEquations

      public TwoFluidConservationEquations()
      Constructor.
  • Method Details

    • calcRHS

      public double[][] calcRHS(TwoFluidSection[] sections, double dx)
      Calculate the right-hand side (dU/dt) for all cells.

      This is the main entry point for the numerical integration. Returns the time derivative of conservative variables for each cell.

      Parameters:
      sections - Array of pipe sections with current state
      dx - Cell size (m)
      Returns:
      Time derivatives [nCells][NUM_EQUATIONS]
    • calcInletFlux

      private double[] calcInletFlux(TwoFluidSection sec)
      Calculate inlet flux using the inlet cell state. This represents mass entering the domain from the inlet stream. Uses holdups directly (set by steady state or BC) rather than computing from mass per length to avoid feedback from cell depletion.
      Parameters:
      sec - the inlet pipe section
      Returns:
      array of flux values for each conserved variable
    • calcOutletFlux

      private double[] calcOutletFlux(TwoFluidSection sec)
      Calculate outlet flux using upwind scheme (transmissive boundary).
      Parameters:
      sec - the outlet pipe section
      Returns:
      array of flux values for each conserved variable
    • updateClosureRelations

      private void updateClosureRelations(TwoFluidSection[] sections)
      Update closure relations for all sections.
      Parameters:
      sections - array of pipe sections to update
    • calcInterfaceFluxes

      private double[][] calcInterfaceFluxes(TwoFluidSection[] sections, double dx)
      Calculate fluxes at cell interfaces using AUSM+.

      For three-phase flow with water-oil slip, we track oil and water mass and momentum fluxes separately. Water generally moves slower than oil in upward flow due to density differences.

      Parameters:
      sections - Pipe sections
      dx - Cell size
      Returns:
      Fluxes at interfaces [nInterfaces][NUM_EQUATIONS]
    • calcSourceTerms

      private double[][] calcSourceTerms(TwoFluidSection[] sections)
      Calculate source terms for all cells.

      For three-phase flow, tracks water separately from oil. Water accumulates more in valleys due to higher density.

      Parameters:
      sections - Pipe sections
      Returns:
      Source terms [nCells][NUM_EQUATIONS]
    • createGasState

      private AUSMPlusFluxCalculator.PhaseState createGasState(TwoFluidSection sec)
      Create gas phase state for flux calculation. Uses true holdup from mass per length for mass-consistent flux.
      Parameters:
      sec - the pipe section
      Returns:
      gas phase state object
    • createLiquidState

      private AUSMPlusFluxCalculator.PhaseState createLiquidState(TwoFluidSection sec)
      Create liquid phase state for flux calculation. Uses true holdup from mass per length for mass-consistent flux.
      Parameters:
      sec - the pipe section
      Returns:
      liquid phase state object
    • createOilState

      private AUSMPlusFluxCalculator.PhaseState createOilState(TwoFluidSection sec)
      Create oil phase state for flux calculation in three-phase flow. Uses true holdup from mass per length for mass-consistent flux.
      Parameters:
      sec - the pipe section
      Returns:
      oil phase state object
    • createWaterState

      private AUSMPlusFluxCalculator.PhaseState createWaterState(TwoFluidSection sec)
      Create water phase state for flux calculation in three-phase flow. Uses true holdup from mass per length for mass-consistent flux.
      Parameters:
      sec - the pipe section
      Returns:
      water phase state object
    • calcMassTransfer

      private double[] calcMassTransfer(TwoFluidSection sec)
      Calculate mass transfer between phases (simplified model).
      Parameters:
      sec - Pipe section
      Returns:
      [gasSource, liquidSource] in kg/(m·s)
    • calcHeatTransfer

      private double calcHeatTransfer(TwoFluidSection sec)
      Calculate heat transfer to/from pipe wall.
      Parameters:
      sec - Pipe section
      Returns:
      Heat source (W/m)
    • calcFrictionWork

      private double calcFrictionWork(TwoFluidSection sec)
      Calculate friction work (viscous dissipation).
      Parameters:
      sec - Pipe section
      Returns:
      Friction work source (W/m)
    • applyPressureGradient

      public void applyPressureGradient(TwoFluidSection[] sections, double[][] dUdt, double dx)
      Apply pressure gradient term (handled separately for numerical stability).
      Parameters:
      sections - Pipe sections
      dUdt - Current RHS values to modify
      dx - Cell size
    • extractState

      public double[][] extractState(TwoFluidSection[] sections)
      Extract state from sections into array format.

      For three-phase flow, extracts gas mass, oil mass, water mass separately.

      Parameters:
      sections - Pipe sections
      Returns:
      State array [nCells][NUM_EQUATIONS]
    • applyState

      public void applyState(TwoFluidSection[] sections, double[][] U)
      Apply state to sections from array format.

      For three-phase flow, updates water and oil holdups after extracting primitives.

      Parameters:
      sections - Pipe sections
      U - State array [nCells][NUM_EQUATIONS]
    • isIncludeEnergyEquation

      public boolean isIncludeEnergyEquation()
    • setIncludeEnergyEquation

      public void setIncludeEnergyEquation(boolean includeEnergyEquation)
    • isIncludeMassTransfer

      public boolean isIncludeMassTransfer()
    • setIncludeMassTransfer

      public void setIncludeMassTransfer(boolean includeMassTransfer)
    • isEnableWaterOilSlip

      public boolean isEnableWaterOilSlip()
      Check if water-oil velocity slip modeling is enabled.
      Returns:
      true if 7-equation model with separate oil/water momentum is enabled
    • setEnableWaterOilSlip

      public void setEnableWaterOilSlip(boolean enableWaterOilSlip)
      Enable or disable water-oil velocity slip modeling.

      When enabled, uses 7-equation model with separate oil and water momentum equations, allowing water to flow at different velocity than oil (e.g., water slipping back in uphill flow).

      Parameters:
      enableWaterOilSlip - true to enable 7-equation slip model
    • getMassTransferCoefficient

      public double getMassTransferCoefficient()
    • setMassTransferCoefficient

      public void setMassTransferCoefficient(double massTransferCoefficient)
    • getWallFriction

      public WallFriction getWallFriction()
    • getInterfacialFriction

      public InterfacialFriction getInterfacialFriction()
    • getFlowRegimeDetector

      public FlowRegimeDetector getFlowRegimeDetector()
    • getFluxCalculator

      public AUSMPlusFluxCalculator getFluxCalculator()
    • getReconstructor

      public MUSCLReconstructor getReconstructor()
    • setSurfaceTemperature

      public void setSurfaceTemperature(double temperature)
      Set surface temperature for heat transfer calculations.
      Parameters:
      temperature - Surface temperature in Kelvin
    • setHeatTransferCoefficient

      public void setHeatTransferCoefficient(double heatTransferCoefficient)
      Set heat transfer coefficient for convective heat transfer.
      Parameters:
      heatTransferCoefficient - Heat transfer coefficient in W/(m²·K)
    • setEnableHeatTransfer

      public void setEnableHeatTransfer(boolean enable)
      Enable/disable heat transfer modeling.
      Parameters:
      enable - true to enable heat transfer
    • getSurfaceTemperature

      public double getSurfaceTemperature()
      Get the surface temperature used in heat transfer calculations.
      Returns:
      Surface temperature in Kelvin
    • getHeatTransferCoefficient

      public double getHeatTransferCoefficient()
      Get the heat transfer coefficient.
      Returns:
      Heat transfer coefficient in W/(m²·K)
    • isHeatTransferEnabled

      public boolean isHeatTransferEnabled()
      Check if heat transfer is enabled.
      Returns:
      true if heat transfer modeling is active