Class TransientPipe

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

public class TransientPipe extends TwoPortEquipment implements PipeLineInterface
Transient multiphase pipe model using drift-flux formulation. Implements a 1D transient multiphase flow simulator for gas-liquid flow in pipelines. The model is suitable for analyzing terrain-induced slugging, liquid accumulation, and transient pressure behavior in production pipelines, risers, and flowlines. Three-Phase Flow Support: When both oil and aqueous (water) phases are present, the model automatically calculates volume-weighted average liquid properties (density, viscosity, enthalpy, sound speed) based on the individual phase volumes from the thermodynamic flash. This maintains the drift-flux framework while properly accounting for oil-water mixtures.

Features

  • Drift-flux model for gas-liquid slip (Zuber-Findlay formulation)
  • Mechanistic flow regime detection (Taitel-Dukler, Barnea)
  • Three-phase gas-oil-water flow with volume-weighted liquid property averaging
  • Liquid accumulation tracking at terrain low points
  • Lagrangian slug tracking for terrain-induced slugging
  • Integration with NeqSim thermodynamics (SRK, PR, CPA equations of state)
  • AUSM+ numerical flux scheme with adaptive CFL-based time stepping

Basic Usage

// Create two-phase fluid
SystemInterface fluid = new SystemSrkEos(300, 50);
fluid.addComponent("methane", 0.8);
fluid.addComponent("n-pentane", 0.2);
fluid.setMixingRule("classic");
fluid.setMultiPhaseCheck(true);

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

// Create and configure transient pipe
TransientPipe pipe = new TransientPipe("Pipeline", inlet);
pipe.setLength(1000); // 1000 m total length
pipe.setDiameter(0.2); // 200 mm inner diameter
pipe.setNumberOfSections(50); // 50 computational cells
pipe.setMaxSimulationTime(60); // 60 seconds simulation

// Run simulation
pipe.run();

// Access results
double[] pressures = pipe.getPressureProfile();
double[] holdups = pipe.getLiquidHoldupProfile();

Terrain Pipeline Example

TransientPipe pipe = new TransientPipe("TerrainPipe", inlet);
pipe.setLength(2000);
pipe.setDiameter(0.3);
pipe.setNumberOfSections(40);

// Define elevation profile with low point
double[] elevations = new double[40];
for (int i = 0; i < 40; i++) {
  double x = i * 50.0;
  if (x < 500)
    elevations[i] = 0;
  else if (x < 1000)
    elevations[i] = -20 * (x - 500) / 500;
  else if (x < 1500)
    elevations[i] = -20 + 20 * (x - 1000) / 500;
  else
    elevations[i] = 0;
}
pipe.setElevationProfile(elevations);

pipe.run();

// Check liquid accumulation
LiquidAccumulationTracker accumTracker = pipe.getAccumulationTracker();
for (AccumulationZone zone : accumTracker.getAccumulationZones()) {
  System.out.println("Accumulation at: " + zone.getPosition() + " m");
}

Physical Model

The drift-flux model relates gas velocity to mixture velocity:
v_G = C₀ · v_m + v_d
where C₀ is the distribution coefficient (typically 1.0-1.2) and v_d is the drift velocity. Flow regime-dependent correlations from Bendiksen (1984) and Harmathy (1960) provide closure.

Numerical Method

The model solves conservation equations using an explicit finite volume scheme with AUSM+ flux splitting. Time stepping is adaptive based on CFL condition for numerical stability.

References

  • Taitel, Y. and Dukler, A.E. (1976) - AIChE Journal 22(1)
  • Barnea, D. (1987) - Int. J. Multiphase Flow 13(1)
  • Bendiksen, K.H. (1984) - Int. J. Multiphase Flow 10(4)
  • Zuber, N. and Findlay, J.A. (1965) - J. Heat Transfer 87(4)
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • logger

      private static final org.apache.logging.log4j.Logger logger
    • GRAVITY

      private static final double GRAVITY
      See Also:
    • length

      private double length
    • diameter

      private double diameter
    • roughness

      private double roughness
    • numberOfSections

      private int numberOfSections
    • wallThickness

      private double wallThickness
    • pipeElasticity

      private double pipeElasticity
    • elevationProfile

      private double[] elevationProfile
    • inclinationProfile

      private double[] inclinationProfile
    • sections

      private PipeSection[] sections
    • dx

      private double dx
    • simulationTime

      private double simulationTime
    • maxSimulationTime

      private double maxSimulationTime
    • dt

      private double dt
    • cflNumber

      private double cflNumber
    • minTimeStep

      private double minTimeStep
    • maxTimeStep

      private double maxTimeStep
    • flowRegimeDetector

      private FlowRegimeDetector flowRegimeDetector
    • driftFluxModel

      private DriftFluxModel driftFluxModel
    • accumulationTracker

      private LiquidAccumulationTracker accumulationTracker
    • slugTracker

      private SlugTracker slugTracker
    • inletBCType

      private TransientPipe.BoundaryCondition inletBCType
    • outletBCType

      private TransientPipe.BoundaryCondition outletBCType
    • inletPressureValue

      private double inletPressureValue
    • outletPressureValue

      private double outletPressureValue
    • outletPressureExplicitlySet

      private boolean outletPressureExplicitlySet
    • inletMassFlow

      private double inletMassFlow
    • outletMassFlow

      private double outletMassFlow
    • includeHeatTransfer

      private boolean includeHeatTransfer
    • ambientTemperature

      private double ambientTemperature
    • overallHeatTransferCoeff

      private double overallHeatTransferCoeff
    • jouleThomsonCoeff

      private double jouleThomsonCoeff
    • referenceFluid

      private SystemInterface referenceFluid
    • updateThermodynamics

      private boolean updateThermodynamics
    • thermodynamicUpdateInterval

      private int thermodynamicUpdateInterval
    • currentStep

      private int currentStep
    • pressureProfile

      private double[] pressureProfile
    • temperatureProfile

      private double[] temperatureProfile
    • liquidHoldupProfile

      private double[] liquidHoldupProfile
    • gasVelocityProfile

      private double[] gasVelocityProfile
    • liquidVelocityProfile

      private double[] liquidVelocityProfile
    • pressureHistory

      private double[][] pressureHistory
    • historyInterval

      private int historyInterval
    • historyIndex

      private int historyIndex
    • massResidual

      private double massResidual
    • energyResidual

      private double energyResidual
    • isConverged

      private boolean isConverged
    • totalTimeSteps

      private int totalTimeSteps
    • mechanicalDesignCalculator

      private transient PipeMechanicalDesignCalculator mechanicalDesignCalculator
    • designPressure

      private double designPressure
    • designTemperature

      private double designTemperature
    • materialGrade

      private String materialGrade
    • designCode

      private String designCode
    • locationClass

      private int locationClass
    • corrosionAllowance

      private double corrosionAllowance
    • pipeMaterial

      private String pipeMaterial
      Pipe material.
    • pipeSchedule

      private String pipeSchedule
      Pipe schedule.
    • pipeWallConductivity

      private double pipeWallConductivity
      Pipe wall thermal conductivity in W/(m·K).
    • insulationThickness

      private double insulationThickness
      Insulation thickness in meters.
    • insulationConductivity

      private double insulationConductivity
      Insulation thermal conductivity in W/(m·K).
    • insulationType

      private String insulationType
      Insulation type.
    • coatingThickness

      private double coatingThickness
      Coating thickness in meters.
    • coatingConductivity

      private double coatingConductivity
      Coating thermal conductivity in W/(m·K).
    • innerHeatTransferCoefficient

      private double innerHeatTransferCoefficient
      Inner heat transfer coefficient.
    • outerHeatTransferCoefficient

      private double outerHeatTransferCoefficient
      Outer heat transfer coefficient.
    • burialDepth

      private double burialDepth
      Burial depth in meters.
    • soilConductivity

      private double soilConductivity
      Soil thermal conductivity.
    • buried

      private boolean buried
      Flag for buried pipe.
  • Constructor Details

    • TransientPipe

      public TransientPipe()
      Default constructor. Creates a TransientPipe with default name "TransientPipe".
    • TransientPipe

      public TransientPipe(String name)
      Constructor with name.
      Parameters:
      name - Pipe name used for identification in process systems
    • TransientPipe

      public TransientPipe(String name, StreamInterface inletStream)
      Constructor with name and inlet stream. This is the recommended constructor for typical usage. The inlet stream provides initial conditions (composition, temperature, pressure, flow rate) for the simulation.
      Parameters:
      name - Pipe name used for identification in process systems
      inletStream - Inlet stream containing fluid properties and flow conditions
  • Method Details

    • initializeSubModels

      private void initializeSubModels()
      Initialize sub-models for flow regime detection, drift-flux, and slug tracking.
    • initializePipe

      public void initializePipe()
      Initialize the discretized pipe sections. Creates the computational mesh based on pipe length and number of sections. Also initializes elevation/inclination profiles and identifies low points for liquid accumulation tracking. This method is called automatically by run() if sections have not been initialized. It can also be called explicitly to inspect the mesh before running. Note: The number of sections determines spatial resolution. For accurate slug tracking, use at least 20 sections. Typical guideline: dx ≈ 10-50 pipe diameters.
    • initializeFromStream

      private void initializeFromStream()
      Initialize pipe state from inlet stream.
    • run

      public void run()
      Run the transient simulation.
      Specified by:
      run in interface Runnable
      Specified by:
      run in interface SimulationInterface
    • run

      public void run(UUID id)
      Run with calculation identifier.
      Specified by:
      run in interface SimulationInterface
      Parameters:
      id - Calculation identifier
    • runTransient

      public void runTransient(double dt, UUID id)
      Run transient simulation for a specified time step. This method advances the pipe simulation by the specified time step dt, making it suitable for use within a ProcessSystem.runTransient(double, java.util.UUID) loop. Unlike run(), which runs the complete simulation to maxSimulationTime, this method performs incremental time-stepping that can be coordinated with other equipment. On the first call, the pipe is initialized from the inlet stream. Subsequent calls advance the simulation state incrementally. The method uses adaptive sub-stepping internally to maintain numerical stability (CFL condition) while advancing by the requested dt. Usage Example:
      ProcessSystem process = new ProcessSystem();
      process.add(inlet);
      process.add(transientPipe);
      process.add(separator);
      process.run(); // Initial steady state
      
      // Transient loop
      for (int i = 0; i < 100; i++) {
        // Optionally change inlet conditions here
        process.runTransient(1.0); // Advance 1 second
        System.out.println("Outlet pressure: " + separator.getGasOutStream().getPressure());
      }
      
      Note: The inlet stream conditions are re-read at each call, allowing dynamic boundary conditions. If the inlet flow rate or composition changes, the pipe simulation will respond accordingly.
      Specified by:
      runTransient in interface SimulationInterface
      Parameters:
      dt - Time step to advance in seconds. The method will use internal sub-stepping if required for numerical stability.
      id - Calculation identifier for tracking
      See Also:
    • updateInletFromStream

      private void updateInletFromStream()
      Update inlet boundary conditions from the current inlet stream state. This method is called during runTransient(double, UUID) to capture any changes in the inlet stream conditions (flow rate, pressure, composition) that may have occurred since the last time step.
    • updateOutletFromStream

      private void updateOutletFromStream()
      Updates the outlet boundary conditions from the current outlet stream state. This method is called during runTransient(double, UUID) to capture any changes in the outlet stream conditions when using CONSTANT_FLOW outlet boundary condition. This allows external controllers or other process equipment to set the outlet flow rate on the outlet stream, which is then read back into the pipe model.
    • calculateTimeStep

      private double calculateTimeStep()
      Calculate adaptive time step based on CFL condition.

      Uses the full eigenvalue structure for hyperbolic systems. The characteristic wave speeds for multiphase flow are approximately |u ± c| where u is the mixture velocity and c is the mixture sound speed. We take the maximum of all four wave speeds: |u_G + c|, |u_G - c|, |u_L + c|, |u_L - c| to ensure stability for both forward and backward propagating waves.

      Returns:
      time step (s)
    • advanceTimeStep

      private void advanceTimeStep(double dt)
      Advance solution by one time step using finite volume method.
      Parameters:
      dt - time step (s)
    • getMassFlowForPressureProfile

      private double getMassFlowForPressureProfile()
      Get the controlling mass flow rate for pressure profile calculation. Returns the appropriate mass flow rate based on boundary conditions:
      • CONSTANT_FLOW inlet: use inlet mass flow
      • CONSTANT_FLOW outlet: use outlet mass flow
      • Both CONSTANT_PRESSURE: use inlet mass flow as fallback
      Returns:
      Mass flow rate in kg/s
    • updateBoundaryPressures

      private void updateBoundaryPressures()
      Update pressure at boundary sections only to maintain boundary condition consistency.

      Interior section pressures are computed from the momentum equation to preserve momentum conservation. Only boundary-adjacent sections are updated to ensure proper pressure gradient at boundaries.

    • updatePressureProfile

      private void updatePressureProfile()
      Update pressure profile based on friction and gravity pressure gradients.

      Legacy method: Marches from inlet to outlet (or outlet to inlet), computing pressure drop in each cell based on the local friction and gravity gradients. This ensures the pressure profile is consistent with the flow. For single-phase flow, uses the direct Darcy-Weisbach calculation.

      Note: This method is preserved for compatibility but is no longer called in transient mode to avoid overriding momentum-conserving pressure from the conservative solver.

    • calculateFluxes

      private double[][] calculateFluxes(PipeSection[] oldSections)
      Calculate fluxes at cell interfaces using AUSM+ scheme. For interior interfaces, the AUSM+ upwind scheme is used. For boundary interfaces, the fluxes are set according to the boundary conditions to ensure mass and momentum conservation:
      • CONSTANT_FLOW: Flux is set to the specified mass flow rate
      • CONSTANT_PRESSURE: Flux is computed from the AUSM scheme
      • CLOSED: Zero flux
      Parameters:
      oldSections - array of pipe sections from the previous time step
      Returns:
      2D array of fluxes [section][conserved variable index]
    • calculateAUSMFlux

      private double[] calculateAUSMFlux(PipeSection left, PipeSection right)
      Calculate AUSM+ numerical flux at interface.
      Parameters:
      left - left pipe section
      right - right pipe section
      Returns:
      flux array [mass_L, mass_G, momentum_L, momentum_G]
    • splitMachPlus

      private double splitMachPlus(double M)
    • splitMachMinus

      private double splitMachMinus(double M)
    • splitPressurePlus

      private double splitPressurePlus(double M, double p)
    • splitPressureMinus

      private double splitPressureMinus(double M, double p)
    • addSourceTerms

      private void addSourceTerms(double[] U, PipeSection section, double dt)
      Add source terms (gravity and friction) to the momentum equation. The momentum equation in conservative form is:
      ∂(ρu)/∂t + ∂(ρu² + p)/∂x = -ρg sin(θ) - τ_w/A
      
      Where the source terms are:
      • Gravity: S_g = -ρ_m · g · sin(θ) [kg/(m²·s²)]
      • Friction: S_f = -dP/dx_friction [kg/(m²·s²)]
      These are integrated as: U[2]_new = U[2]_old + S × dt
      Parameters:
      U - conserved variable array to be modified in-place
      section - pipe section for which to calculate source terms
      dt - time step size in seconds
    • updatePrimitiveVariables

      private void updatePrimitiveVariables(PipeSection section, PipeSection oldSection, double[] U, int sectionIndex, double dt, double momentumFluxLeft, double momentumFluxRight)
      Update primitive variables from conservative variables.

      This method converts from conservative variables (densities, momentum, energy) back to primitive variables (holdups, velocities, temperature, pressure). Interior cell pressures are computed from the momentum equation residual to properly capture acoustic wave propagation.

      Parameters:
      section - Current section to update
      oldSection - Previous time step section state
      U - Conservative variables [ρ_G·α_G, ρ_L·α_L, ρ_m·u, ρ_m·E]
      sectionIndex - Index of this section (0 to numberOfSections-1)
      dt - Time step (s)
      momentumFluxLeft - Momentum flux at left face (Pa)
      momentumFluxRight - Momentum flux at right face (Pa)
    • applyBoundaryConditions

      private void applyBoundaryConditions()
      Apply boundary conditions.
    • updateFlowRegimes

      private void updateFlowRegimes()
      Update flow regimes for all sections.
    • checkTerrainSlugging

      private void checkTerrainSlugging()
      Check for terrain-induced slugging.
    • updateThermodynamicProperties

      private void updateThermodynamicProperties()
      Update thermodynamic properties using NeqSim flash.
    • checkConvergence

      private void checkConvergence()
      Check for steady-state convergence.
    • storeResults

      private void storeResults()
      Store current results.
    • storeHistory

      private void storeHistory()
      Store pressure history for time series analysis.
    • updateOutletStream

      private void updateOutletStream()
      Update outlet stream with final conditions including flow rate. This method updates the outlet stream with:
      • Pressure from the outlet pipe section
      • Temperature from the outlet pipe section
      • Mass flow rate calculated from outlet section velocity and density
      The flow rate is computed directly from the conservation equations to maintain mass balance. During slug flow, the increased liquid holdup naturally increases the outlet density, which is reflected in the mass flow calculation.
    • getName

      public String getName()
      Description copied from class: NamedBaseClass

      Getter for the field name.

      Specified by:
      getName in interface NamedInterface
      Overrides:
      getName in class NamedBaseClass
      Returns:
      a String object
    • setName

      public void setName(String name)
      Description copied from class: NamedBaseClass

      Setter for the field name.

      Specified by:
      setName in interface NamedInterface
      Overrides:
      setName in class NamedBaseClass
      Parameters:
      name - a String object
    • setLength

      public void setLength(double length)
      Set total pipe length.
      Specified by:
      setLength in interface PipeLineInterface
      Parameters:
      length - Pipe length in meters
    • getLength

      public double getLength()
      Get total pipe length.
      Specified by:
      getLength in interface PipeLineInterface
      Returns:
      Pipe length in meters
    • setDiameter

      public void setDiameter(double diameter)
      Set pipe inner diameter.
      Specified by:
      setDiameter in interface PipeLineInterface
      Parameters:
      diameter - Inner diameter in meters
    • getDiameter

      public double getDiameter()
      Get pipe inner diameter.
      Specified by:
      getDiameter in interface PipeLineInterface
      Returns:
      Inner diameter in meters
    • getRoughness

      public double getRoughness()
      Get pipe wall roughness.
      Returns:
      Wall roughness in meters
    • getWallThickness

      public double getWallThickness()
      Get pipe wall thickness.
      Specified by:
      getWallThickness in interface PipeLineInterface
      Returns:
      Wall thickness in meters
    • getPipeElasticity

      public double getPipeElasticity()
      Get pipe material elasticity (Young's modulus).
      Returns:
      Elasticity in Pascals
    • isIncludeHeatTransfer

      public boolean isIncludeHeatTransfer()
      Check if heat transfer is enabled.
      Returns:
      true if heat transfer is included in calculations
    • setIncludeHeatTransfer

      public void setIncludeHeatTransfer(boolean include)
      Enable or disable heat transfer calculations.

      When enabled, the energy equation is solved to calculate temperature changes along the pipe due to:

      • Heat transfer to/from surroundings (ambient)
      • Joule-Thomson effect (gas expansion cooling)
      • Friction heating (viscous dissipation)
      • Elevation work
      Parameters:
      include - true to enable heat transfer calculations
    • getAmbientTemperature

      public double getAmbientTemperature()
      Get the ambient temperature.
      Specified by:
      getAmbientTemperature in interface PipeLineInterface
      Returns:
      ambient temperature in Kelvin
    • setAmbientTemperature

      public void setAmbientTemperature(double temperature)
      Set the ambient temperature.
      Specified by:
      setAmbientTemperature in interface PipeLineInterface
      Parameters:
      temperature - ambient temperature in Kelvin
    • getOverallHeatTransferCoeff

      public double getOverallHeatTransferCoeff()
      Get overall heat transfer coefficient.
      Returns:
      Heat transfer coefficient in W/(m²·K)
    • setOverallHeatTransferCoeff

      public void setOverallHeatTransferCoeff(double coeff)
      Set overall heat transfer coefficient.

      The overall heat transfer coefficient U accounts for all heat transfer resistances between the fluid and surroundings. Typical values:

      • Bare steel pipe in still air: 5-10 W/(m²·K)
      • Bare steel pipe in seawater: 200-500 W/(m²·K)
      • Insulated pipe (50mm): 1-3 W/(m²·K)
      • Buried pipe: 2-5 W/(m²·K)
      Parameters:
      coeff - Heat transfer coefficient in W/(m²·K)
    • getJouleThomsonCoeff

      public double getJouleThomsonCoeff()
      Get Joule-Thomson coefficient for temperature change during gas expansion.

      Returns the JT coefficient calculated from gas phase thermodynamics. This is automatically updated during simulation based on the fluid properties.

      Typical values (at ~300K, 50 bar):

      • Methane: ~4.5e-6 K/Pa (0.45 K/MPa)
      • Natural gas: 2-6e-6 K/Pa
      • CO2: ~1e-5 K/Pa
      • Hydrogen: ~-0.3e-6 K/Pa (warms on expansion)
      • Liquids: ~1e-8 K/Pa (very small)
      Returns:
      Joule-Thomson coefficient in K/Pa
    • getMassResidual

      public double getMassResidual()
      Get mass residual from last time step.
      Returns:
      Mass balance residual
    • getEnergyResidual

      public double getEnergyResidual()
      Get energy residual from last time step.
      Returns:
      Energy balance residual
    • isConverged

      public boolean isConverged()
      Check if simulation has converged.
      Returns:
      true if converged to steady-state
    • setRoughness

      public void setRoughness(double roughness)
      Set pipe wall roughness. Used for friction factor calculation. Typical values:
      • New steel pipe: 0.00004 m (40 μm)
      • Used steel pipe: 0.0001 m (100 μm)
      • Corroded pipe: 0.0003 m (300 μm)
      Parameters:
      roughness - Wall roughness in meters
    • setNumberOfSections

      public void setNumberOfSections(int n)
      Set number of computational cells (sections). More sections provide higher spatial resolution but require more computation. Guideline: dx ≈ 10-50 pipe diameters. For slug tracking, use at least 20 sections.
      Parameters:
      n - Number of sections
    • setElevationProfile

      public void setElevationProfile(double[] profile)
      Set elevation profile along the pipe. Array of elevations (meters) at each section node. The array length should match the number of sections. Positive values indicate upward elevation. Example:
      double[] elevations = new double[50];
      for (int i = 0; i < 50; i++) {
        elevations[i] = 10 * Math.sin(i * Math.PI / 49); // Terrain with low point
      }
      pipe.setElevationProfile(elevations);
      
      Parameters:
      profile - Array of elevations in meters
    • setInclinationProfile

      public void setInclinationProfile(double[] profile)
      Set inclination profile along the pipe. Array of inclination angles (radians) at each section. Positive values indicate upward inclination. Use this instead of elevation profile for constant-inclination sections.
      Parameters:
      profile - Array of inclination angles in radians
    • setMaxSimulationTime

      public void setMaxSimulationTime(double time)
      Set maximum simulation time. The simulation runs until this time is reached or steady-state is achieved.
      Parameters:
      time - Maximum simulation time in seconds
    • getSimulationTime

      public double getSimulationTime()
      Get current simulation time.
      Returns:
      Simulation time in seconds
    • setInletBoundaryCondition

      public void setInletBoundaryCondition(TransientPipe.BoundaryCondition bc)
      Set inlet boundary condition type.
      Parameters:
      bc - Boundary condition type
      See Also:
    • setOutletBoundaryCondition

      public void setOutletBoundaryCondition(TransientPipe.BoundaryCondition bc)
    • setinletPressureValue

      @Deprecated public void setinletPressureValue(double pressure)
      Deprecated.
      Set the inlet pressure value.
      Parameters:
      pressure - Inlet pressure in bara (bar absolute)
    • setInletPressure

      public void setInletPressure(double pressure)
      Set the inlet pressure value.
      Specified by:
      setInletPressure in interface TwoPortInterface
      Overrides:
      setInletPressure in class TwoPortEquipment
      Parameters:
      pressure - Inlet pressure in bara (bar absolute)
    • setoutletPressureValue

      @Deprecated public void setoutletPressureValue(double pressure)
      Deprecated.
      Set the outlet pressure value.
      Parameters:
      pressure - Outlet pressure in bara (bar absolute)
    • setOutletPressure

      public void setOutletPressure(double pressure)
      Set the outlet pressure value.
      Specified by:
      setOutletPressure in interface PipeLineInterface
      Specified by:
      setOutletPressure in interface TwoPortInterface
      Overrides:
      setOutletPressure in class TwoPortEquipment
      Parameters:
      pressure - Outlet pressure in bara (bar absolute)
    • setInletMassFlow

      public void setInletMassFlow(double flow)
    • setOutletMassFlow

      public void setOutletMassFlow(double flow)
      Set the outlet mass flow rate. Use this when the outlet flow is controlled by downstream equipment (e.g., a valve). When using CONSTANT_FLOW outlet boundary condition, this value is used to calculate the pressure profile and outlet stream properties. This can be called before each runTransient() call to update the outlet flow from downstream valve Cv calculations.
      Parameters:
      flow - Outlet mass flow rate in kg/s
    • getOutletMassFlow

      public double getOutletMassFlow()
      Get the current outlet mass flow rate.
      Returns:
      Outlet mass flow rate in kg/s
    • setInletStream

      public void setInletStream(StreamInterface stream)
      Description copied from class: TwoPortEquipment
      Set inlet Stream of twoport.
      Specified by:
      setInletStream in interface TwoPortInterface
      Overrides:
      setInletStream in class TwoPortEquipment
      Parameters:
      stream - value to set
    • getOutletStream

      public StreamInterface getOutletStream()
      Description copied from class: TwoPortEquipment
      Get outlet Stream of twoport.
      Specified by:
      getOutletStream in interface TwoPortInterface
      Overrides:
      getOutletStream in class TwoPortEquipment
      Returns:
      outlet Stream of TwoPortEquipment
    • setOutletStream

      public void setOutletStream(StreamInterface stream)
      Description copied from class: TwoPortEquipment
      Set outlet Stream of twoport.
      Specified by:
      setOutletStream in interface TwoPortInterface
      Overrides:
      setOutletStream in class TwoPortEquipment
      Parameters:
      stream - value to set
    • getPressureProfile

      public double[] getPressureProfile()
      Get the pressure profile along the pipe.
      Specified by:
      getPressureProfile in interface PipeLineInterface
      Returns:
      array of pressures in bar at each increment
    • getTemperatureProfile

      public double[] getTemperatureProfile()
      Get temperature profile at end of simulation.
      Specified by:
      getTemperatureProfile in interface PipeLineInterface
      Returns:
      Array of temperatures (K) at each section, or null if not run
    • getLiquidHoldupProfile

      public double[] getLiquidHoldupProfile()
      Get liquid holdup profile at end of simulation. Liquid holdup (α_L) is the fraction of pipe cross-section occupied by liquid. Values range from 0 (all gas) to 1 (all liquid).
      Specified by:
      getLiquidHoldupProfile in interface PipeLineInterface
      Returns:
      Array of liquid holdups (dimensionless) at each section, or null if not run
    • getGasVelocityProfile

      public double[] getGasVelocityProfile()
      Get gas velocity profile at end of simulation.
      Returns:
      Array of gas velocities (m/s) at each section, or null if not run
    • getLiquidVelocityProfile

      public double[] getLiquidVelocityProfile()
      Get liquid velocity profile at end of simulation.
      Returns:
      Array of liquid velocities (m/s) at each section, or null if not run
    • getPressureHistory

      public double[][] getPressureHistory()
      Get pressure history over simulation time. The history is stored at intervals specified by historyInterval. The array dimensions are [time_index][position_index].
      Returns:
      2D array of pressures (Pa), or null if not run
    • getSections

      public PipeSection[] getSections()
      Get all pipe sections with their state variables. Each section contains detailed state information including pressure, temperature, holdups, velocities, flow regime, and other properties.
      Returns:
      Array of PipeSection objects
    • getSlugTracker

      public SlugTracker getSlugTracker()
      Get the slug tracker for detailed slug analysis. The slug tracker contains information about active slugs, slug statistics, and slug history. Example:
      SlugTracker tracker = pipe.getSlugTracker();
      int slugCount = tracker.getSlugCount();
      double avgLength = tracker.getAverageSlugLength();
      String stats = tracker.getStatisticsString();
      
      Returns:
      SlugTracker instance
    • getAccumulationTracker

      public LiquidAccumulationTracker getAccumulationTracker()
      Get the liquid accumulation tracker. Tracks liquid pooling at terrain low points. Useful for identifying potential liquid loading and slug initiation locations. Example:
      LiquidAccumulationTracker tracker = pipe.getAccumulationTracker();
      for (AccumulationZone zone : tracker.getAccumulationZones()) {
        System.out.println("Low point at: " + zone.getPosition());
        System.out.println("Accumulated: " + zone.getAccumulatedVolume() + " m3");
      }
      
      Returns:
      LiquidAccumulationTracker instance
    • getTotalTimeSteps

      public int getTotalTimeSteps()
      Get total number of time steps taken during simulation.
      Returns:
      Number of time steps
    • setCflNumber

      public void setCflNumber(double cfl)
      Set CFL number for adaptive time stepping. The CFL (Courant-Friedrichs-Lewy) number controls the time step size relative to the grid spacing and wave speeds. Lower values (0.3-0.5) provide more stability but slower simulation. Higher values (0.7-0.9) are faster but may become unstable.
      Parameters:
      cfl - CFL number, clamped to range [0.1, 1.0]
    • setThermodynamicUpdateInterval

      public void setThermodynamicUpdateInterval(int interval)
      Set interval for thermodynamic property updates. Flash calculations are computationally expensive. This setting controls how often phase properties are recalculated. Higher values improve performance but may reduce accuracy for rapidly changing conditions.
      Parameters:
      interval - Update interval (number of time steps), minimum 1
    • setUpdateThermodynamics

      public void setUpdateThermodynamics(boolean update)
      Enable or disable thermodynamic updates during simulation. When disabled, phase properties remain constant at initial values. This is appropriate for isothermal simulations or when temperature/pressure changes are small.
      Parameters:
      update - true to enable updates, false to disable
    • getCalculationIdentifier

      public UUID getCalculationIdentifier()
      Description copied from class: SimulationBaseClass
      Getter for property calcIdentifier.
      Specified by:
      getCalculationIdentifier in interface SimulationInterface
      Overrides:
      getCalculationIdentifier in class SimulationBaseClass
      Returns:
      Value of calcIdentifier.
    • setCalculationIdentifier

      public void setCalculationIdentifier(UUID id)
      Description copied from class: SimulationBaseClass
      Setter for property calcIdentifier.
      Specified by:
      setCalculationIdentifier in interface SimulationInterface
      Overrides:
      setCalculationIdentifier in class SimulationBaseClass
      Parameters:
      id - Value to set.
    • getPipe

      public FlowSystemInterface getPipe()
      Get the underlying flow system (for advanced models). This transient model uses internal discretization, not FlowSystemInterface.
      Specified by:
      getPipe in interface PipeLineInterface
      Returns:
      flow system interface or null if not applicable
    • setNumberOfLegs

      public void setNumberOfLegs(int number)
      Set number of pipe legs/segments.
      Specified by:
      setNumberOfLegs in interface PipeLineInterface
      Parameters:
      number - number of legs
    • setHeightProfile

      public void setHeightProfile(double[] heights)
      Set the height profile along the pipe.
      Specified by:
      setHeightProfile in interface PipeLineInterface
      Parameters:
      heights - array of heights at each leg boundary (length = numberOfLegs + 1)
    • setLegPositions

      public void setLegPositions(double[] positions)
      Set the position of each leg along the pipe.
      Specified by:
      setLegPositions in interface PipeLineInterface
      Parameters:
      positions - array of positions at each leg boundary in meters
    • setPipeDiameters

      public void setPipeDiameters(double[] diameters)
      Set pipe diameters for each segment.
      Specified by:
      setPipeDiameters in interface PipeLineInterface
      Parameters:
      diameters - array of diameters for each leg boundary
    • setPipeWallRoughness

      public void setPipeWallRoughness(double[] rough)
      Set wall roughness for each segment.
      Specified by:
      setPipeWallRoughness in interface PipeLineInterface
      Parameters:
      rough - array of roughness values for each leg
    • setOuterTemperatures

      public void setOuterTemperatures(double[] outerTemp)
      Set outer temperatures for heat transfer calculations.
      Specified by:
      setOuterTemperatures in interface PipeLineInterface
      Parameters:
      outerTemp - array of outer temperatures in Kelvin for each leg
    • setNumberOfNodesInLeg

      public void setNumberOfNodesInLeg(int number)
      Set number of computational nodes in each leg.
      Specified by:
      setNumberOfNodesInLeg in interface PipeLineInterface
      Parameters:
      number - number of nodes per leg
    • setOutputFileName

      public void setOutputFileName(String name)
      Set output file name for detailed results.
      Specified by:
      setOutputFileName in interface PipeLineInterface
      Parameters:
      name - output file name
    • setInitialFlowPattern

      public void setInitialFlowPattern(String flowPattern)
      Set initial flow pattern for simulation initialization.
      Specified by:
      setInitialFlowPattern in interface PipeLineInterface
      Parameters:
      flowPattern - initial flow pattern (e.g., "stratified", "slug")
    • getInletStream

      public StreamInterface getInletStream()
      Get inlet Stream of twoport.
      Specified by:
      getInletStream in interface TwoPortInterface
      Overrides:
      getInletStream in class TwoPortEquipment
      Returns:
      inlet Stream of TwoPortEquipment
    • setPipeWallRoughness

      public void setPipeWallRoughness(double roughness)
      Set the pipe wall roughness.
      Specified by:
      setPipeWallRoughness in interface PipeLineInterface
      Parameters:
      roughness - the wall roughness in meters
    • getPipeWallRoughness

      public double getPipeWallRoughness()
      Get the pipe wall roughness.
      Specified by:
      getPipeWallRoughness in interface PipeLineInterface
      Returns:
      the wall roughness in meters
    • setElevation

      public void setElevation(double elevation)
      Set the elevation change from inlet to outlet.
      Specified by:
      setElevation in interface PipeLineInterface
      Parameters:
      elevation - elevation change in meters (positive = uphill)
    • getElevation

      public double getElevation()
      Get the elevation change from inlet to outlet.
      Specified by:
      getElevation in interface PipeLineInterface
      Returns:
      elevation change in meters
    • setInletElevation

      public void setInletElevation(double inletElevation)
      Set the inlet elevation above reference.
      Specified by:
      setInletElevation in interface PipeLineInterface
      Parameters:
      inletElevation - inlet elevation in meters
    • getInletElevation

      public double getInletElevation()
      Get the inlet elevation above reference.
      Specified by:
      getInletElevation in interface PipeLineInterface
      Returns:
      inlet elevation in meters
    • setOutletElevation

      public void setOutletElevation(double outletElevation)
      Set the outlet elevation above reference.
      Specified by:
      setOutletElevation in interface PipeLineInterface
      Parameters:
      outletElevation - outlet elevation in meters
    • getOutletElevation

      public double getOutletElevation()
      Get the outlet elevation above reference.
      Specified by:
      getOutletElevation in interface PipeLineInterface
      Returns:
      outlet elevation in meters
    • getNumberOfLegs

      public int getNumberOfLegs()
      Get number of pipe legs/segments.
      Specified by:
      getNumberOfLegs in interface PipeLineInterface
      Returns:
      number of legs
    • setNumberOfIncrements

      public void setNumberOfIncrements(int numberOfIncrements)
      Set number of computational increments/segments.
      Specified by:
      setNumberOfIncrements in interface PipeLineInterface
      Parameters:
      numberOfIncrements - number of increments for pressure drop calculation
    • getNumberOfIncrements

      public int getNumberOfIncrements()
      Get number of computational increments/segments.
      Specified by:
      getNumberOfIncrements in interface PipeLineInterface
      Returns:
      number of increments
    • setOutPressure

      public void setOutPressure(double pressure)
      Set outlet pressure of twoport.
      Specified by:
      setOutPressure in interface PipeLineInterface
      Specified by:
      setOutPressure in interface TwoPortInterface
      Parameters:
      pressure - value to set in unit bara
    • setOutTemperature

      public void setOutTemperature(double temperature)
      Set outlet temperature of twoport.
      Specified by:
      setOutTemperature in interface PipeLineInterface
      Specified by:
      setOutTemperature in interface TwoPortInterface
      Parameters:
      temperature - value to set in kelvin
    • getPressureDrop

      public double getPressureDrop()
      Get the total pressure drop across the pipeline.
      Specified by:
      getPressureDrop in interface PipeLineInterface
      Returns:
      pressure drop in bar
    • getOutletPressure

      public double getOutletPressure(String unit)
      Get the outlet pressure.
      Specified by:
      getOutletPressure in interface PipeLineInterface
      Parameters:
      unit - pressure unit (e.g., "bara", "barg", "Pa", "MPa")
      Returns:
      outlet pressure in specified unit
    • getOutletTemperature

      public double getOutletTemperature(String unit)
      Get the outlet temperature.
      Specified by:
      getOutletTemperature in interface PipeLineInterface
      Parameters:
      unit - temperature unit (e.g., "K", "C")
      Returns:
      outlet temperature in specified unit
    • getVelocity

      public double getVelocity()
      Get the flow velocity in the pipe.
      Specified by:
      getVelocity in interface PipeLineInterface
      Returns:
      velocity in m/s
    • getSuperficialVelocity

      public double getSuperficialVelocity(int phaseNumber)
      Get the superficial velocity for a specific phase.
      Specified by:
      getSuperficialVelocity in interface PipeLineInterface
      Parameters:
      phaseNumber - phase index (0=gas, 1=liquid)
      Returns:
      superficial velocity in m/s
    • getFlowRegime

      public String getFlowRegime()
      Get the determined flow regime.
      Specified by:
      getFlowRegime in interface PipeLineInterface
      Returns:
      flow regime as string (e.g., "stratified", "slug", "annular", "dispersed bubble")
    • getLiquidHoldup

      public double getLiquidHoldup()
      Get the liquid holdup fraction.
      Specified by:
      getLiquidHoldup in interface PipeLineInterface
      Returns:
      liquid holdup as fraction (0-1)
    • getReynoldsNumber

      public double getReynoldsNumber()
      Get the Reynolds number for the flow.
      Specified by:
      getReynoldsNumber in interface PipeLineInterface
      Returns:
      Reynolds number (dimensionless)
    • getFrictionFactor

      public double getFrictionFactor()
      Get the friction factor.
      Specified by:
      getFrictionFactor in interface PipeLineInterface
      Returns:
      Darcy friction factor (dimensionless)
    • setHeatTransferCoefficient

      public void setHeatTransferCoefficient(double coefficient)
      Set the overall heat transfer coefficient.
      Specified by:
      setHeatTransferCoefficient in interface PipeLineInterface
      Parameters:
      coefficient - heat transfer coefficient in W/(m²·K)
    • getHeatTransferCoefficient

      public double getHeatTransferCoefficient()
      Get the overall heat transfer coefficient.
      Specified by:
      getHeatTransferCoefficient in interface PipeLineInterface
      Returns:
      heat transfer coefficient in W/(m²·K)
    • setConstantSurfaceTemperature

      public void setConstantSurfaceTemperature(double temperature)
      Set the constant surface temperature for heat transfer.
      Specified by:
      setConstantSurfaceTemperature in interface PipeLineInterface
      Parameters:
      temperature - surface temperature in Kelvin
    • isAdiabatic

      public boolean isAdiabatic()
      Check if the pipe is operating in adiabatic mode.
      Specified by:
      isAdiabatic in interface PipeLineInterface
      Returns:
      true if adiabatic (no heat transfer)
    • setAdiabatic

      public void setAdiabatic(boolean adiabatic)
      Set whether the pipe operates in adiabatic mode.
      Specified by:
      setAdiabatic in interface PipeLineInterface
      Parameters:
      adiabatic - true for no heat transfer
    • setPipeSpecification

      public void setPipeSpecification(double nominalDiameter, String specification)
      Set pipe specification from database.
      Specified by:
      setPipeSpecification in interface PipeLineInterface
      Parameters:
      nominalDiameter - nominal diameter in mm or inches
      specification - pipe specification code (e.g., "API 5L", "ANSI B36.10")
    • setWallThickness

      public void setWallThickness(double thickness)
      Set the pipe wall thickness.
      Specified by:
      setWallThickness in interface PipeLineInterface
      Parameters:
      thickness - wall thickness in meters
    • getAngle

      public double getAngle()
      Get the angle of the pipe from horizontal.
      Specified by:
      getAngle in interface PipeLineInterface
      Returns:
      angle in degrees (0 = horizontal, 90 = vertical upward)
    • setAngle

      public void setAngle(double angle)
      Set the angle of the pipe from horizontal.
      Specified by:
      setAngle in interface PipeLineInterface
      Parameters:
      angle - angle in degrees (0 = horizontal, 90 = vertical upward)
    • setPipeMaterial

      public void setPipeMaterial(String material)
      Set the pipe material.
      Specified by:
      setPipeMaterial in interface PipeLineInterface
      Parameters:
      material - pipe material name (e.g., "carbon steel", "stainless steel", "duplex")
    • getPipeMaterial

      public String getPipeMaterial()
      Get the pipe material.
      Specified by:
      getPipeMaterial in interface PipeLineInterface
      Returns:
      pipe material name
    • setPipeSchedule

      public void setPipeSchedule(String schedule)
      Set the pipe schedule.
      Specified by:
      setPipeSchedule in interface PipeLineInterface
      Parameters:
      schedule - pipe schedule (e.g., "40", "80", "STD", "XS")
    • getPipeSchedule

      public String getPipeSchedule()
      Get the pipe schedule.
      Specified by:
      getPipeSchedule in interface PipeLineInterface
      Returns:
      pipe schedule
    • setInsulationThickness

      public void setInsulationThickness(double thickness)
      Set the insulation thickness.
      Specified by:
      setInsulationThickness in interface PipeLineInterface
      Parameters:
      thickness - insulation thickness in meters
    • getInsulationThickness

      public double getInsulationThickness()
      Get the insulation thickness.
      Specified by:
      getInsulationThickness in interface PipeLineInterface
      Returns:
      insulation thickness in meters
    • setInsulationConductivity

      public void setInsulationConductivity(double conductivity)
      Set the insulation thermal conductivity.
      Specified by:
      setInsulationConductivity in interface PipeLineInterface
      Parameters:
      conductivity - thermal conductivity in W/(m·K)
    • getInsulationConductivity

      public double getInsulationConductivity()
      Get the insulation thermal conductivity.
      Specified by:
      getInsulationConductivity in interface PipeLineInterface
      Returns:
      thermal conductivity in W/(m·K)
    • setInsulationType

      public void setInsulationType(String insulationType)
      Set the insulation type/material.
      Specified by:
      setInsulationType in interface PipeLineInterface
      Parameters:
      insulationType - insulation type (e.g., "polyurethane", "mineral wool", "aerogel")
    • getInsulationType

      public String getInsulationType()
      Get the insulation type/material.
      Specified by:
      getInsulationType in interface PipeLineInterface
      Returns:
      insulation type
    • setCoatingThickness

      public void setCoatingThickness(double thickness)
      Set the coating thickness.
      Specified by:
      setCoatingThickness in interface PipeLineInterface
      Parameters:
      thickness - coating thickness in meters
    • getCoatingThickness

      public double getCoatingThickness()
      Get the coating thickness.
      Specified by:
      getCoatingThickness in interface PipeLineInterface
      Returns:
      coating thickness in meters
    • setCoatingConductivity

      public void setCoatingConductivity(double conductivity)
      Set the coating thermal conductivity.
      Specified by:
      setCoatingConductivity in interface PipeLineInterface
      Parameters:
      conductivity - thermal conductivity in W/(m·K)
    • getCoatingConductivity

      public double getCoatingConductivity()
      Get the coating thermal conductivity.
      Specified by:
      getCoatingConductivity in interface PipeLineInterface
      Returns:
      thermal conductivity in W/(m·K)
    • setPipeWallConductivity

      public void setPipeWallConductivity(double conductivity)
      Set the pipe wall thermal conductivity.
      Specified by:
      setPipeWallConductivity in interface PipeLineInterface
      Parameters:
      conductivity - thermal conductivity in W/(m·K)
    • getPipeWallConductivity

      public double getPipeWallConductivity()
      Get the pipe wall thermal conductivity.
      Specified by:
      getPipeWallConductivity in interface PipeLineInterface
      Returns:
      thermal conductivity in W/(m·K)
    • setOuterHeatTransferCoefficient

      public void setOuterHeatTransferCoefficient(double coefficient)
      Set the outer (external) heat transfer coefficient.

      This is the convective heat transfer coefficient between the pipe outer surface (or insulation outer surface if insulated) and the surrounding environment.

      Typical values:

      • Still air: 5-25 W/(m²·K)
      • Flowing air: 10-100 W/(m²·K)
      • Buried in soil: 1-5 W/(m²·K)
      • Still water: 100-500 W/(m²·K)
      • Flowing seawater: 500-2000 W/(m²·K)
      Specified by:
      setOuterHeatTransferCoefficient in interface PipeLineInterface
      Parameters:
      coefficient - outer heat transfer coefficient in W/(m²·K)
    • getOuterHeatTransferCoefficient

      public double getOuterHeatTransferCoefficient()
      Get the outer (external) heat transfer coefficient.
      Specified by:
      getOuterHeatTransferCoefficient in interface PipeLineInterface
      Returns:
      outer heat transfer coefficient in W/(m²·K)
    • setInnerHeatTransferCoefficient

      public void setInnerHeatTransferCoefficient(double coefficient)
      Set the inner (fluid-side) heat transfer coefficient.

      This is the convective heat transfer coefficient between the fluid and the pipe inner wall. If not set, it can be calculated automatically based on flow conditions.

      Specified by:
      setInnerHeatTransferCoefficient in interface PipeLineInterface
      Parameters:
      coefficient - inner heat transfer coefficient in W/(m²·K)
    • getInnerHeatTransferCoefficient

      public double getInnerHeatTransferCoefficient()
      Get the inner (fluid-side) heat transfer coefficient.
      Specified by:
      getInnerHeatTransferCoefficient in interface PipeLineInterface
      Returns:
      inner heat transfer coefficient in W/(m²·K)
    • setOuterHeatTransferCoefficients

      public void setOuterHeatTransferCoefficients(double[] coefficients)
      Set outer heat transfer coefficients for each pipe segment.
      Specified by:
      setOuterHeatTransferCoefficients in interface PipeLineInterface
      Parameters:
      coefficients - array of outer heat transfer coefficients in W/(m²·K)
    • setWallHeatTransferCoefficients

      public void setWallHeatTransferCoefficients(double[] coefficients)
      Set inner (wall) heat transfer coefficients for each pipe segment.
      Specified by:
      setWallHeatTransferCoefficients in interface PipeLineInterface
      Parameters:
      coefficients - array of wall heat transfer coefficients in W/(m²·K)
    • setAmbientTemperatures

      public void setAmbientTemperatures(double[] temperatures)
      Set ambient/surrounding temperatures for each pipe segment.
      Specified by:
      setAmbientTemperatures in interface PipeLineInterface
      Parameters:
      temperatures - array of ambient temperatures in Kelvin
    • calculateOverallHeatTransferCoefficient

      public double calculateOverallHeatTransferCoefficient()
      Calculate the overall heat transfer coefficient based on pipe buildup.

      This method calculates the overall U-value considering:

      • Inner fluid-side convection
      • Pipe wall conduction
      • Coating conduction (if present)
      • Insulation conduction (if present)
      • Outer convection

      The calculation uses the resistance analogy for cylindrical geometries.

      Specified by:
      calculateOverallHeatTransferCoefficient in interface PipeLineInterface
      Returns:
      overall heat transfer coefficient in W/(m²·K) based on inner diameter
    • setBurialDepth

      public void setBurialDepth(double depth)
      Set the burial depth below ground surface.
      Specified by:
      setBurialDepth in interface PipeLineInterface
      Parameters:
      depth - burial depth in meters
    • getBurialDepth

      public double getBurialDepth()
      Get the burial depth.
      Specified by:
      getBurialDepth in interface PipeLineInterface
      Returns:
      burial depth in meters
    • setSoilConductivity

      public void setSoilConductivity(double conductivity)
      Set the soil thermal conductivity.
      Specified by:
      setSoilConductivity in interface PipeLineInterface
      Parameters:
      conductivity - soil thermal conductivity in W/(m·K)
    • getSoilConductivity

      public double getSoilConductivity()
      Get the soil thermal conductivity.
      Specified by:
      getSoilConductivity in interface PipeLineInterface
      Returns:
      soil thermal conductivity in W/(m·K)
    • isBuried

      public boolean isBuried()
      Check if the pipe is buried.
      Specified by:
      isBuried in interface PipeLineInterface
      Returns:
      true if pipe is buried
    • setBuried

      public void setBuried(boolean buried)
      Set whether the pipe is buried.
      Specified by:
      setBuried in interface PipeLineInterface
      Parameters:
      buried - true if pipe is buried
    • getOrCreateCalculator

      private PipeMechanicalDesignCalculator getOrCreateCalculator()
      Get or create the mechanical design calculator.
      Returns:
      the mechanical design calculator instance
    • getMechanicalDesignCalculator

      public PipeMechanicalDesignCalculator getMechanicalDesignCalculator()
      Get the mechanical design calculator for this pipeline.

      The calculator provides standards-based calculations for:

      • Wall thickness calculation per ASME B31.3/B31.4/B31.8 or DNV-OS-F101
      • Maximum Allowable Operating Pressure (MAOP)
      • Stress analysis (hoop, longitudinal, von Mises)
      • Test pressure calculation
      Specified by:
      getMechanicalDesignCalculator in interface PipeLineInterface
      Returns:
      mechanical design calculator
    • setDesignPressure

      public void setDesignPressure(double pressure)
      Set design pressure for mechanical design calculations.
      Specified by:
      setDesignPressure in interface PipeLineInterface
      Parameters:
      pressure - design pressure in MPa
    • getDesignPressure

      public double getDesignPressure()
      Get design pressure.
      Specified by:
      getDesignPressure in interface PipeLineInterface
      Returns:
      design pressure in MPa
    • setDesignPressure

      public void setDesignPressure(double pressure, String unit)
      Set design pressure with unit.
      Specified by:
      setDesignPressure in interface PipeLineInterface
      Parameters:
      pressure - design pressure value
      unit - pressure unit ("MPa", "bar", "bara", "psi")
    • setDesignTemperature

      public void setDesignTemperature(double temperature)
      Set maximum design temperature for mechanical design.
      Specified by:
      setDesignTemperature in interface PipeLineInterface
      Parameters:
      temperature - design temperature in Celsius
    • getDesignTemperature

      public double getDesignTemperature()
      Get maximum design temperature.
      Specified by:
      getDesignTemperature in interface PipeLineInterface
      Returns:
      design temperature in Celsius
    • setMaterialGrade

      public void setMaterialGrade(String grade)
      Set the pipe material grade per API 5L.
      Specified by:
      setMaterialGrade in interface PipeLineInterface
      Parameters:
      grade - material grade (e.g., "X42", "X52", "X65", "X70", "X80")
    • getMaterialGrade

      public String getMaterialGrade()
      Get the pipe material grade.
      Specified by:
      getMaterialGrade in interface PipeLineInterface
      Returns:
      material grade
    • setDesignCode

      public void setDesignCode(String code)
      Set the design code for wall thickness and pressure calculations.
      Specified by:
      setDesignCode in interface PipeLineInterface
      Parameters:
      code - design code (e.g., "ASME_B31_8", "ASME_B31_4", "ASME_B31_3", "DNV_OS_F101")
    • getDesignCode

      public String getDesignCode()
      Get the design code.
      Specified by:
      getDesignCode in interface PipeLineInterface
      Returns:
      design code
    • setLocationClass

      public void setLocationClass(int locClass)
      Set the location class per ASME B31.8.

      Location classes:

      • Class 1: Offshore and remote areas (F=0.72)
      • Class 2: Fringe areas (F=0.60)
      • Class 3: Suburban areas (F=0.50)
      • Class 4: Urban areas (F=0.40)
      Specified by:
      setLocationClass in interface PipeLineInterface
      Parameters:
      locClass - location class 1-4
    • getLocationClass

      public int getLocationClass()
      Get the location class.
      Specified by:
      getLocationClass in interface PipeLineInterface
      Returns:
      location class 1-4
    • setCorrosionAllowance

      public void setCorrosionAllowance(double allowance)
      Set the corrosion allowance.
      Specified by:
      setCorrosionAllowance in interface PipeLineInterface
      Parameters:
      allowance - corrosion allowance in meters
    • getCorrosionAllowance

      public double getCorrosionAllowance()
      Get the corrosion allowance.
      Specified by:
      getCorrosionAllowance in interface PipeLineInterface
      Returns:
      corrosion allowance in meters
    • calculateMinimumWallThickness

      public double calculateMinimumWallThickness()
      Calculate minimum required wall thickness based on design code.
      Specified by:
      calculateMinimumWallThickness in interface PipeLineInterface
      Returns:
      minimum wall thickness in meters
    • calculateMAOP

      public double calculateMAOP()
      Calculate Maximum Allowable Operating Pressure (MAOP).
      Specified by:
      calculateMAOP in interface PipeLineInterface
      Returns:
      MAOP in MPa
    • getMAOP

      public double getMAOP(String unit)
      Get MAOP in specified unit.
      Specified by:
      getMAOP in interface PipeLineInterface
      Parameters:
      unit - pressure unit ("MPa", "bar", "psi")
      Returns:
      MAOP in specified unit
    • calculateTestPressure

      public double calculateTestPressure()
      Calculate hydrostatic test pressure.
      Specified by:
      calculateTestPressure in interface PipeLineInterface
      Returns:
      test pressure in MPa
    • calculateHoopStress

      public double calculateHoopStress()
      Calculate hoop stress at operating pressure.
      Specified by:
      calculateHoopStress in interface PipeLineInterface
      Returns:
      hoop stress in MPa
    • calculateVonMisesStress

      public double calculateVonMisesStress(double deltaT)
      Calculate von Mises equivalent stress.
      Specified by:
      calculateVonMisesStress in interface PipeLineInterface
      Parameters:
      deltaT - temperature change from installation in Celsius
      Returns:
      von Mises stress in MPa
    • isMechanicalDesignSafe

      public boolean isMechanicalDesignSafe()
      Check if the mechanical design is within allowable stress limits.
      Specified by:
      isMechanicalDesignSafe in interface PipeLineInterface
      Returns:
      true if design stress is below allowable limit
    • generateMechanicalDesignReport

      public String generateMechanicalDesignReport()
      Generate a mechanical design report.
      Specified by:
      generateMechanicalDesignReport in interface PipeLineInterface
      Returns:
      formatted design report string