Class PipeBeggsAndBrills

All Implemented Interfaces:
Serializable, Runnable, PipeLineInterface, ProcessEquipmentInterface, TwoPortInterface, SimulationInterface, NamedInterface

public class PipeBeggsAndBrills extends Pipeline
Pipeline simulation using Beggs and Brill empirical correlations for multiphase flow.

This class implements the Beggs and Brill (1973) correlation for pressure drop and liquid holdup prediction in multiphase pipeline flow. It supports both single-phase and multiphase (gas-liquid) flow in horizontal, inclined, and vertical pipes.

Reference

Beggs, H.D. and Brill, J.P., "A Study of Two-Phase Flow in Inclined Pipes", Journal of Petroleum Technology, May 1973, pp. 607-617. SPE-4007-PA.

Calculation Modes

The pipeline supports two primary calculation modes via PipeBeggsAndBrills.CalculationMode:

  • CALCULATE_OUTLET_PRESSURE (default) - Given inlet conditions and flow rate, calculate the outlet pressure
  • CALCULATE_FLOW_RATE - Given inlet and outlet pressures, calculate the flow rate using iterative methods

Flow Regime Determination

The Beggs and Brill correlation classifies flow into four regimes based on the Froude number (Fr) and input liquid volume fraction (λL):

  • SEGREGATED - Stratified, wavy, or annular flow where phases are separated
  • INTERMITTENT - Plug or slug flow with alternating liquid slugs and gas pockets
  • DISTRIBUTED - Bubble or mist flow where one phase is dispersed in the other
  • TRANSITION - Flow in transition zone between segregated and intermittent
  • SINGLE_PHASE - Only gas or only liquid present

Flow regime boundaries are defined by correlations L1-L4:

L1 = 316 × λL^0.302
L2 = 0.0009252 × λL^(-2.4684)
L3 = 0.1 × λL^(-1.4516)
L4 = 0.5 × λL^(-6.738)

Pressure Drop Calculation

Total pressure drop consists of three components:

ΔP_total = ΔP_friction + ΔP_hydrostatic + ΔP_acceleration

where:

  • Friction pressure drop - Uses two-phase friction factor with slip correction
  • Hydrostatic pressure drop - Based on mixture density and elevation change
  • Acceleration pressure drop - Usually negligible, included in friction term

Liquid Holdup Calculation

Liquid holdup (EL) is calculated based on flow regime:

  • Segregated: EL = 0.98 × λL^0.4846 / Fr^0.0868
  • Intermittent: EL = 0.845 × λL^0.5351 / Fr^0.0173
  • Distributed: EL = 1.065 × λL^0.5824 / Fr^0.0609

Inclination correction factor (Bθ) is applied for non-horizontal pipes.

Friction Factor Calculation

The friction factor is calculated using:

  • Laminar (Re < 2300): f = 64/Re
  • Transition (2300-4000): Linear interpolation
  • Turbulent (Re > 4000): Haaland equation

Two-phase friction factor: f_tp = f × exp(S), where S is a slip correction factor.

Heat Transfer Modes

The pipeline supports five heat transfer calculation modes via PipeBeggsAndBrills.HeatTransferMode:

  • ADIABATIC - No heat transfer (Q=0). Temperature changes only from Joule-Thomson effect.
  • ISOTHERMAL - Constant temperature along the pipe (outlet T = inlet T).
  • SPECIFIED_U - Use a user-specified overall heat transfer coefficient (U-value).
  • ESTIMATED_INNER_H - Calculate inner h from flow conditions using Gnielinski correlation for turbulent flow, use as U.
  • DETAILED_U - Calculate inner h from flow, then compute overall U including pipe wall conduction, insulation (if present), and outer convection resistances.

NTU-Effectiveness Method

Heat transfer is calculated using the analytical NTU (Number of Transfer Units) method:

NTU = U × A / (ṁ × Cp)
T_out = T_wall + (T_in - T_wall) × exp(-NTU)

This provides an exact analytical solution for constant wall temperature boundary conditions.

Inner Heat Transfer Coefficient

For ESTIMATED_INNER_H and DETAILED_U modes, the inner convective heat transfer coefficient is calculated using:

  • Laminar flow (Re < 2300): Nu = 3.66 (fully developed pipe flow)
  • Transition (2300 < Re < 3000): Linear interpolation
  • Turbulent flow (Re > 3000): Gnielinski correlation: Nu = (f/8)(Re-1000)Pr / [1 + 12.7(f/8)^0.5(Pr^(2/3)-1)]
  • Two-phase flow: Shah/Martinelli enhancement factor applied

Overall U-Value (DETAILED_U mode)

The overall heat transfer coefficient includes thermal resistances in series:

1/U = 1/h_inner + R_wall + R_insulation + 1/h_outer

R_wall = r_i × ln(r_o/r_i) / k_wall
R_insulation = r_i × ln(r_ins/r_o) / k_ins

where:

  • h_inner = inner convective coefficient from flow calculation
  • R_wall = pipe wall conductive resistance (cylindrical geometry)
  • R_insulation = insulation layer resistance (if thickness > 0)
  • h_outer = outer convective coefficient (e.g., seawater ~500 W/(m²·K))

Energy Equation Components

