Class OnePhasePipeLine

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

public class OnePhasePipeLine extends Pipeline
One-phase pipeline with compositional tracking support.

This class wraps PipeFlowSystem for use in process simulations. It supports both steady-state and transient simulations, including compositional tracking for scenarios like gas switching (e.g., natural gas to nitrogen transitions).

Transient Compositional Tracking

For gas switching scenarios, use setAdvectionScheme(AdvectionScheme) to select a higher-order scheme that reduces numerical dispersion:

Example: Gas Switching Simulation

// Create pipeline
OnePhasePipeLine pipe = new OnePhasePipeLine("GasPipe", inletStream);
pipe.setNumberOfLegs(1);
pipe.setNumberOfNodesInLeg(100);
pipe.setPipeDiameters(new double[] {0.3, 0.3});
pipe.setLegPositions(new double[] {0.0, 5000.0});

// Select TVD scheme for sharp composition fronts
pipe.setAdvectionScheme(AdvectionScheme.TVD_VAN_LEER);
pipe.setCompositionalTracking(true);

// Initialize with steady state
pipe.run();

// Run transient with changing inlet composition
UUID id = UUID.randomUUID();
for (int step = 0; step < 100; step++) {
  // Update inlet stream composition if needed
  pipe.runTransient(1.0, id); // 1 second time step

  // Access outlet composition
  double methane = pipe.getOutletStream().getFluid().getComponent("methane").getx();
}
Version:
$Id: $Id
Author:
esol
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • compositionalTracking

      private boolean compositionalTracking
      Whether to track composition during transient simulation.
    • initialized

      private boolean initialized
      Whether the pipe system has been initialized.
    • simulationTime

      private double simulationTime
      Current simulation time in seconds.
    • internalTimeStep

      private double internalTimeStep
      Time step for internal solver.
  • Constructor Details

    • OnePhasePipeLine

      public OnePhasePipeLine(StreamInterface inStream)
      Constructor for OnePhasePipeLine.
      Parameters:
      inStream - a Stream object
    • OnePhasePipeLine

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

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

    • createSystem

      public void createSystem()
      Creates the pipe system. Called automatically by run() if not already created.
    • setAdvectionScheme

      public void setAdvectionScheme(AdvectionScheme scheme)
      Set the advection scheme for compositional tracking.

      Higher-order schemes reduce numerical dispersion (front spreading) during compositional tracking. For gas switching scenarios, TVD schemes are recommended.

      Parameters:
      scheme - the advection scheme to use
      See Also:
    • getAdvectionScheme

      public AdvectionScheme getAdvectionScheme()
      Get the current advection scheme.
      Returns:
      the advection scheme
    • setCompositionalTracking

      public void setCompositionalTracking(boolean enable)
      Enable or disable compositional tracking during transient simulation.

      When enabled, the transient solver tracks component mass fractions through the pipe. Use this for gas switching or composition gradient tracking scenarios.

      Parameters:
      enable - true to enable compositional tracking
    • isCompositionalTracking

      public boolean isCompositionalTracking()
      Check if compositional tracking is enabled.
      Returns:
      true if compositional tracking is enabled
    • getSimulationTime

      public double getSimulationTime()
      Get the current simulation time.
      Returns:
      simulation time in seconds
    • resetSimulationTime

      public void resetSimulationTime()
      Reset the simulation time to zero.
    • setInternalTimeStep

      public void setInternalTimeStep(double dt)
      Set the internal time step for the solver.
      Parameters:
      dt - time step in seconds
    • getInternalTimeStep

      public double getInternalTimeStep()
      Get the internal time step.
      Returns:
      time step in seconds
    • getCompositionProfile

      public double[] getCompositionProfile(String componentName)
      Get the composition profile along the pipe for a specific component.
      Parameters:
      componentName - name of the component
      Returns:
      array of mass fractions at each node
    • getPressureProfile

      public double[] getPressureProfile(String unit)
      Get the pressure profile along the pipe.
      Parameters:
      unit - pressure unit (e.g., "bara", "Pa")
      Returns:
      array of pressures at each node
    • getTemperatureProfile

      public double[] getTemperatureProfile(String unit)
      Get the temperature profile along the pipe.
      Parameters:
      unit - temperature unit (e.g., "K", "C")
      Returns:
      array of temperatures at each node
    • getVelocityProfile

      public double[] getVelocityProfile()
      Get the velocity profile along the pipe.
      Returns:
      array of velocities (m/s) at each node
    • 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
    • runTransient

      public void runTransient(double dt, UUID id)
      Run transient simulation for the specified time step.

      This method advances the pipe simulation by the specified time step and updates the outlet stream with the current outlet conditions. The inlet boundary is updated from the current inlet stream state.

      If compositional tracking is enabled, the solver tracks component mass fractions through the pipe using the selected advection scheme.

      Specified by:
      runTransient in interface SimulationInterface
      Overrides:
      runTransient in class Pipeline
      Parameters:
      dt - time step in seconds
      id - calculation identifier
    • updateInletBoundary

      private void updateInletBoundary()
      Update the inlet boundary condition from the current inlet stream.
    • updateOutletStream

      private void updateOutletStream()
      Update the outlet stream with current outlet conditions from the pipe.
    • getOutletMassFraction

      public double getOutletMassFraction(String componentName)
      Get the outlet composition for a specific component.
      Parameters:
      componentName - name of the component
      Returns:
      mass fraction of the component at the outlet
    • getOutletMoleFraction

      public double getOutletMoleFraction(String componentName)
      Get the outlet mole fraction for a specific component.
      Parameters:
      componentName - name of the component
      Returns:
      mole fraction of the component at the outlet