Package neqsim.process.processmodel.graph


package neqsim.process.processmodel.graph
Graph-based process representation for NeqSim process flowsheets.

This package provides an explicit DAG (Directed Acyclic Graph) representation of process flowsheets, addressing the limitation that ProcessSystem is a list where topology is implicit via stream connections.

Why This Matters

Without explicit graph representation:

  • Execution order equals insertion order (fragile)
  • Rearranging units or adding recycles late causes wrong results
  • Parallel execution risks silent convergence failures

With a graph:

  • Execution order is derived from topology, not assumed
  • Recycles and feedback loops are explicit objects
  • Partitioning enables safe parallel execution
  • AI agents can reason about flowsheet structure

Key Classes

Usage Example - Single ProcessSystem

// Build graph from existing ProcessSystem
ProcessSystem system = new ProcessSystem();
// ... add units ...
ProcessGraph graph = ProcessGraphBuilder.buildGraph(system);

// Get derived calculation order (topology-based, not insertion-based)
List<ProcessEquipmentInterface> calcOrder = graph.getCalculationOrder();

// Detect cycles (recycle loops)
ProcessGraph.CycleAnalysisResult cycles = graph.analyzeCycles();
if (cycles.hasCycles()) {
  System.out.println("Found " + cycles.getCycleCount() + " recycle loops");
}

// Partition for parallel execution
ProcessGraph.ParallelPartition partition = graph.partitionForParallelExecution();
for (List<ProcessNode> level : partition.getLevels()) {
  // Units in each level can be executed in parallel
  level.parallelStream().forEach(node -> node.getEquipment().run());
}

// Get GNN-compatible tensors for AI analysis
double[][] nodeFeatures = graph.getNodeFeatureMatrix();
int[][] edgeIndex = graph.getEdgeIndexTensor();
double[][] edgeFeatures = graph.getEdgeFeatureMatrix();

Usage Example - Combined ProcessSystems (ProcessModule)

// Create a module combining multiple process systems
ProcessModule plant = new ProcessModule("Gas Processing Plant");
plant.add(separationSystem);
plant.add(compressionSystem);
plant.add(exportSystem);

// Build hierarchical graph
ProcessModelGraph modelGraph = plant.buildModelGraph();

// Analyze the combined structure
System.out.println("Sub-systems: " + modelGraph.getSubSystemCount());
System.out.println("Total equipment: " + modelGraph.getTotalNodeCount());
System.out.println("Inter-system connections: " + modelGraph.getInterSystemConnectionCount());

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

// Analyze inter-system connections
for (ProcessModelGraph.InterSystemConnection conn : modelGraph.getInterSystemConnections()) {
  System.out.println(conn); // e.g., "Separation[outlet] -> Compression[feed]"
}

// Get summary
System.out.println(modelGraph.getSummary());

Graph Neural Network Compatibility

The graph representation is designed for compatibility with Graph Neural Networks:

  • Node features: one-hot equipment type, in/out degree, operating conditions
  • Edge features: edge type, stream properties, back-edge indicator
  • COO format edge index tensor for sparse representation
  • Adjacency matrix and list representations available
See Also: