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
ProcessGraph- Main graph structure with analysis methodsProcessNode- Node representing equipmentProcessEdge- Edge representing stream connectionsProcessGraphBuilder- Builds graph from ProcessSystemProcessModelGraph- Hierarchical graph for combined ProcessSystems in a ProcessModuleProcessModelGraphBuilder- Builds hierarchical graphs from ProcessModule
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:
-
ClassDescriptionRepresents a directed edge in the process flowsheet graph.Edge types representing different connection types in process flowsheets.Represents a process flowsheet as an explicit directed graph (DAG with potential cycles).Result of cycle detection analysis.Result of parallel execution partitioning.Result of strongly connected component analysis.Result of sensitivity analysis for tear stream selection.Result of tear stream selection analysis.Builder class for constructing a
ProcessGraphfrom aProcessSystem.Represents a hierarchical process model as a graph of graphs.Represents a connection between two sub-systems.Represents a partition of sub-systems into levels for parallel execution.Represents a sub-system (ProcessSystem) within the model.Builder class for constructing aProcessModelGraphfrom aProcessModule.Represents a node in the process flowsheet graph.