Class ProcessModelGraphBuilder

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

public final class ProcessModelGraphBuilder extends Object
Builder class for constructing a ProcessModelGraph from a ProcessModule.

This builder handles the complexity of combining multiple ProcessSystem objects into a unified graph representation, while maintaining information about the hierarchical structure and cross-system connections.

Usage:

ProcessModule module = new ProcessModule("Plant");
module.add(processSystem1);
module.add(processSystem2);

ProcessModelGraph modelGraph = ProcessModelGraphBuilder.buildModelGraph(module);

// Get overall calculation order
List<ProcessEquipmentInterface> order = modelGraph.getCalculationOrder();

// Analyze inter-system connections
for (InterSystemConnection conn : modelGraph.getInterSystemConnections()) {
  System.out.println(conn);
}
Version:
1.0
Author:
NeqSim
  • Field Details

    • logger

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

    • ProcessModelGraphBuilder

      private ProcessModelGraphBuilder()
  • Method Details

    • buildModelGraph

      public static ProcessModelGraph buildModelGraph(ProcessModule module)
      Builds a ProcessModelGraph from a ProcessModule.
      Parameters:
      module - the process module containing ProcessSystems and/or nested modules
      Returns:
      the constructed ProcessModelGraph
    • buildModelGraph

      public static ProcessModelGraph buildModelGraph(String modelName, ProcessSystem... systems)
      Builds a ProcessModelGraph from multiple ProcessSystems.

      Convenience method for combining multiple systems without creating a ProcessModule.

      Parameters:
      modelName - name for the combined model
      systems - the process systems to combine
      Returns:
      the constructed ProcessModelGraph
    • buildFlattenedGraph

      private static ProcessGraph buildFlattenedGraph(List<ProcessModelGraph.SubSystemGraph> subSystemGraphs)
      Builds a flattened graph containing all nodes and edges from all sub-systems.
      Parameters:
      subSystemGraphs - list of sub-system graphs to flatten
      Returns:
      a new ProcessGraph containing all nodes and edges from all sub-systems
    • detectInterSystemConnections

      private static void detectInterSystemConnections(List<ProcessModelGraph.SubSystemGraph> subSystemGraphs, Map<ProcessNode, String> nodeToSystem, List<ProcessModelGraph.InterSystemConnection> connections, ProcessGraph flattenedGraph)
      Detects connections between different sub-systems by analyzing stream references. This includes both explicit edges within sub-systems AND implicit dependencies where one system uses stream/fluid objects from another system's equipment.
      Parameters:
      subSystemGraphs - list of sub-system graphs to analyze
      nodeToSystem - mapping from nodes to their owning system names
      connections - list to populate with detected inter-system connections
      flattenedGraph - the flattened graph containing all nodes
    • collectEquipmentOutputs

      private static void collectEquipmentOutputs(ProcessEquipmentInterface equipment, String systemName, Map<Object, ProcessEquipmentInterface> streamProducers, Map<Object,String> streamToSystem)
      Collect output streams from specific equipment types.
      Parameters:
      equipment - the equipment to collect outputs from
      systemName - the name of the system containing the equipment
      streamProducers - map to populate with stream-to-producer mappings
      streamToSystem - map to populate with stream-to-system mappings
    • findEdge

      private static ProcessEdge findEdge(ProcessNode source, ProcessNode target)
      Find an edge between two nodes.
      Parameters:
      source - the source node
      target - the target node
      Returns:
      the edge between the nodes, or null if not found
    • connectionExists

      private static boolean connectionExists(List<ProcessModelGraph.InterSystemConnection> connections, ProcessNode source, ProcessNode target)
      Check if a connection already exists.
      Parameters:
      connections - the list of existing connections
      source - the source node
      target - the target node
      Returns:
      true if the connection exists, false otherwise
    • findStreamField

      private static Field findStreamField(Class<?> clazz)
      Find the 'stream' field in a Stream class hierarchy.
      Parameters:
      clazz - the class to search for the stream field
      Returns:
      the stream field, or null if not found
    • checkMixerInputs

      private static void checkMixerInputs(ProcessEquipmentInterface mixer, String targetSystemName, Map<Object, ProcessEquipmentInterface> streamProducers, Map<Object,String> streamToSystem, ProcessGraph flattenedGraph, List<ProcessModelGraph.InterSystemConnection> connections)
      Check Mixer inputs for cross-system connections.
      Parameters:
      mixer - the mixer equipment to check
      targetSystemName - the name of the target process system
      streamProducers - map from streams to their producing equipment
      streamToSystem - map from streams to their originating system name
      flattenedGraph - the flattened process graph
      connections - list to populate with discovered inter-system connections
    • findField

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