Class ProcessGraphBuilder

java.lang.Object
neqsim.process.processmodel.graph.ProcessGraphBuilder

public final class ProcessGraphBuilder extends Object
Builder class for constructing a ProcessGraph from a ProcessSystem.

This class discovers stream connections between equipment units and produces an explicit graph structure that enables topology-based calculation order derivation.

Usage:

ProcessSystem system = ...;
ProcessGraph graph = ProcessGraphBuilder.buildGraph(system);

// Get calculation order derived from topology
List<ProcessEquipmentInterface> order = graph.getCalculationOrder();

// Partition for parallel execution
ProcessGraph.ParallelPartition partition = graph.partitionForParallelExecution();
Version:
1.0
Author:
NeqSim
  • Field Details

    • logger

      private static final org.apache.logging.log4j.Logger logger
  • Constructor Details

    • ProcessGraphBuilder

      private ProcessGraphBuilder()
  • Method Details

    • buildGraph

      public static ProcessGraph buildGraph(ProcessSystem system)
      Builds a process graph from a ProcessSystem.
      Parameters:
      system - the process system
      Returns:
      the constructed graph
    • collectSplitStreams

      private static void collectSplitStreams(ProcessEquipmentInterface unit, Map<Object, ProcessEquipmentInterface> streamToProducer)
      Collects split streams from a Splitter via reflection. Uses the splitStream field or getSplitStream(int) method.
      Parameters:
      unit - the splitter unit to collect streams from
      streamToProducer - map to store stream to producer associations
    • collectMixerInputStreamsAndCreateEdges

      private static void collectMixerInputStreamsAndCreateEdges(ProcessEquipmentInterface unit, ProcessGraph graph, Map<Object, ProcessEquipmentInterface> streamToProducer)
      Collects input streams from a Mixer and creates edges. Uses reflection since getStream(int) is not in MixerInterface.
      Parameters:
      unit - the mixer unit to collect streams from
      graph - the process graph to add edges to
      streamToProducer - map of stream to producer associations
    • findField

      private static Field findField(Class<?> clazz, String fieldName)
      Finds a field in the class hierarchy.
      Parameters:
      clazz - the class to search in (including superclasses)
      fieldName - the name of the field to find
      Returns:
      the Field object, or null if not found
    • collectProducedStreams

      private static void collectProducedStreams(ProcessEquipmentInterface unit, Map<Object, ProcessEquipmentInterface> streamToProducer)
      Collects streams produced by a unit via common getter methods.
      Parameters:
      unit - the process equipment unit to analyze
      streamToProducer - map to store stream-to-producer relationships
    • collectConsumedStreamsAndCreateEdges

      private static void collectConsumedStreamsAndCreateEdges(ProcessEquipmentInterface unit, ProcessGraph graph, Map<Object, ProcessEquipmentInterface> streamToProducer)
      Collects streams consumed by a unit and creates edges.
      Parameters:
      unit - the process equipment unit to analyze
      graph - the process graph to add edges to
      streamToProducer - map of stream-to-producer relationships
    • scanFieldsForInletStreams

      private static void scanFieldsForInletStreams(ProcessEquipmentInterface unit, ProcessGraph graph, Map<Object, ProcessEquipmentInterface> streamToProducer, Set<Object> visited)
      Scans fields for inlet streams.
      Parameters:
      unit - the process equipment unit to scan
      graph - the process graph to add edges to
      streamToProducer - map of stream-to-producer relationships
      visited - set of already visited streams to avoid duplicates
    • createEdgeFromProducer

      private static void createEdgeFromProducer(ProcessGraph graph, Map<Object, ProcessEquipmentInterface> streamToProducer, Object stream, ProcessEquipmentInterface consumer)
      Creates an edge from the producer of a stream to the consumer.
      Parameters:
      graph - the process graph to add the edge to
      streamToProducer - map of stream-to-producer relationships
      stream - the stream object connecting producer to consumer
      consumer - the consuming process equipment unit
    • invokeMethod

      private static Object invokeMethod(ProcessEquipmentInterface unit, Method method)
      Safely invokes a method.