Class OnePhasePipeLine
- All Implemented Interfaces:
Serializable, Runnable, PipeLineInterface, ProcessEquipmentInterface, TwoPortInterface, SimulationInterface, NamedInterface
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:
AdvectionScheme.FIRST_ORDER_UPWIND- Default, most stable but high dispersionAdvectionScheme.TVD_VAN_LEER- Recommended for compositional trackingAdvectionScheme.TVD_SUPERBEE- Sharpest fronts, best for gas switching
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 Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether to track composition during transient simulation.private booleanWhether the pipe system has been initialized.private doubleTime step for internal solver.private static final longSerialization version UID.private doubleCurrent simulation time in seconds.Fields inherited from class Pipeline
equilibriumHeatTransfer, equilibriumMassTransfer, fileName, flowPattern, legHeights, legPositions, logger, numberOfLegs, numberOfNodesInLeg, outerHeatTransferCoeffs, outerTemperature, pipe, pipeDiameters, pipelineMechanicalDesign, pipeWallRoughness, system, times, wallHeatTransferCoeffsFields inherited from class TwoPortEquipment
inStream, outStreamFields inherited from class ProcessEquipmentBaseClass
conditionAnalysisMessage, energyStream, hasController, isSolved, properties, reportFields inherited from class SimulationBaseClass
calcIdentifier, calculateSteadyState, timeFields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionOnePhasePipeLine(String name) Constructor for OnePhasePipeLine.OnePhasePipeLine(String name, StreamInterface inStream) Constructor for OnePhasePipeLine.OnePhasePipeLine(StreamInterface inStream) Constructor for OnePhasePipeLine. -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates the pipe system.Get the current advection scheme.double[]getCompositionProfile(String componentName) Get the composition profile along the pipe for a specific component.doubleGet the internal time step.doublegetOutletMassFraction(String componentName) Get the outlet composition for a specific component.doublegetOutletMoleFraction(String componentName) Get the outlet mole fraction for a specific component.double[]getPressureProfile(String unit) Get the pressure profile along the pipe.doubleGet the current simulation time.double[]getTemperatureProfile(String unit) Get the temperature profile along the pipe.double[]Get the velocity profile along the pipe.booleanCheck if compositional tracking is enabled.voidReset the simulation time to zero.voidIn this method all thermodynamic and unit operations will be calculated in a steady state calculation.voidrunTransient(double dt, UUID id) Run transient simulation for the specified time step.voidsetAdvectionScheme(AdvectionScheme scheme) Set the advection scheme for compositional tracking.voidsetCompositionalTracking(boolean enable) Enable or disable compositional tracking during transient simulation.voidsetInternalTimeStep(double dt) Set the internal time step for the solver.private voidUpdate the inlet boundary condition from the current inlet stream.private voidUpdate the outlet stream with current outlet conditions from the pipe.Methods inherited from class Pipeline
displayResult, getCapacityDuty, getCapacityMax, getEntropyProduction, getMechanicalDesign, getOutletPressure, getPipe, getSuperficialVelocity, getTimes, initMechanicalDesign, setEquilibriumHeatTransfer, setEquilibriumMassTransfer, setHeightProfile, setInitialFlowPattern, setLegPositions, setNumberOfLegs, setNumberOfNodesInLeg, setOuterTemperatures, setOutputFileName, setPipeDiameters, setPipeOuterHeatTransferCoefficients, setPipeWallHeatTransferCoefficients, setPipeWallRoughness, setTimeSeries, toJson, toJsonMethods inherited from class TwoPortEquipment
getInletPressure, getInletStream, getInletTemperature, getMassBalance, getOutletPressure, getOutletStream, getOutletTemperature, setInletPressure, setInletStream, setInletTemperature, setOutletPressure, setOutletStream, setOutletTemperature, validateSetupMethods inherited from class ProcessEquipmentBaseClass
copy, equals, getConditionAnalysisMessage, getController, getEnergyStream, getExergyChange, getMassBalance, getMinimumFlow, getPressure, getPressure, getProperty, getReport_json, getResultTable, getSpecification, getTemperature, getTemperature, getThermoSystem, hashCode, isActive, isActive, isSetEnergyStream, reportResults, run_step, runConditionAnalysis, setController, setEnergyStream, setEnergyStream, setFlowValveController, setMinimumFlow, setPressure, setRegulatorOutSignal, setSpecification, setTemperature, solvedMethods inherited from class SimulationBaseClass
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTimeMethods inherited from class NamedBaseClass
getName, getTagName, setName, setTagNameMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NamedInterface
getName, getTagName, setName, setTagNameMethods inherited from interface ProcessEquipmentInterface
getExergyChange, getFluid, getRestCapacity, needRecalculationMethods inherited from interface SimulationInterface
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, run, run_step, run_step, runTransient, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTime, solvedMethods inherited from interface TwoPortInterface
getInletPressure, getInletStream, getInletTemperature, getInStream, getOutletPressure, getOutletStream, getOutletTemperature, getOutStream, setInletPressure, setInletStream, setInletTemperature, setOutletPressure, setOutletStream, setOutletTemperature
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
compositionalTracking
private boolean compositionalTrackingWhether to track composition during transient simulation. -
initialized
private boolean initializedWhether the pipe system has been initialized. -
simulationTime
private double simulationTimeCurrent simulation time in seconds. -
internalTimeStep
private double internalTimeStepTime step for internal solver.
-
-
Constructor Details
-
OnePhasePipeLine
Constructor for OnePhasePipeLine.- Parameters:
inStream- aStreamobject
-
OnePhasePipeLine
Constructor for OnePhasePipeLine.- Parameters:
name- name of pipe
-
OnePhasePipeLine
Constructor for OnePhasePipeLine.- Parameters:
name- name of pipeinStream- input stream
-
-
Method Details
-
createSystem
public void createSystem()Creates the pipe system. Called automatically by run() if not already created. -
setAdvectionScheme
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
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
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
Get the pressure profile along the pipe.- Parameters:
unit- pressure unit (e.g., "bara", "Pa")- Returns:
- array of pressures at each node
-
getTemperatureProfile
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
In this method all thermodynamic and unit operations will be calculated in a steady state calculation.
- Specified by:
runin interfaceSimulationInterface- Overrides:
runin classPipeline- Parameters:
id- UUID
-
runTransient
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:
runTransientin interfaceSimulationInterface- Overrides:
runTransientin classPipeline- Parameters:
dt- time step in secondsid- 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
Get the outlet composition for a specific component.- Parameters:
componentName- name of the component- Returns:
- mass fraction of the component at the outlet
-
getOutletMoleFraction
Get the outlet mole fraction for a specific component.- Parameters:
componentName- name of the component- Returns:
- mole fraction of the component at the outlet
-