Class TwoFluidConservationEquations
- All Implemented Interfaces:
Serializable
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 Summary
FieldsModifier and TypeFieldDescriptionprivate booleanEnable heat transfer to surroundings.private booleanEnable water-oil velocity slip (7-equation model).private FlowRegimeDetectorprivate AUSMPlusFluxCalculatorprivate GeometryCalculatorprivate static final doubleprivate doubleHeat transfer coefficient (W/(m²·K)).static final intIndex for energy.static final intIndex for gas mass.static final intIndex for gas momentum.static final intLegacy index for liquid momentum (for compatibility - uses oil momentum).static final intIndex for oil mass (separate from water).static final intIndex for oil momentum (separate from water for slip).static final intIndex for water mass (separate conservation equation).static final intIndex for water momentum (separate for water-oil slip).private booleanprivate booleanprivate InterfacialFrictionprivate doublestatic final intNumber of conservation equations (7 for three-phase with water-oil slip: gas mass, oil mass, water mass, gas momentum, oil momentum, water momentum, energy).private MUSCLReconstructorprivate static final longprivate doubleSurface temperature for heat transfer (K).private WallFriction -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyPressureGradient(TwoFluidSection[] sections, double[][] dUdt, double dx) Apply pressure gradient term (handled separately for numerical stability).voidapplyState(TwoFluidSection[] sections, double[][] U) Apply state to sections from array format.private doubleCalculate friction work (viscous dissipation).private doubleCalculate heat transfer to/from pipe wall.private double[]Calculate inlet flux using the inlet cell state.private double[][]calcInterfaceFluxes(TwoFluidSection[] sections, double dx) Calculate fluxes at cell interfaces using AUSM+.private double[]Calculate mass transfer between phases (simplified model).private double[]Calculate outlet flux using upwind scheme (transmissive boundary).double[][]calcRHS(TwoFluidSection[] sections, double dx) Calculate the right-hand side (dU/dt) for all cells.private double[][]calcSourceTerms(TwoFluidSection[] sections) Calculate source terms for all cells.Create gas phase state for flux calculation.Create liquid phase state for flux calculation.Create oil phase state for flux calculation in three-phase flow.Create water phase state for flux calculation in three-phase flow.double[][]extractState(TwoFluidSection[] sections) Extract state from sections into array format.doubleGet the heat transfer coefficient.doubledoubleGet the surface temperature used in heat transfer calculations.booleanCheck if water-oil velocity slip modeling is enabled.booleanCheck if heat transfer is enabled.booleanbooleanvoidsetEnableHeatTransfer(boolean enable) Enable/disable heat transfer modeling.voidsetEnableWaterOilSlip(boolean enableWaterOilSlip) Enable or disable water-oil velocity slip modeling.voidsetHeatTransferCoefficient(double heatTransferCoefficient) Set heat transfer coefficient for convective heat transfer.voidsetIncludeEnergyEquation(boolean includeEnergyEquation) voidsetIncludeMassTransfer(boolean includeMassTransfer) voidsetMassTransferCoefficient(double massTransferCoefficient) voidsetSurfaceTemperature(double temperature) Set surface temperature for heat transfer calculations.private voidupdateClosureRelations(TwoFluidSection[] sections) Update closure relations for all sections.
-
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_EQUATIONSNumber 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_MASSIndex for gas mass.- See Also:
-
IDX_OIL_MASS
public static final int IDX_OIL_MASSIndex for oil mass (separate from water).- See Also:
-
IDX_WATER_MASS
public static final int IDX_WATER_MASSIndex for water mass (separate conservation equation).- See Also:
-
IDX_GAS_MOMENTUM
public static final int IDX_GAS_MOMENTUMIndex for gas momentum.- See Also:
-
IDX_OIL_MOMENTUM
public static final int IDX_OIL_MOMENTUMIndex for oil momentum (separate from water for slip).- See Also:
-
IDX_WATER_MOMENTUM
public static final int IDX_WATER_MOMENTUMIndex for water momentum (separate for water-oil slip).- See Also:
-
IDX_ENERGY
public static final int IDX_ENERGYIndex for energy.- See Also:
-
IDX_LIQUID_MOMENTUM
public static final int IDX_LIQUID_MOMENTUMLegacy index for liquid momentum (for compatibility - uses oil momentum).- See Also:
-
wallFriction
-
interfacialFriction
-
flowRegimeDetector
-
geometryCalc
-
fluxCalculator
-
reconstructor
-
includeEnergyEquation
private boolean includeEnergyEquation -
includeMassTransfer
private boolean includeMassTransfer -
massTransferCoefficient
private double massTransferCoefficient -
enableHeatTransfer
private boolean enableHeatTransferEnable heat transfer to surroundings. -
surfaceTemperature
private double surfaceTemperatureSurface temperature for heat transfer (K). -
heatTransferCoefficient
private double heatTransferCoefficientHeat transfer coefficient (W/(m²·K)). -
enableWaterOilSlip
private boolean enableWaterOilSlipEnable 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
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 statedx- Cell size (m)- Returns:
- Time derivatives [nCells][NUM_EQUATIONS]
-
calcInletFlux
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
Calculate outlet flux using upwind scheme (transmissive boundary).- Parameters:
sec- the outlet pipe section- Returns:
- array of flux values for each conserved variable
-
updateClosureRelations
Update closure relations for all sections.- Parameters:
sections- array of pipe sections to update
-
calcInterfaceFluxes
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 sectionsdx- Cell size- Returns:
- Fluxes at interfaces [nInterfaces][NUM_EQUATIONS]
-
calcSourceTerms
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
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
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
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
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
Calculate mass transfer between phases (simplified model).- Parameters:
sec- Pipe section- Returns:
- [gasSource, liquidSource] in kg/(m·s)
-
calcHeatTransfer
Calculate heat transfer to/from pipe wall.- Parameters:
sec- Pipe section- Returns:
- Heat source (W/m)
-
calcFrictionWork
Calculate friction work (viscous dissipation).- Parameters:
sec- Pipe section- Returns:
- Friction work source (W/m)
-
applyPressureGradient
Apply pressure gradient term (handled separately for numerical stability).- Parameters:
sections- Pipe sectionsdUdt- Current RHS values to modifydx- Cell size
-
extractState
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
Apply state to sections from array format.For three-phase flow, updates water and oil holdups after extracting primitives.
- Parameters:
sections- Pipe sectionsU- 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
-
getInterfacialFriction
-
getFlowRegimeDetector
-
getFluxCalculator
-
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
-