The energy balance can include three optional components:

  • Wall heat transfer - Heat exchange with surroundings using NTU-effectiveness method
  • Joule-Thomson effect - Temperature change due to gas expansion (cooling): ΔT_JT = -μ_JT × ΔP
  • Friction heating - Viscous dissipation adding energy to the fluid: Q_friction = ΔP_friction × V̇

Joule-Thomson Coefficient

The JT coefficient is calculated from rigorous thermodynamics (mass-weighted average across phases). Typical values:

  • Methane: ~4×10⁻⁶ K/Pa (0.4 K/bar)
  • Natural gas: 3-5×10⁻⁶ K/Pa
  • CO₂: ~10⁻⁵ K/Pa (1 K/bar)

Usage Examples

Example 1: Basic Horizontal Pipeline

// Create fluid system
SystemInterface fluid = new SystemSrkEos(303.15, 50.0);
fluid.addComponent("methane", 0.9);
fluid.addComponent("ethane", 0.1);
fluid.setMixingRule("classic");

// Create inlet stream
Stream inlet = new Stream("inlet", fluid);
inlet.setFlowRate(50000, "kg/hr");
inlet.run();

// Create pipeline
PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("pipeline", inlet);
pipe.setDiameter(0.2032); // 8 inch
pipe.setLength(10000.0); // 10 km
pipe.setElevation(0.0); // horizontal
pipe.setNumberOfIncrements(20);
pipe.run();

System.out.println("Pressure drop: " + pipe.getPressureDrop() + " bar");
System.out.println("Flow regime: " + pipe.getFlowRegime());

Example 2: Pipeline with Heat Transfer

// Hot fluid in cold environment
PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("subsea_pipe", hotStream);
pipe.setDiameter(0.1524); // 6 inch
pipe.setLength(5000.0); // 5 km
pipe.setElevation(0.0); // horizontal
pipe.setConstantSurfaceTemperature(5.0, "C"); // Sea temperature
pipe.setHeatTransferCoefficient(25.0); // W/(m²·K) - SPECIFIED_U mode
pipe.run();

System.out.println("Inlet T: " + pipe.getInletStream().getTemperature("C") + " °C");
System.out.println("Outlet T: " + pipe.getOutletStream().getTemperature("C") + " °C");

Example 3: Detailed U-Value with Insulation

pipe.setConstantSurfaceTemperature(5.0, "C"); // Seawater
pipe.setOuterHeatTransferCoefficient(500.0); // Seawater forced convection
pipe.setPipeWallThermalConductivity(45.0); // Carbon steel
pipe.setInsulation(0.05, 0.04); // 50mm foam, k=0.04 W/(m·K)
pipe.setHeatTransferMode(HeatTransferMode.DETAILED_U);
pipe.run();

Example 4: Inclined Pipeline (Riser)

// Vertical riser
PipeBeggsAndBrills riser = new PipeBeggsAndBrills("riser", feedStream);
riser.setDiameter(0.1524); // 6 inch
riser.setLength(500.0); // 500 m length
riser.setElevation(500.0); // 500 m vertical rise
riser.setAngle(90.0); // Vertical
riser.run();

System.out.println("Hydrostatic head: " + riser.getSegmentPressure(0)
    - riser.getSegmentPressure(riser.getNumberOfIncrements()) + " bar");

Example 5: Adiabatic with Joule-Thomson Effect

// High-pressure gas expansion
pipe.setHeatTransferMode(HeatTransferMode.ADIABATIC);
pipe.setIncludeJouleThomsonEffect(true);
pipe.run();

// For natural gas with ~20 bar pressure drop:
// Expected JT cooling: ~8-10 K

Example 6: Calculate Flow Rate from Pressures

pipe.setCalculationMode(CalculationMode.CALCULATE_FLOW_RATE);
pipe.setSpecifiedOutletPressure(40.0, "bara"); // Target outlet pressure
pipe.setMaxFlowIterations(50);
pipe.setFlowConvergenceTolerance(1e-4);
pipe.run();

System.out.println("Calculated flow: " + pipe.getOutletStream().getFlowRate("kg/hr") + " kg/hr");

Transient Simulation

The class supports transient (time-dependent) simulation using the runTransient() method. This solves the time-dependent mass, momentum, and energy conservation equations using an explicit finite difference scheme.

Typical Parameter Values

