Class PipingRouteBuilder
- All Implemented Interfaces:
Serializable
The builder stores route segments with from/to nodes, hydraulic diameter, straight length,
optional wall thickness, roughness, elevation change, and K-value minor losses. Calling
build(StreamInterface) creates a ProcessSystem containing the inlet stream and
one PipeBeggsAndBrills unit per segment, wired in the same order as the line-list rows.
Minor losses are converted from resistance coefficient K to equivalent length ratio L/D using a configurable Darcy friction factor assumption. The default assumption is 0.02, a typical turbulent screening value.
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOne K-value minor loss attached to a route segment.static classOne route segment from a line-list table. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleDefault Darcy friction factor used for converting K values to L/D values.private intprivate doubleprivate doubleprivate final List<PipingRouteBuilder.RouteSegment> private static final longSerialization version UID. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMinorLoss(String segmentId, String fittingType, double kValue) Adds one K-value minor loss to a segment.addSegment(String fromNode, String toNode, double length, String lengthUnit, double nominalDiameter, String diameterUnit) Adds one route segment and assigns a generated segment id such asS1.addSegment(String segmentId, String fromNode, String toNode, double length, String lengthUnit, double nominalDiameter, String diameterUnit) Adds one route segment with an explicit segment id.addToProcessSystem(ProcessSystem process, StreamInterface inletStream) Adds the route pipe units to an existingProcessSystemand returns the outlet stream of the final generated pipe.addToProcessSystem(ProcessSystem process, StreamInterface inletStream, String sourceEquipmentName, String sourcePortName) Adds the route pipe units to an existingProcessSystemwith explicit source-equipment metadata for the first route connection.build(StreamInterface inletStream) Builds a serialProcessSystemroute model from the stored route segments.private static doubleconvertLengthToMeters(double value, String unit) Converts a length-like value to meters.private PipeBeggsAndBrillscreatePipe(PipingRouteBuilder.RouteSegment segment, StreamInterface inletStream) Creates and configures one Beggs-and-Brill pipe for a route segment.private PipingRouteBuilder.RouteSegmentfindSegment(String segmentId) Finds a segment by id or by route reference.private PipingRouteBuilder.RouteSegmentfindSegmentOrThrow(String segmentId) Finds a segment or throws an exception.getSegment(String segmentId) Gets a route segment by id or byfromNode->toNodereference.Returns route segments in build order.private voidRecalculates stored equivalent length ratios after the friction factor assumption changes.private static doublerequireFinite(double value, String fieldName) Requires a finite value.private static doublerequireNonNegative(double value, String fieldName) Requires a finite non-negative value.private static doublerequirePositive(double value, String fieldName) Requires a finite positive value.private static StringrequireText(String value, String fieldName) Requires a non-empty text value.setDefaultHeatTransferMode(PipeBeggsAndBrills.HeatTransferMode heatTransferMode) Sets the heat transfer mode applied to each generated Beggs-and-Brill pipe.setDefaultNumberOfIncrements(int numberOfIncrements) Sets the number of increments used for each generated Beggs-and-Brill pipe.setDefaultPipeWallRoughness(double roughness, String unit) Sets the default wall roughness used for segments without explicit roughness.setMinorLossFrictionFactor(double frictionFactor) Sets the Darcy friction factor assumption used to convert K values to equivalent L/D values.setSegmentElevationChange(String segmentId, double elevationChange, String unit) Sets segment elevation change from inlet to outlet.setSegmentPipeWallRoughness(String segmentId, double roughness, String unit) Sets segment pipe wall roughness.setSegmentWallThickness(String segmentId, double wallThickness, String unit) Sets segment wall thickness metadata and pipe wall thickness on the generated pipe.toJson()Exports route geometry, assumptions, and minor losses as JSON.toMap()Converts the builder state to a JSON-friendly map.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
DEFAULT_MINOR_LOSS_FRICTION_FACTOR
private static final double DEFAULT_MINOR_LOSS_FRICTION_FACTORDefault Darcy friction factor used for converting K values to L/D values.- See Also:
-
segments
-
defaultPipeWallRoughnessMeters
private double defaultPipeWallRoughnessMeters -
defaultNumberOfIncrements
private int defaultNumberOfIncrements -
minorLossFrictionFactor
private double minorLossFrictionFactor -
defaultHeatTransferMode
-
-
Constructor Details
-
PipingRouteBuilder
public PipingRouteBuilder()Creates an empty piping route builder.
-
-
Method Details
-
addSegment
public PipingRouteBuilder addSegment(String fromNode, String toNode, double length, String lengthUnit, double nominalDiameter, String diameterUnit) Adds one route segment and assigns a generated segment id such asS1.- Parameters:
fromNode- upstream node name from the line listtoNode- downstream node name from the line listlength- straight pipe length, must be positivelengthUnit- unit forlength, for examplem,km,ftnominalDiameter- hydraulic diameter used by the pipe model, must be positivediameterUnit- unit fornominalDiameter, for examplem,mm,inch- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if inputs are blank, non-positive, duplicated, or unsupported
-
addSegment
public PipingRouteBuilder addSegment(String segmentId, String fromNode, String toNode, double length, String lengthUnit, double nominalDiameter, String diameterUnit) Adds one route segment with an explicit segment id.- Parameters:
segmentId- unique segment id, for example a line number orS1fromNode- upstream node name from the line listtoNode- downstream node name from the line listlength- straight pipe length, must be positivelengthUnit- unit forlength, for examplem,km,ftnominalDiameter- hydraulic diameter used by the pipe model, must be positivediameterUnit- unit fornominalDiameter, for examplem,mm,inch- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if inputs are blank, non-positive, duplicated, or unsupported
-
setSegmentWallThickness
public PipingRouteBuilder setSegmentWallThickness(String segmentId, double wallThickness, String unit) Sets segment wall thickness metadata and pipe wall thickness on the generated pipe.- Parameters:
segmentId- segment id orfromNode->toNoderoute referencewallThickness- wall thickness, must be non-negativeunit- unit forwallThickness, for examplem,mm,inch- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if the segment cannot be found or the value/unit is invalid
-
setSegmentElevationChange
public PipingRouteBuilder setSegmentElevationChange(String segmentId, double elevationChange, String unit) Sets segment elevation change from inlet to outlet.- Parameters:
segmentId- segment id orfromNode->toNoderoute referenceelevationChange- elevation change, positive for uphill and negative for downhillunit- unit forelevationChange, for examplem,ft- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if the segment cannot be found or the unit is invalid
-
setSegmentPipeWallRoughness
public PipingRouteBuilder setSegmentPipeWallRoughness(String segmentId, double roughness, String unit) Sets segment pipe wall roughness.- Parameters:
segmentId- segment id orfromNode->toNoderoute referenceroughness- roughness, must be non-negativeunit- unit forroughness, for examplem,mm,micrometer- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if the segment cannot be found or the value/unit is invalid
-
addMinorLoss
Adds one K-value minor loss to a segment.- Parameters:
segmentId- segment id orfromNode->toNoderoute referencefittingType- fitting, valve, strainer, bend, or equipment-loss descriptionkValue- resistance coefficient K, must be non-negative- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if the segment cannot be found or the K value is invalid
-
setDefaultPipeWallRoughness
Sets the default wall roughness used for segments without explicit roughness.- Parameters:
roughness- roughness, must be non-negativeunit- unit forroughness, for examplem,mm,micrometer- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if the roughness or unit is invalid
-
setMinorLossFrictionFactor
Sets the Darcy friction factor assumption used to convert K values to equivalent L/D values.- Parameters:
frictionFactor- Darcy friction factor, must be positive- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- if the friction factor is not positive
-
setDefaultNumberOfIncrements
Sets the number of increments used for each generated Beggs-and-Brill pipe.- Parameters:
numberOfIncrements- number of increments, must be positive- Returns:
- this builder for chaining
- Throws:
IllegalArgumentException- ifnumberOfIncrementsis not positive
-
setDefaultHeatTransferMode
public PipingRouteBuilder setDefaultHeatTransferMode(PipeBeggsAndBrills.HeatTransferMode heatTransferMode) Sets the heat transfer mode applied to each generated Beggs-and-Brill pipe.- Parameters:
heatTransferMode- heat transfer mode, must not be null- Returns:
- this builder for chaining
- Throws:
NullPointerException- ifheatTransferModeis null
-
build
Builds a serialProcessSystemroute model from the stored route segments.- Parameters:
inletStream- inlet stream for the first pipe segment, must not be null- Returns:
- process system containing the inlet stream and route pipe units
- Throws:
IllegalArgumentException- if no route segments have been addedNullPointerException- ifinletStreamis null
-
addToProcessSystem
Adds the route pipe units to an existingProcessSystemand returns the outlet stream of the final generated pipe.Use this method when a line-list route is only one section of a larger flowsheet. The caller is responsible for adding the upstream feed stream or upstream equipment to the process system. The returned stream can be passed directly to downstream equipment constructors.
- Parameters:
process- process system that will receive the generated pipe units, must not be nullinletStream- stream connected to the first generated pipe, must not be null- Returns:
- outlet stream from the last generated pipe
- Throws:
IllegalArgumentException- if no route segments have been addedNullPointerException- ifprocessorinletStreamis null
-
addToProcessSystem
public StreamInterface addToProcessSystem(ProcessSystem process, StreamInterface inletStream, String sourceEquipmentName, String sourcePortName) Adds the route pipe units to an existingProcessSystemwith explicit source-equipment metadata for the first route connection.This overload is useful when
inletStreamis the outlet stream of an upstream equipment item. The stream object performs the actual process wiring, whilesourceEquipmentNameandsourcePortNamepreserve the topology metadata inProcessConnectionrecords.- Parameters:
process- process system that will receive the generated pipe units, must not be nullinletStream- stream connected to the first generated pipe, must not be nullsourceEquipmentName- upstream equipment name for the first material connectionsourcePortName- upstream port name for the first material connection- Returns:
- outlet stream from the last generated pipe
- Throws:
IllegalArgumentException- if no route segments have been added or source metadata is blankNullPointerException- ifprocessorinletStreamis null
-
getSegments
Returns route segments in build order.- Returns:
- unmodifiable list of route segments
-
getSegment
Gets a route segment by id or byfromNode->toNodereference.- Parameters:
segmentId- segment id or route reference- Returns:
- matching route segment, or null if no segment matches
-
toJson
Exports route geometry, assumptions, and minor losses as JSON.- Returns:
- pretty-printed JSON route definition
-
createPipe
private PipeBeggsAndBrills createPipe(PipingRouteBuilder.RouteSegment segment, StreamInterface inletStream) Creates and configures one Beggs-and-Brill pipe for a route segment.- Parameters:
segment- route segment definitioninletStream- inlet stream connected to the pipe- Returns:
- configured pipe unit
-
recalculateMinorLossEquivalentLengths
private void recalculateMinorLossEquivalentLengths()Recalculates stored equivalent length ratios after the friction factor assumption changes. -
findSegmentOrThrow
Finds a segment or throws an exception.- Parameters:
segmentId- segment id or route reference- Returns:
- matching route segment
- Throws:
IllegalArgumentException- if no segment matches
-
findSegment
Finds a segment by id or by route reference.- Parameters:
segmentId- segment id or route reference- Returns:
- matching route segment, or null if none matches
-
toMap
-
requireText
Requires a non-empty text value.- Parameters:
value- text value to validatefieldName- field name used in error messages- Returns:
- trimmed text value
- Throws:
IllegalArgumentException- if the value is null or blank
-
requirePositive
Requires a finite positive value.- Parameters:
value- numeric value to validatefieldName- field name used in error messages- Returns:
- validated value
- Throws:
IllegalArgumentException- if the value is not finite and positive
-
requireNonNegative
Requires a finite non-negative value.- Parameters:
value- numeric value to validatefieldName- field name used in error messages- Returns:
- validated value
- Throws:
IllegalArgumentException- if the value is not finite or is negative
-
requireFinite
Requires a finite value.- Parameters:
value- numeric value to validatefieldName- field name used in error messages- Returns:
- validated value
- Throws:
IllegalArgumentException- if the value is NaN or infinite
-
convertLengthToMeters
Converts a length-like value to meters.- Parameters:
value- value to convertunit- source unit, for examplem,km,mm,inch,ft, ormicrometer- Returns:
- value converted to meters
- Throws:
IllegalArgumentException- if the unit is blank or unsupported
-