Class PFDLayoutPolicy

java.lang.Object
neqsim.process.processmodel.diagram.PFDLayoutPolicy
All Implemented Interfaces:
Serializable

public class PFDLayoutPolicy extends Object implements Serializable
Layout intelligence layer for generating professional oil & gas PFDs.

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:
  • Field Details

  • Constructor Details

    • PFDLayoutPolicy

      public PFDLayoutPolicy()
      Creates a new PFD layout policy with default settings.
  • Method Details

    • classifyEquipment

      public EquipmentRole classifyEquipment(ProcessEquipmentInterface equipment)
      Classifies the role of process equipment for layout purposes.
      Parameters:
      equipment - the equipment to classify
      Returns:
      the equipment role
    • determineRole

      private EquipmentRole determineRole(ProcessEquipmentInterface equipment)
      Determines the role of equipment based on its type and context.
      Parameters:
      equipment - the equipment
      Returns:
      the determined role
    • classifyByPhase

      private EquipmentRole classifyByPhase(ProcessEquipmentInterface equipment)
      Classifies equipment role based on the phase of its fluid.
      Parameters:
      equipment - the equipment
      Returns:
      GAS, LIQUID, or MIXED based on phase types
    • classifyStreamPhase

      public PFDLayoutPolicy.StreamPhase classifyStreamPhase(StreamInterface stream)
      Classifies the phase of a stream.
      Parameters:
      stream - the stream to classify
      Returns:
      the stream phase
    • determineStreamPhase

      private PFDLayoutPolicy.StreamPhase determineStreamPhase(StreamInterface stream)
      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

      private PFDLayoutPolicy.StreamPhase classifyByStreamName(StreamInterface stream)
      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 check
      stream - the stream (for name hints)
      Returns:
      OIL, AQUEOUS, or generic LIQUID
    • classifyEdgePhase

      public PFDLayoutPolicy.StreamPhase classifyEdgePhase(ProcessEdge edge)
      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 equipment
      outletStream - 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):

      1. Gas - lightest, exits top
      2. Oil - intermediate, exits middle
      3. Aqueous/Water - heaviest, exits bottom
      Parameters:
      separator - the three-phase separator
      outletStream - 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

      public String getRankConstraint(ProcessNode node)
      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

      public int getRankLevel(ProcessNode node)
      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 node
      graph - the process graph (for topology analysis)
      Returns:
      the horizontal position
    • classifyPhaseZone

      public PFDLayoutPolicy.PhaseZone classifyPhaseZone(ProcessNode node)
      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

      private PFDLayoutPolicy.PhaseZone classifyByUpstreamPhase(ProcessNode node)
      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

      private PFDLayoutPolicy.PhaseZone classifyLiquidZone(ProcessNode node)
      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

      private boolean isWaterRelatedName(String name)
      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

      public int[] getLayoutCoordinates(ProcessNode node, ProcessGraph graph)
      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 node
      graph - the process graph
      Returns:
      int array [x, y] representing layout position