Typical Heat Transfer Coefficients
Environment h [W/(m²·K)]
Still air (natural convection) 5-25
Forced air 25-250
Still water 100-500
Seawater (flowing) 500-1000
Buried in soil 1-5
Typical Thermal Conductivities
Material k [W/(m·K)]
Carbon steel 45-50
Stainless steel 15-20
Mineral wool insulation 0.03-0.05
Polyurethane foam 0.02-0.03
Concrete coating 1.0-1.5
Version:
$Id: $Id
Author:
Even Solbraa, Sviatoslav Eroshkin
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • iteration

      int iteration
    • nominalDiameter

      private double nominalDiameter
    • PipeSpecSet

      private Boolean PipeSpecSet
    • inletPressure

      private double inletPressure
    • totalPressureDrop

      private double totalPressureDrop
    • temperatureOut

      protected double temperatureOut
    • pressureOut

      protected double pressureOut
    • calculationMode

      private PipeBeggsAndBrills.CalculationMode calculationMode
    • specifiedOutletPressure

      private double specifiedOutletPressure
    • specifiedOutletPressureUnit

      private String specifiedOutletPressureUnit
    • maxFlowIterations

      private int maxFlowIterations
    • flowConvergenceTolerance

      private double flowConvergenceTolerance
    • maxflowunit

      String maxflowunit
    • insideDiameter

      private double insideDiameter
    • pipeThickness

      private double pipeThickness
    • pipeWallRoughness

      private double pipeWallRoughness
    • runIsothermal

      private boolean runIsothermal
    • regime

    • inputVolumeFractionLiquid

      private double inputVolumeFractionLiquid
    • mixtureFroudeNumber

      private double mixtureFroudeNumber
    • pipeSpecification

      private String pipeSpecification
    • A

      private double A
    • area

      private double area
    • supGasVel

      private double supGasVel
    • supLiquidVel

      private double supLiquidVel
    • mixtureDensity

      private double mixtureDensity
    • hydrostaticPressureDrop

      private double hydrostaticPressureDrop
    • El

      private double El
    • supMixVel

      private double supMixVel
    • frictionPressureLoss

      private double frictionPressureLoss
    • pressureDrop

      private double pressureDrop
    • numberOfIncrements

      private int numberOfIncrements
    • totalLength

      private double totalLength
    • totalElevation

      private double totalElevation
    • angle

      private double angle
    • mixtureLiquidDensity

      private double mixtureLiquidDensity
    • mixtureLiquidViscosity

      private double mixtureLiquidViscosity
    • mixtureOilMassFraction

      private double mixtureOilMassFraction
    • mixtureOilVolumeFraction

      private double mixtureOilVolumeFraction
    • cumulativeLength

      private double cumulativeLength
    • cumulativeElevation

      private double cumulativeElevation
    • length

      double length
    • elevation

      double elevation
    • pressureProfile

      private List<Double> pressureProfile
    • temperatureProfile

      private List<Double> temperatureProfile
    • pressureDropProfile

      private List<Double> pressureDropProfile
    • flowRegimeProfile

      private List<PipeBeggsAndBrills.FlowRegime> flowRegimeProfile
    • liquidSuperficialVelocityProfile

      private List<Double> liquidSuperficialVelocityProfile
    • gasSuperficialVelocityProfile

      private List<Double> gasSuperficialVelocityProfile
    • mixtureSuperficialVelocityProfile

      private List<Double> mixtureSuperficialVelocityProfile
    • mixtureViscosityProfile

      private List<Double> mixtureViscosityProfile
    • mixtureDensityProfile

      private List<Double> mixtureDensityProfile
    • liquidDensityProfile

      private List<Double> liquidDensityProfile
    • liquidHoldupProfile

      private List<Double> liquidHoldupProfile
    • mixtureReynoldsNumber

      private List<Double> mixtureReynoldsNumber
    • lengthProfile

      private List<Double> lengthProfile
    • elevationProfile

      private List<Double> elevationProfile
    • incrementsProfile

      private List<Integer> incrementsProfile
    • transientInitialized

      private boolean transientInitialized
    • transientPressureProfile

      private List<Double> transientPressureProfile
    • transientTemperatureProfile

      private List<Double> transientTemperatureProfile
    • transientMassFlowProfile

      private List<Double> transientMassFlowProfile
    • transientVelocityProfile

      private List<Double> transientVelocityProfile
    • transientDensityProfile

      private List<Double> transientDensityProfile
    • segmentLengthMeters

      private double segmentLengthMeters
    • crossSectionArea

      private double crossSectionArea
    • MIN_TRANSIT_VELOCITY

      private static final double MIN_TRANSIT_VELOCITY
      See Also:
    • MIN_DENSITY

      private static final double MIN_DENSITY
      See Also:
    • runAdiabatic

      private boolean runAdiabatic
    • runConstantSurfaceTemperature

      private boolean runConstantSurfaceTemperature
    • constantSurfaceTemperature

      private double constantSurfaceTemperature
    • heatTransferCoefficient

      private double heatTransferCoefficient
    • heatTransferMode

      private PipeBeggsAndBrills.HeatTransferMode heatTransferMode
    • includeJouleThomsonEffect

      private boolean includeJouleThomsonEffect
    • includeFrictionHeating

      private boolean includeFrictionHeating
    • Tmi

      double Tmi
    • Tmo

      double Tmo
    • Ts

      double Ts
    • error

      double error
    • iterationT

      double iterationT
    • dTlm

      double dTlm
    • cp

      double cp
    • q1

      double q1
    • q2

      double q2
    • ReNoSlip

      double ReNoSlip
    • S

      double S
    • rhoNoSlip

      double rhoNoSlip
    • muNoSlip

      double muNoSlip
    • thermalConductivity

      double thermalConductivity
    • Pr

      double Pr
    • frictionFactor

      double frictionFactor
    • frictionTwoPhase

      double frictionTwoPhase
    • Nu

      double Nu
    • criticalPressure

      double criticalPressure
    • hmax

      double hmax
    • X

      double X
    • outerHeatTransferCoefficient

      private double outerHeatTransferCoefficient
    • pipeWallThermalConductivity

      private double pipeWallThermalConductivity
    • insulationThickness

      private double insulationThickness
    • insulationThermalConductivity

      private double insulationThermalConductivity
  • Constructor Details

    • PipeBeggsAndBrills

      public PipeBeggsAndBrills(String name)
      Constructor for PipeBeggsAndBrills.
      Parameters:
      name - name of pipe
    • PipeBeggsAndBrills

      public PipeBeggsAndBrills(String name, StreamInterface inStream)
      Constructor for PipeBeggsAndBrills.
      Parameters:
      name - name of pipe
      inStream - input stream
  • Method Details

    • setPipeSpecification

      public void setPipeSpecification(double nominalDiameter, String pipeSec)

      Setter for the field pipeSpecification.

      Parameters:
      nominalDiameter - a double in inch
      pipeSec - a String object
    • getThermoSystem

      public SystemInterface getThermoSystem()

      getThermoSystem.

      Specified by:
      getThermoSystem in interface ProcessEquipmentInterface
      Overrides:
      getThermoSystem in class ProcessEquipmentBaseClass
      Returns:
      a SystemInterface object
    • setElevation

      public void setElevation(double elevation)

      Setter for the field elevation.

      Parameters:
      elevation - a double
    • setLength

      public void setLength(double length)

      Setter for the field length.

      Parameters:
      length - the length to set
    • setDiameter

      public void setDiameter(double diameter)

      setDiameter.

      Parameters:
      diameter - the diameter to set
    • setThickness

      public void setThickness(double pipeThickness)

      setThickness.

      Parameters:
      pipeThickness - the thickness to set
    • getThickness

      public double getThickness()

      getThickness.

      Returns:
      a double
    • setAngle

      public void setAngle(double angle)

      Setter for the field angle.

      Parameters:
      angle - a double
    • setPipeWallRoughness

      public void setPipeWallRoughness(double pipeWallRoughness)

      Setter for the field pipeWallRoughness.

      Parameters:
      pipeWallRoughness - the pipeWallRoughness to set
    • setNumberOfIncrements

      public void setNumberOfIncrements(int numberOfIncrements)

      Setter for the field numberOfIncrements.

      Parameters:
      numberOfIncrements - a int
    • setRunIsothermal

      @Deprecated public void setRunIsothermal(boolean runIsothermal)
      Sets whether to run isothermal calculations.
      Parameters:
      runIsothermal - a boolean
    • setConstantSurfaceTemperature

      public void setConstantSurfaceTemperature(double temperature, String unit)

      Setter for the field constantSurfaceTemperature.

      Parameters:
      temperature - a double
      unit - a String object
    • setHeatTransferMode

      public void setHeatTransferMode(PipeBeggsAndBrills.HeatTransferMode mode)
      Sets the heat transfer calculation mode.

      Available modes:

      • ADIABATIC: No heat transfer (Q=0)
      • ISOTHERMAL: Constant temperature along the pipe
      • SPECIFIED_U: Use a user-specified overall U-value
      • ESTIMATED_INNER_H: Calculate h from flow (Gnielinski), use as U
      • DETAILED_U: Calculate full U including wall, insulation, outer convection
      Parameters:
      mode - the heat transfer calculation mode
    • getHeatTransferMode

      public PipeBeggsAndBrills.HeatTransferMode getHeatTransferMode()
      Gets the current heat transfer calculation mode.
      Returns:
      the heat transfer mode
    • setHeatTransferCoefficient

      public void setHeatTransferCoefficient(double heatTransferCoefficient)
      Sets the overall heat transfer coefficient (U-value) and switches to SPECIFIED_U mode.

      This is the effective U-value used in the heat transfer equation Q = U * A * LMTD. When set, the mode automatically changes to SPECIFIED_U, meaning this value is used directly without flow-based calculation.

      Parameters:
      heatTransferCoefficient - the overall heat transfer coefficient in W/(m²·K)
      Throws:
      IllegalArgumentException - if heatTransferCoefficient is negative
    • setOutletPressure

      public void setOutletPressure(double pressure)
      Sets the specified outlet pressure and switches to flow rate calculation mode. When outlet pressure is specified, the run() method will iterate to find the flow rate that achieves the specified outlet pressure.
      Specified by:
      setOutletPressure in interface TwoPortInterface
      Overrides:
      setOutletPressure in class TwoPortEquipment
      Parameters:
      pressure - the desired outlet pressure in bara
    • setOutletPressure

      public void setOutletPressure(double pressure, String unit)
      Sets the specified outlet pressure with unit and switches to flow rate calculation mode. When outlet pressure is specified, the run() method will iterate to find the flow rate that achieves the specified outlet pressure.
      Parameters:
      pressure - the desired outlet pressure
      unit - the pressure unit (e.g., "bara", "barg", "Pa", "MPa")
    • getSpecifiedOutletPressure

      public double getSpecifiedOutletPressure()
      Gets the specified outlet pressure.
      Returns:
      the specified outlet pressure in the unit set, or NaN if not specified
    • getSpecifiedOutletPressureUnit

      public String getSpecifiedOutletPressureUnit()
      Gets the specified outlet pressure unit.
      Returns:
      the pressure unit
    • setCalculationMode

      public void setCalculationMode(PipeBeggsAndBrills.CalculationMode mode)
      Sets the calculation mode for the pipeline.
      Parameters:
      mode - the calculation mode (CALCULATE_OUTLET_PRESSURE or CALCULATE_FLOW_RATE)
    • getCalculationMode

      public PipeBeggsAndBrills.CalculationMode getCalculationMode()
      Gets the current calculation mode.
      Returns:
      the calculation mode
    • setMaxFlowIterations

      public void setMaxFlowIterations(int maxIterations)
      Sets the maximum number of iterations for flow rate calculation when outlet pressure is specified.
      Parameters:
      maxIterations - the maximum number of iterations
    • setFlowConvergenceTolerance

      public void setFlowConvergenceTolerance(double tolerance)
      Sets the convergence tolerance for flow rate calculation when outlet pressure is specified.
      Parameters:
      tolerance - the relative convergence tolerance (default 1e-4)
    • convertSystemUnitToImperial

      public void convertSystemUnitToImperial()
      Converts the input values from the system measurement units to imperial units. Needed because the main equations and coefficients are developed for imperial system

      The conversions applied are:

      • Inside Diameter (m) - (feet): multiplied by 3.2808399
      • Angle (m) - (feet): multiplied by 0.01745329
      • Elevation (m) - (feet): multiplied by 3.2808399
      • Length (m) - (feet): multiplied by 3.2808399
      • Pipe Wall Roughness (m) - (feet): multiplied by 3.2808399
    • convertSystemUnitToMetric

      public void convertSystemUnitToMetric()
      Converts the input values from imperial units to the system measurement units. Needed because the main equations and coefficients are developed for imperial system

      The conversions applied are the inverse of those in the convertSystemUnitToImperial() method:

      • Inside Diameter (ft - m): divided by 3.2808399
      • Angle (ft - m): divided by 0.01745329
      • Elevation (ft - m): divided by 3.2808399
      • Length (ft - m): divided by 3.2808399
      • Pipe Wall Roughness (ft - m): divided by 3.2808399
      • Pressure Drop (lb/inch) -(bar): multiplied by 1.48727E-05
    • calculateMissingValue

      public void calculateMissingValue()

      calculateMissingValue.

    • calculateLength

      private double calculateLength()
      Calculates the length based on the elevation and angle.
      Returns:
      the calculated length.
    • calculateElevation

      private double calculateElevation()
      Calculates the elevation based on the length and angle.
      Returns:
      the calculated elevation.
    • calculateAngle

      private double calculateAngle()
      Calculates the angle based on the length and elevation.
      Returns:
      the calculated angle.
    • calcFlowRegime

      public PipeBeggsAndBrills.FlowRegime calcFlowRegime()

      calcFlowRegime.

      Returns:
      the determined flow regime
    • calcHydrostaticPressureDifference

      public double calcHydrostaticPressureDifference()

      calcHydrostaticPressureDifference.

      Returns:
      a double
    • calcFrictionPressureLoss

      public double calcFrictionPressureLoss()

      calcFrictionPressureLoss.

      Returns:
      a double
    • calcPressureDrop

      public double calcPressureDrop()

      calcPressureDrop.

      Returns:
      a double
    • run

      public void run(UUID id)

      In this method all thermodynamic and unit operations will be calculated in a steady state calculation.

      Specified by:
      run in interface SimulationInterface
      Overrides:
      run in class Pipeline
      Parameters:
      id - UUID
    • runWithSpecifiedFlowRate

      private void runWithSpecifiedFlowRate(UUID id)
      Run pipeline calculation with specified flow rate (calculate outlet pressure). This is the default calculation mode.
      Parameters:
      id - calculation identifier
    • runWithSpecifiedOutletPressure

      private void runWithSpecifiedOutletPressure(UUID id)
      Run pipeline calculation with specified outlet pressure (calculate flow rate). Uses bisection method to find the flow rate that achieves the target outlet pressure.
      Parameters:
      id - calculation identifier
    • tryCalculatePressure

      private double tryCalculatePressure(double flowRate, String flowUnit, UUID id)
      Helper method to calculate outlet pressure for a given flow rate, handling exceptions when pressure goes negative (indicating flow rate is too high).
      Parameters:
      flowRate - the flow rate to test
      flowUnit - the unit for flow rate
      id - calculation identifier
      Returns:
      the outlet pressure, or a very low value if calculation fails (pressure went negative)
    • calcGnielinskiNu

      private double calcGnielinskiNu(double Re, double Pr)
      Calculates the Nusselt number using the Gnielinski correlation for turbulent pipe flow. Valid for 0.5 < Pr < 2000 and 3000 < Re < 5E6.
      Parameters:
      Re - Reynolds number
      Pr - Prandtl number
      Returns:
      the Nusselt number
    • estimateHeatTransferCoefficent

      public double estimateHeatTransferCoefficent(SystemInterface system)
      Estimates the inner heat transfer coefficient for the given system.

      For single-phase flow, uses standard correlations:

      • Laminar (Re < 2300): Nu = 3.66 (fully developed)
      • Transition (2300-3000): Linear interpolation
      • Turbulent (Re > 3000): Gnielinski correlation

      For two-phase flow, uses Shah correlation enhancement factor.

      Parameters:
      system - the thermodynamic system for which the heat transfer coefficient is to be estimated
      Returns:
      the estimated inner heat transfer coefficient [W/(m²·K)]
    • calcTwoPhaseHeatTransferCoefficient

      private double calcTwoPhaseHeatTransferCoefficient(SystemInterface system, double singlePhaseHTC)
      Calculates the two-phase heat transfer coefficient using Shah correlation.

      The Shah correlation provides enhancement factors for convective heat transfer in two-phase flow. It accounts for the increased turbulence and interfacial effects in gas-liquid flow.

      Parameters:
      system - the thermodynamic system
      singlePhaseHTC - the single-phase heat transfer coefficient [W/(m²·K)]
      Returns:
      the two-phase heat transfer coefficient [W/(m²·K)]
    • calcOverallHeatTransferCoefficient

      private double calcOverallHeatTransferCoefficient(double innerHTC)
      Calculates the overall heat transfer coefficient including inner convection, pipe wall conduction, insulation (if present), and outer convection.

      The overall U-value is based on the inner surface area and accounts for:

      • Inner convective resistance: 1/h_i
      • Pipe wall conductive resistance: (r_o/r_i) × ln(r_o/r_i) / k_wall
      • Insulation resistance (if present): (r_ins/r_i) × ln(r_ins/r_o) / k_ins
      • Outer convective resistance: (r_o/r_i) / h_o or (r_ins/r_i) / h_o
      Parameters:
      innerHTC - the inner heat transfer coefficient [W/(m²·K)]
      Returns:
      the overall heat transfer coefficient based on inner area [W/(m²·K)]
    • setOuterHeatTransferCoefficient

      public void setOuterHeatTransferCoefficient(double coefficient)
      Sets the outer (external) heat transfer coefficient for calculating overall U-value.

      This is the convective heat transfer coefficient on the outside of the pipe (or insulation). Typical values:

      • Still air: 5-10 W/(m²·K)
      • Moving air (wind): 10-50 W/(m²·K)
      • Still water: 100-500 W/(m²·K)
      • Flowing water (subsea): 200-1000 W/(m²·K)
      Parameters:
      coefficient - the outer heat transfer coefficient [W/(m²·K)]
      Throws:
      IllegalArgumentException - if coefficient is negative
    • getOuterHeatTransferCoefficient

      public double getOuterHeatTransferCoefficient()
      Gets the outer (external) heat transfer coefficient.
      Returns:
      the outer heat transfer coefficient [W/(m²·K)]
    • setPipeWallThermalConductivity

      public void setPipeWallThermalConductivity(double conductivity)
      Sets the pipe wall thermal conductivity.

      Typical values:

      • Carbon steel: 45-50 W/(m·K)
      • Stainless steel: 15-20 W/(m·K)
      • Duplex steel: 15-17 W/(m·K)
      Parameters:
      conductivity - the thermal conductivity [W/(m·K)]
    • getPipeWallThermalConductivity

      public double getPipeWallThermalConductivity()
      Gets the pipe wall thermal conductivity.
      Returns:
      the thermal conductivity [W/(m·K)]
    • setInsulation

      public void setInsulation(double thickness, double conductivity)
      Sets the insulation layer properties.

      Typical thermal conductivity values:

      • Mineral wool: 0.03-0.05 W/(m·K)
      • Polyurethane foam: 0.02-0.03 W/(m·K)
      • Polypropylene (wet insulation): 0.22-0.25 W/(m·K)
      • Syntactic foam (subsea): 0.10-0.15 W/(m·K)
      Parameters:
      thickness - the insulation thickness [m]
      conductivity - the thermal conductivity [W/(m·K)]
      Throws:
      IllegalArgumentException - if thickness or conductivity is negative
    • getInsulationThickness

      public double getInsulationThickness()
      Gets the insulation thickness.
      Returns:
      the insulation thickness [m]
    • getInsulationThermalConductivity

      public double getInsulationThermalConductivity()
      Gets the insulation thermal conductivity.
      Returns:
      the thermal conductivity [W/(m·K)]
    • setUseOverallHeatTransferCoefficient

      @Deprecated public void setUseOverallHeatTransferCoefficient(boolean use)
      Deprecated.
      Enables or disables use of detailed overall heat transfer coefficient calculation.

      When enabled (true), switches to DETAILED_U mode which includes pipe wall resistance, insulation resistance (if set), and outer convection resistance (if set). When disabled (false), switches to ESTIMATED_INNER_H mode which uses only the inner convective heat transfer coefficient.

      Parameters:
      use - true to use DETAILED_U mode, false to use ESTIMATED_INNER_H mode
    • isUseOverallHeatTransferCoefficient

      @Deprecated public boolean isUseOverallHeatTransferCoefficient()
      Deprecated.
      Gets whether detailed overall heat transfer coefficient is being used.
      Returns:
      true if using DETAILED_U mode
    • calcTemperatureDifference

      public double calcTemperatureDifference(SystemInterface system)
      Calculates the temperature difference between the outlet and inlet of the system.

      Uses the analytical solution for a pipe with constant wall temperature (like a heat exchanger):

      T_out = T_wall + (T_in - T_wall) * exp(-U * A / (m_dot * Cp))
      

      This is derived from the energy balance dQ = U*(T-Ts)*dA = -m_dot*Cp*dT integrated along the pipe length.

      Parameters:
      system - the thermodynamic system for which the temperature difference is to be calculated
      Returns:
      the temperature difference between the outlet and inlet (negative for cooling)
    • calcHeatBalance

      public double calcHeatBalance(double enthalpy, SystemInterface system, ThermodynamicOperations testOps)
      Calculates the heat balance for the given system.

      This method calculates the enthalpy change due to:

      • Wall heat transfer (LMTD method) - when not adiabatic
      • Joule-Thomson effect - cooling/heating due to pressure change (calculated from thermodynamics)
      • Friction heating - viscous dissipation

      The final PHflash operation determines the equilibrium state at the new enthalpy and pressure, which inherently accounts for heat of vaporization/condensation in two-phase flow. Phase changes (liquid evaporation or vapor condensation) are properly handled through the enthalpy balance.

      Parameters:
      enthalpy - the initial enthalpy of the system
      system - the thermodynamic system for which the heat balance is to be calculated
      testOps - the thermodynamic operations to be performed
      Returns:
      the calculated enthalpy after performing the heat balance
    • setIncludeJouleThomsonEffect

      public void setIncludeJouleThomsonEffect(boolean include)
      Sets whether to include Joule-Thomson effect in energy calculations.

      The Joule-Thomson effect accounts for temperature change during gas expansion. For natural gas, this typically results in cooling during pressure drop. The JT coefficient is automatically calculated from the gas phase thermodynamics using NeqSim's rigorous equation of state, providing accurate values for the actual fluid composition and conditions.

      Typical Joule-Thomson coefficients (calculated automatically):

      • Methane: ~4×10⁻⁶ K/Pa (0.4 K/bar)
      • Natural gas: 3-5×10⁻⁶ K/Pa
      • CO2: ~10⁻⁵ K/Pa (1 K/bar)
      Parameters:
      include - true to include JT effect, false otherwise
    • isIncludeJouleThomsonEffect

      public boolean isIncludeJouleThomsonEffect()
      Gets whether Joule-Thomson effect is included in energy calculations.

      When enabled, the energy equation accounts for temperature change due to gas expansion, typically resulting in cooling for natural gas flows. The JT coefficient is automatically calculated from the gas phase thermodynamics.

      Returns:
      true if JT effect is included in the energy balance
      See Also:
    • setIncludeFrictionHeating

      public void setIncludeFrictionHeating(boolean include)
      Sets whether to include friction heating in energy calculations.

      Friction heating accounts for viscous dissipation, where mechanical energy lost to friction is converted to thermal energy in the fluid. The heat added is calculated as: Q_friction = ΔP_friction × Q_volumetric

      For typical pipeline conditions, friction heating is a small effect (typically 0.01-0.1 K per bar of friction pressure drop) compared to wall heat transfer or Joule-Thomson cooling. However, for high-velocity or long pipelines, it may become significant.

      Parameters:
      include - true to include friction heating, false otherwise
    • isIncludeFrictionHeating

      public boolean isIncludeFrictionHeating()
      Gets whether friction heating is included in energy calculations.

      When enabled, the energy equation accounts for viscous dissipation, where friction pressure losses are converted to thermal energy in the fluid.

      Returns:
      true if friction heating is included in the energy balance
      See Also:
    • initializeTransientState

      private void initializeTransientState(UUID id)
    • ensureTransientState

      private void ensureTransientState(UUID id)
    • calcTransientFrictionPressureDrop

      private double calcTransientFrictionPressureDrop(double velocity, double density, double viscosity, double segmentLength)
      Calculates friction pressure drop for transient simulation. Uses simplified correlations that don't depend on steady-state flow regime detection.
      Parameters:
      velocity - mixture velocity in m/s
      density - mixture density in kg/m3
      viscosity - mixture viscosity in Pa.s (not cP)
      segmentLength - length of segment in m
      Returns:
      friction pressure drop in bar
    • calcTransientHydrostaticPressureDrop

      private double calcTransientHydrostaticPressureDrop(double density, double elevationChange)
      Calculates hydrostatic pressure drop for transient simulation.
      Parameters:
      density - mixture density in kg/m3
      elevationChange - elevation change in m (positive = uphill)
      Returns:
      hydrostatic pressure drop in bar
    • runTransient

      public void runTransient(double dt, UUID id)

      runTransient

      This method calculates thermodynamic and unit operations using difference equations if available and calculateSteadyState is true. Use setCalculateSteadyState to set the parameter. Sets calc identifier UUID.
      Specified by:
      runTransient in interface SimulationInterface
      Overrides:
      runTransient in class Pipeline
      Parameters:
      dt - Delta time [s]
      id - Calculation identifier
    • displayResult

      public void displayResult()

      displayResult.

      Specified by:
      displayResult in interface ProcessEquipmentInterface
      Overrides:
      displayResult in class Pipeline
    • getInletSuperficialVelocity

      public double getInletSuperficialVelocity()

      getInletSuperficialVelocity.

      Returns:
      a double
    • getHeatTransferCoefficient

      public double getHeatTransferCoefficient()
      Getter for the field heatTransferCoefficient.
      Returns:
      the heat transfer coefficient
    • getOutletSuperficialVelocity

      public double getOutletSuperficialVelocity()

      getOutletSuperficialVelocity.

      Returns:
      a double
    • getNumberOfIncrements

      public int getNumberOfIncrements()

      getNumberOfIncrements.

      Returns:
      a double
    • getAngle

      public double getAngle()

      Getter for the field angle.

      Returns:
      angle in degrees
    • getLength

      public double getLength()

      Getter for the field length.

      Returns:
      total length of the pipe in m
    • getElevation

      public double getElevation()

      Getter for the field elevation.

      Returns:
      total elevation of the pipe in m
    • getDiameter

      public double getDiameter()

      getDiameter.

      Returns:
      the diameter
    • getFlowRegime

      public PipeBeggsAndBrills.FlowRegime getFlowRegime()

      getFlowRegime.

      Returns:
      flow regime
    • getLastSegmentPressureDrop

      public double getLastSegmentPressureDrop()

      Getter for the field LastSegmentPressureDrop.

      Returns:
      pressure drop last segment
    • getPressureDrop

      public double getPressureDrop()

      Getter for the field totalPressureDrop.

      Returns:
      total pressure drop
    • getPressureProfile

      public List<Double> getPressureProfile()

      Getter for the field PressureProfile.

      Returns:
      a list double
    • getSegmentPressure

      public Double getSegmentPressure(int index)

      getSegmentPressure.

      Parameters:
      index - segment number
      Returns:
      segment pressure as double
    • getPressureDropProfile

      public List<Double> getPressureDropProfile()
      Get Pressure drop profile.
      Returns:
      ArrayList of pressure drop profile.
    • getSegmentPressureDrop

      public Double getSegmentPressureDrop(int index)

      getSegmentPressureDrop.

      Parameters:
      index - segment number
      Returns:
      Double
    • getTemperatureProfile

      public List<Double> getTemperatureProfile()

      Getter for the field temperatureProfile.

      Returns:
      list of temperatures
    • getSegmentTemperature

      public Double getSegmentTemperature(int index)

      getSegmentTemperature.

      Parameters:
      index - segment number
      Returns:
      Double
    • getFlowRegimeProfile

      public List<PipeBeggsAndBrills.FlowRegime> getFlowRegimeProfile()

      Getter for the field flowRegimeProfile.

      Returns:
      list of flow regime names
    • getSegmentFlowRegime

      public PipeBeggsAndBrills.FlowRegime getSegmentFlowRegime(int index)

      getSegmentFlowRegime.

      Parameters:
      index - segment number
      Returns:
      String
    • getLiquidSuperficialVelocityProfile

      public List<Double> getLiquidSuperficialVelocityProfile()

      Getter for the field liquidSuperficialVelocityProfile.

      Returns:
      list of liquid superficial velocity profile
    • getGasSuperficialVelocityProfile

      public List<Double> getGasSuperficialVelocityProfile()

      Getter for the field gasSuperficialVelocityProfile.

      Returns:
      list of gas superficial velocities
    • getMixtureSuperficialVelocityProfile

      public List<Double> getMixtureSuperficialVelocityProfile()

      Getter for the field mixtureSuperficialVelocityProfile.

      Returns:
      list of mixture superficial velocity profile
    • getMixtureViscosityProfile

      public List<Double> getMixtureViscosityProfile()

      Getter for the field mixtureViscosityProfile.

      Returns:
      list of mixture viscosity
    • getMixtureDensityProfile

      public List<Double> getMixtureDensityProfile()

      Getter for the field mixtureDensityProfile.

      Returns:
      list of density profile
    • getLiquidDensityProfile

      public List<Double> getLiquidDensityProfile()

      Getter for the field liquidDensityProfile.

      Returns:
      a List object
    • getLiquidHoldupProfile

      public List<Double> getLiquidHoldupProfile()

      Getter for the field liquidHoldupProfile.

      Returns:
      list of hold-up
    • getMixtureReynoldsNumber

      public List<Double> getMixtureReynoldsNumber()

      Getter for the field mixtureReynoldsNumber.

      Returns:
      list of reynold numbers
    • getLengthProfile

      public List<Double> getLengthProfile()

      Getter for the field lengthProfile.

      Returns:
      list of length profile
    • getIncrementsProfile

      public List<Integer> getIncrementsProfile()

      Getter for the field incrementsProfile.

      Returns:
      list of increments profile
    • getElevationProfile

      public List<Double> getElevationProfile()

      Getter for the field elevationProfile.

      Returns:
      list of elevation profile
    • getSegmentLiquidSuperficialVelocity

      public Double getSegmentLiquidSuperficialVelocity(int index)

      getSegmentLiquidSuperficialVelocity.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentGasSuperficialVelocity

      public Double getSegmentGasSuperficialVelocity(int index)

      getSegmentGasSuperficialVelocity.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentMixtureSuperficialVelocity

      public Double getSegmentMixtureSuperficialVelocity(int index)

      getSegmentMixtureSuperficialVelocity.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentMixtureViscosity

      public Double getSegmentMixtureViscosity(int index)

      getSegmentMixtureViscosity.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentMixtureDensity

      public Double getSegmentMixtureDensity(int index)

      getSegmentMixtureDensity.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentLiquidDensity

      public Double getSegmentLiquidDensity(int index)

      getSegmentLiquidDensity.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentLiquidHoldup

      public Double getSegmentLiquidHoldup(int index)

      getSegmentLiquidHoldup.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentMixtureReynoldsNumber

      public Double getSegmentMixtureReynoldsNumber(int index)

      getSegmentMixtureReynoldsNumber.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentLength

      public Double getSegmentLength(int index)

      getSegmentLength.

      Parameters:
      index - segment number
      Returns:
      Double
    • getSegmentElevation

      public Double getSegmentElevation(int index)

      getSegmentElevation.

      Parameters:
      index - segment number
      Returns:
      Double
    • toJson

      public String toJson()

      Serializes the Process Equipment along with its state to a JSON string.

      Specified by:
      toJson in interface ProcessEquipmentInterface
      Overrides:
      toJson in class Pipeline
      Returns:
      json string.
    • toJson

      public String toJson(ReportConfig cfg)
      Serializes the Process Equipment with configurable level of detail.
      Specified by:
      toJson in interface ProcessEquipmentInterface
      Overrides:
      toJson in class Pipeline
      Parameters:
      cfg - report configuration
      Returns:
      json string