Class ProcessModule

All Implemented Interfaces:
Serializable, Runnable, SimulationInterface, NamedInterface

public class ProcessModule extends SimulationBaseClass
A class representing a process module class that can contain unit operations and other modules. Module will be runnning until all recycles in this module are solved. If no recycle in the module then run only once.
Version:
1.0
Author:
[seros]
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • logger

      private static final org.apache.logging.log4j.Logger logger
    • unitIndex

      private int unitIndex
    • recycleModules

      private final List<ProcessEquipmentInterface> recycleModules
    • addedUnitOperations

      private List<ProcessSystem> addedUnitOperations
    • operationsIndex

      private List<Integer> operationsIndex
    • addedModules

      private List<ProcessModule> addedModules
    • modulesIndex

      private List<Integer> modulesIndex
    • solved

      private boolean solved
  • Constructor Details

    • ProcessModule

      public ProcessModule(String name)
      Constructor that takes a name as a parameter.
      Parameters:
      name - the name of the process module
  • Method Details

    • add

      public void add(ProcessSystem processSystem)
      Add an unit operation to the process module.
      Parameters:
      processSystem - the process system that contains the unit operations to be added.
    • add

      public void add(ProcessModule module)
      Add a process module to the process module.
      Parameters:
      module - the process module to be added
    • getAddedUnitOperations

      public List<ProcessSystem> getAddedUnitOperations()
      Get the list of added unit operations.
      Returns:
      the list of added unit operations
    • getOperationsIndex

      public List<Integer> getOperationsIndex()
      Get the list of operations index. The operations index is used to follow the correct order of calculations.
      Returns:
      the list of operations index
    • getAddedModules

      public List<ProcessModule> getAddedModules()
      Get the list of added process modules.
      Returns:
      the list of added process modules
    • getModulesIndex

      public List<Integer> getModulesIndex()
      Get the list of module index. The module index is used to follow the correct order of calculations.
      Returns:
      the list of module index
    • run

      public void run(UUID id)

      In this method all thermodynamic and unit operations will be calculated in a steady state calculation.

      Parameters:
      id - UUID
    • checkModulesRecycles

      public void checkModulesRecycles()
      Adds all recycle operations from addedUnitOperations to recycleModules list.
    • recyclesSolved

      public boolean recyclesSolved()
      Checks if all recycle operations in recycleModules are solved.
      Returns:
      true if all recycle operations are solved, false otherwise
    • solved

      public boolean solved()

      Returns whether or not the module has been solved.

      Returns:
      a boolean
    • runAsTask

      public Future<?> runAsTask()
      Runs this module in a separate thread using the global NeqSim thread pool.

      This method submits the module to the shared NeqSimThreadPool and returns a Future that can be used to monitor completion, cancel the task, or retrieve any exceptions that occurred.

      Returns:
      a Future representing the pending completion of the task
      See Also:
    • runAsThread

      @Deprecated public Thread runAsThread()
      Deprecated.
      Use runAsTask() instead for better resource management. This method creates a new unmanaged thread directly.

      runAsThread.

      Returns:
      a Thread object
    • getUnit

      public Object getUnit(String name)
      Returns the unit with the given name from the list of added unit operations and list of added modules.
      Parameters:
      name - the name of the unit to retrieve
      Returns:
      the unit with the given name, or null if no such unit is found
    • getMeasurementDevice

      public Object getMeasurementDevice(String name)
      Returns the unit with the given name from the list of added unit operations and list of added modules.
      Parameters:
      name - the name of the unit to retrieve
      Returns:
      the unit with the given name, or null if no such unit is found
    • copy

      public ProcessModule copy()

      Create deep copy.

      Returns:
      a ProcessModule object
    • getReport

      public ArrayList<String[]> getReport()

      getReport.

      Returns:
      a ArrayList object
    • checkMassBalance

      public Map<String, ProcessSystem.MassBalanceResult> checkMassBalance(String unit)
      Check mass balance of all unit operations in all process systems within this module.
      Parameters:
      unit - unit for mass flow rate (e.g., "kg/sec", "kg/hr", "mole/sec")
      Returns:
      a map with unit operation name as key and mass balance result as value
    • checkMassBalance

      public Map<String, ProcessSystem.MassBalanceResult> checkMassBalance()
      Check mass balance of all unit operations in all process systems using kg/sec.
      Returns:
      a map with unit operation name as key and mass balance result as value in kg/sec
    • getFailedMassBalance

      public Map<String, ProcessSystem.MassBalanceResult> getFailedMassBalance(String unit, double percentThreshold)
      Get unit operations that failed mass balance check based on percentage error threshold.
      Parameters:
      unit - unit for mass flow rate (e.g., "kg/sec", "kg/hr", "mole/sec")
      percentThreshold - percentage error threshold (default: 0.1%)
      Returns:
      a map with failed unit operation names and their mass balance results
    • getFailedMassBalance

      public Map<String, ProcessSystem.MassBalanceResult> getFailedMassBalance()
      Get unit operations that failed mass balance check using kg/sec and 0.1% threshold.
      Returns:
      a map with failed unit operation names and their mass balance results
    • getFailedMassBalance

      public Map<String, ProcessSystem.MassBalanceResult> getFailedMassBalance(double percentThreshold)
      Get unit operations that failed mass balance check using specified threshold.
      Parameters:
      percentThreshold - percentage error threshold
      Returns:
      a map with failed unit operation names and their mass balance results in kg/sec
    • getReport_json

      public String getReport_json()

      getReport_json.

      Return results of simulation in json format
      Returns:
      a String
    • run_step

      public void run_step(UUID id)

      run_step

      In this method all thermodynamic and unit operations will be calculated in a steady state calculation. Sets calc identifier UUID. It does not solve recycles - only calculates one step
      Parameters:
      id - Calc identifier UUID to set.
    • buildModelGraph

      public ProcessModelGraph buildModelGraph()
      Builds a graph representation of this module and all its sub-systems.

      The returned ProcessModelGraph contains:

      • Individual graphs for each ProcessSystem
      • A unified flattened graph for the entire module
      • Information about inter-system connections
      Returns:
      the graph representation of this module
    • getCalculationOrder

      public List<ProcessEquipmentInterface> getCalculationOrder()
      Gets the topologically-sorted calculation order for all equipment in this module.

      This order respects stream dependencies across all sub-systems.

      Returns:
      list of equipment in calculation order, or null if cycles prevent ordering
    • hasRecycleLoops

      public boolean hasRecycleLoops()
      Checks if this module (or any sub-system) contains recycle loops.
      Returns:
      true if cycles exist
    • getSubSystemCount

      public int getSubSystemCount()
      Gets the number of sub-systems in this module.
      Returns:
      number of ProcessSystems and nested ProcessModules
    • getGraphSummary

      public String getGraphSummary()
      Gets a summary of the module's graph structure.
      Returns:
      human-readable summary string
    • validateStructure

      public List<String> validateStructure()
      Validates the structural integrity of this module.
      Returns:
      list of validation issues, empty if valid