Class PFDLayoutPolicy
- All Implemented Interfaces:
Serializable
This class applies engineering layout rules to produce diagrams that follow industry conventions:
- Gravity logic - Gas flows upward, liquids flow downward
- Functional zoning - Separation center, gas processing upper, liquid lower
- Equipment semantics - Separator outlets positioned correctly (gas top, liquid bottom)
- Phase-aware routing - Stream colors and paths based on phase
- Stable layout - Same model produces same diagram every time
For three-phase separators, the layout follows gravity-based conventions:
- Gas outlet exits from top (lightest phase)
- Oil outlet exits from middle (intermediate density)
- Aqueous/water outlet exits from bottom (heaviest phase)
- Version:
- 1.0
- Author:
- NeqSim
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumVertical phase zone for gravity-based positioning.static enumHorizontal process position for left-to-right flow convention.static enumSeparator outlet type for proper positioning.static enumStream phase classification based on vapor/liquid fraction. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<StreamInterface, PFDLayoutPolicy.StreamPhase> Cache for stream phase classifications.private final Map<ProcessEquipmentInterface, EquipmentRole> Cache for equipment role classifications.private static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate EquipmentRoleclassifyByPhase(ProcessEquipmentInterface equipment) Classifies equipment role based on the phase of its fluid.private PFDLayoutPolicy.StreamPhaseclassifyByStreamName(StreamInterface stream) Classifies stream phase based on stream name hints.private PFDLayoutPolicy.PhaseZoneClassifies a node's phase zone by tracing its upstream connections.classifyEdgePhase(ProcessEdge edge) Classifies the phase of an edge (stream connection).classifyEquipment(ProcessEquipmentInterface equipment) Classifies the role of process equipment for layout purposes.classifyHorizontalPosition(ProcessNode node, ProcessGraph graph) Determines the horizontal process position for a node.private PFDLayoutPolicy.StreamPhaseclassifyLiquidPhase(SystemInterface fluid, StreamInterface stream) Classifies a liquid-dominated stream as OIL, AQUEOUS, or LIQUID.private PFDLayoutPolicy.PhaseZoneClassifies a liquid processing node as oil or water zone.classifyPhaseZone(ProcessNode node) Determines the vertical phase zone for a node.classifySeparatorOutlet(ProcessEquipmentInterface separator, StreamInterface outletStream) Determines the separator outlet type for an edge leaving a separator.private PFDLayoutPolicy.SeparatorOutletclassifySeparatorOutletByNameAndPhase(StreamInterface outletStream) Classifies separator outlet by stream name and phase composition.classifyStreamPhase(StreamInterface stream) Classifies the phase of a stream.private PFDLayoutPolicy.SeparatorOutletclassifyThreePhaseSeparatorOutlet(ThreePhaseSeparator separator, StreamInterface outletStream) Classifies the outlet type for a three-phase separator.voidClears all cached classifications.private EquipmentRoledetermineRole(ProcessEquipmentInterface equipment) Determines the role of equipment based on its type and context.private PFDLayoutPolicy.StreamPhasedetermineStreamPhase(StreamInterface stream) Determines the phase of a stream based on phase types and composition.int[]getLayoutCoordinates(ProcessNode node, ProcessGraph graph) Gets the combined layout coordinates for a node.getRankConstraint(ProcessNode node) Gets the Graphviz rank constraint for a node based on its equipment role.intgetRankLevel(ProcessNode node) Gets the vertical rank level for a node (0 = top, higher = lower).private booleanisWaterRelatedName(String name) Checks if a name contains water-related keywords.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
roleCache
Cache for equipment role classifications. -
phaseCache
Cache for stream phase classifications.
-
-
Constructor Details
-
PFDLayoutPolicy
public PFDLayoutPolicy()Creates a new PFD layout policy with default settings.
-
-
Method Details
-
classifyEquipment
Classifies the role of process equipment for layout purposes.- Parameters:
equipment- the equipment to classify- Returns:
- the equipment role
-
determineRole
Determines the role of equipment based on its type and context.- Parameters:
equipment- the equipment- Returns:
- the determined role
-
classifyByPhase
Classifies equipment role based on the phase of its fluid.- Parameters:
equipment- the equipment- Returns:
- GAS, LIQUID, or MIXED based on phase types
-
classifyStreamPhase
Classifies the phase of a stream.- Parameters:
stream- the stream to classify- Returns:
- the stream phase
-
determineStreamPhase
Determines the phase of a stream based on phase types and composition.For streams leaving three-phase separators, this method distinguishes between oil and aqueous phases using phase type information. For two-phase systems, it uses phase type detection.
- Parameters:
stream- the stream- Returns:
- the determined phase (GAS, LIQUID, OIL, AQUEOUS, MIXED, or UNKNOWN)
-
classifyByStreamName
Classifies stream phase based on stream name hints.- Parameters:
stream- the stream- Returns:
- the phase based on name
-
classifyLiquidPhase
private PFDLayoutPolicy.StreamPhase classifyLiquidPhase(SystemInterface fluid, StreamInterface stream) Classifies a liquid-dominated stream as OIL, AQUEOUS, or LIQUID.This method uses phase type information when available, and falls back to stream name hints when phase type cannot be determined.
- Parameters:
fluid- the fluid to checkstream- the stream (for name hints)- Returns:
- OIL, AQUEOUS, or generic LIQUID
-
classifyEdgePhase
Classifies the phase of an edge (stream connection).- Parameters:
edge- the process edge- Returns:
- the stream phase
-
classifySeparatorOutlet
public PFDLayoutPolicy.SeparatorOutlet classifySeparatorOutlet(ProcessEquipmentInterface separator, StreamInterface outletStream) Determines the separator outlet type for an edge leaving a separator.For three-phase separators, outlets are positioned by gravity:
- Gas outlet: top (north) - lightest phase
- Oil outlet: middle (east) - intermediate density
- Aqueous/water outlet: bottom (south) - heaviest phase
- Parameters:
separator- the separator equipmentoutletStream- the outlet stream- Returns:
- the outlet type for positioning
-
classifyThreePhaseSeparatorOutlet
private PFDLayoutPolicy.SeparatorOutlet classifyThreePhaseSeparatorOutlet(ThreePhaseSeparator separator, StreamInterface outletStream) Classifies the outlet type for a three-phase separator.Three-phase separator outlets by gravity (top to bottom):
- Gas - lightest, exits top
- Oil - intermediate, exits middle
- Aqueous/Water - heaviest, exits bottom
- Parameters:
separator- the three-phase separatoroutletStream- the outlet stream to classify- Returns:
- the separator outlet type
-
classifySeparatorOutletByNameAndPhase
private PFDLayoutPolicy.SeparatorOutlet classifySeparatorOutletByNameAndPhase(StreamInterface outletStream) Classifies separator outlet by stream name and phase composition.- Parameters:
outletStream- the outlet stream- Returns:
- the separator outlet type
-
getRankConstraint
Gets the Graphviz rank constraint for a node based on its equipment role.Uses oil & gas conventions:
- Gas equipment: rank=min (top)
- Separators: rank=same (center anchor)
- Liquid equipment: rank=max (bottom)
- Parameters:
node- the process node- Returns:
- rank constraint string or null if no constraint
-
getRankLevel
Gets the vertical rank level for a node (0 = top, higher = lower).- Parameters:
node- the process node- Returns:
- rank level
-
clearCache
public void clearCache()Clears all cached classifications. -
classifyHorizontalPosition
public PFDLayoutPolicy.ProcessPosition classifyHorizontalPosition(ProcessNode node, ProcessGraph graph) Determines the horizontal process position for a node.Uses graph topology to determine position:
- Source nodes (no incoming edges) → INLET (left)
- Sink nodes (no outgoing edges) → OUTLET (right)
- All other nodes → CENTER
- Parameters:
node- the process nodegraph- the process graph (for topology analysis)- Returns:
- the horizontal position
-
classifyPhaseZone
Determines the vertical phase zone for a node.Uses equipment role and stream phase to determine vertical positioning:
- Gas processing equipment → GAS_TOP
- Separators → OIL_MIDDLE (part of oil processing)
- Liquid/oil processing → OIL_MIDDLE
- Water processing → WATER_BOTTOM
- Parameters:
node- the process node- Returns:
- the vertical phase zone
-
classifyByUpstreamPhase
Classifies a node's phase zone by tracing its upstream connections.This method is used for equipment that could handle any phase (mixers, heaters, coolers, valves etc.) by examining what streams feed into it.
- Parameters:
node- the process node- Returns:
- the phase zone based on upstream connections
-
classifyLiquidZone
Classifies a liquid processing node as oil or water zone.This method traces the stream back to determine if it originates from a separator's oil or water outlet, ensuring proper vertical positioning in the PFD.
- Parameters:
node- the process node- Returns:
- OIL_MIDDLE or WATER_BOTTOM
-
isWaterRelatedName
Checks if a name contains water-related keywords.- Parameters:
name- the name to check (should be lowercase)- Returns:
- true if the name indicates water/aqueous processing
-
getLayoutCoordinates
Gets the combined layout coordinates for a node.Returns a 2D coordinate where:
- X (horizontal): 0=inlet/left, 1=center, 2=outlet/right
- Y (vertical): 0=gas/top, 1=oil/middle, 2=water/bottom
- Parameters:
node- the process nodegraph- the process graph- Returns:
- int array [x, y] representing layout position
-