Class RecycleController

java.lang.Object
neqsim.process.equipment.util.RecycleController
All Implemented Interfaces:
Serializable

public class RecycleController extends Object implements Serializable
RecycleController class for managing multiple recycle streams in process simulations.

This class coordinates convergence of multiple recycle loops, supporting:

  • Priority-based sequencing of nested recycles
  • Individual acceleration methods per recycle (Wegstein, Broyden)
  • Coordinated multi-recycle Broyden acceleration for coupled systems
Version:
$Id: $Id
Author:
asmund
See Also:
  • Field Details

    • logger

      static org.apache.logging.log4j.Logger logger
      Logger object for class.
    • serialVersionUID

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

      ArrayList<Recycle> recycleArray
    • priorityArray

      ArrayList<Integer> priorityArray
    • currentPriorityLevel

      private int currentPriorityLevel
    • minimumPriorityLevel

      private int minimumPriorityLevel
    • maximumPriorityLevel

      private int maximumPriorityLevel
    • coordinatedAccelerator

      private transient BroydenAccelerator coordinatedAccelerator
      Coordinated Broyden accelerator for multi-recycle systems.
    • useCoordinatedAcceleration

      private boolean useCoordinatedAcceleration
      Whether to use coordinated acceleration across all recycles at current priority.
  • Constructor Details

    • RecycleController

      public RecycleController()
      Constructor for RecycleController.
  • Method Details

    • init

      public void init()
      Initializes the controller for a new convergence cycle.
    • resetPriorityLevel

      public void resetPriorityLevel()

      resetPriorityLevel.

    • addRecycle

      public void addRecycle(Recycle recycle)

      addRecycle.

      Parameters:
      recycle - a Recycle object
    • doSolveRecycle

      public boolean doSolveRecycle(Recycle recycle)

      doSolveRecycle.

      Parameters:
      recycle - a Recycle object
      Returns:
      a boolean
    • isHighestPriority

      public boolean isHighestPriority(Recycle recycle)

      isHighestPriority.

      Parameters:
      recycle - a Recycle object
      Returns:
      a boolean
    • solvedCurrentPriorityLevel

      public boolean solvedCurrentPriorityLevel()

      solvedCurrentPriorityLevel.

      Returns:
      a boolean
    • nextPriorityLevel

      public void nextPriorityLevel()

      nextPriorityLevel.

    • hasLoverPriorityLevel

      public boolean hasLoverPriorityLevel()

      hasLoverPriorityLevel.

      Returns:
      a boolean
    • hasHigherPriorityLevel

      public boolean hasHigherPriorityLevel()

      hasHigherPriorityLevel.

      Returns:
      a boolean
    • solvedAll

      public boolean solvedAll()

      solvedAll.

      Returns:
      a boolean
    • clear

      public void clear()

      clear.

    • getCurrentPriorityLevel

      public int getCurrentPriorityLevel()

      Getter for the field currentPriorityLevel.

      Returns:
      a int
    • setCurrentPriorityLevel

      public void setCurrentPriorityLevel(int currentPriorityLevel)

      Setter for the field currentPriorityLevel.

      Parameters:
      currentPriorityLevel - a int
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • setAccelerationMethod

      public void setAccelerationMethod(AccelerationMethod method)
      Sets the acceleration method for all recycles managed by this controller.
      Parameters:
      method - the acceleration method to use
    • setAccelerationMethod

      public void setAccelerationMethod(AccelerationMethod method, int priority)
      Sets the acceleration method for recycles at the specified priority level.
      Parameters:
      method - the acceleration method to use
      priority - the priority level to apply to
    • isUseCoordinatedAcceleration

      public boolean isUseCoordinatedAcceleration()
      Checks if coordinated multi-recycle acceleration is enabled.
      Returns:
      true if coordinated acceleration is enabled
    • setUseCoordinatedAcceleration

      public void setUseCoordinatedAcceleration(boolean useCoordinatedAcceleration)
      Enables or disables coordinated Broyden acceleration across all recycles at the same priority.

      When enabled, all recycles at the current priority level will share a single Broyden accelerator, treating the combined tear stream values as a single multi-variable system. This can improve convergence for tightly coupled recycle loops.

      When disabled (default), each recycle uses its own acceleration method independently.

      Parameters:
      useCoordinatedAcceleration - true to enable coordinated acceleration
    • getCoordinatedAccelerator

      public BroydenAccelerator getCoordinatedAccelerator()
      Gets the coordinated Broyden accelerator.
      Returns:
      the coordinated accelerator, or null if not using coordinated acceleration
    • getRecyclesAtCurrentPriority

      public List<Recycle> getRecyclesAtCurrentPriority()
      Gets all recycles at the current priority level.
      Returns:
      list of recycles at current priority
    • getRecycleCount

      public int getRecycleCount()
      Gets the number of recycles managed by this controller.
      Returns:
      number of recycles
    • getRecycles

      public List<Recycle> getRecycles()
      Gets all recycles managed by this controller.
      Returns:
      list of all recycles
    • runSimultaneousAcceleration

      public boolean runSimultaneousAcceleration()
      Performs simultaneous modular solving for all recycles at the current priority level.

      This method collects all tear stream variables from recycles at the current priority level into a single vector and applies global Broyden acceleration. This approach can significantly improve convergence for tightly coupled recycle loops compared to solving each recycle independently.

      The algorithm:

      1. Extracts current tear stream values from all recycles at current priority
      2. Runs all equipment between tear streams to get updated outputs
      3. Applies global Broyden acceleration to the combined variable vector
      4. Updates all tear streams with accelerated values
      Returns:
      true if all recycles at current priority are converged
    • extractRecycleInputValues

      private double[] extractRecycleInputValues(Recycle recycle)
      Extracts input values from a recycle's last iteration stream.
      Parameters:
      recycle - the recycle to extract from
      Returns:
      array of [temperature, pressure, flow, mole_fractions...]
    • extractRecycleOutputValues

      private double[] extractRecycleOutputValues(Recycle recycle)
      Extracts output values from a recycle's mixed stream (after mixing inputs).
      Parameters:
      recycle - the recycle to extract from
      Returns:
      array of [temperature, pressure, flow, mole_fractions...]
    • applyAcceleratedValuesToRecycle

      private void applyAcceleratedValuesToRecycle(Recycle recycle, double[] values)
      Applies accelerated values to a recycle's outlet stream.
      Parameters:
      recycle - the recycle to update
      values - array of [temperature, pressure, flow, mole_fractions...]
    • getTotalIterations

      public int getTotalIterations()
      Gets the total iteration count across all recycles.
      Returns:
      sum of iterations from all recycles
    • getMaxResidualError

      public double getMaxResidualError()
      Gets the maximum residual error across all recycles at current priority.
      Returns:
      maximum composition error
    • resetAll

      public void resetAll()
      Resets all recycles and the coordinated accelerator for a new convergence cycle.
    • getConvergenceDiagnostics

      public String getConvergenceDiagnostics()
      Gets convergence diagnostics for the current state.
      Returns:
      diagnostic string with convergence information
    • getTearStreamSensitivityMatrix

      public SensitivityMatrix getTearStreamSensitivityMatrix()
      Gets the sensitivity matrix from the Broyden convergence Jacobian.

      This provides sensitivities computed as a byproduct of convergence, without additional simulations. The matrix represents d(output)/d(input) for tear stream variables.

      Returns:
      SensitivityMatrix from convergence, or null if not available
    • getConvergenceJacobian

      public double[][] getConvergenceJacobian()
      Gets the raw inverse Jacobian matrix from the Broyden accelerator.

      This is the direct output of the Broyden update formula, useful for advanced analysis.

      Returns:
      inverse Jacobian matrix, or null if not available
    • getTearStreamVariableNames

      public List<String> getTearStreamVariableNames()
      Gets the names of tear stream variables in Jacobian order.
      Returns:
      list of variable names corresponding to Jacobian rows/columns
    • hasSensitivityData

      public boolean hasSensitivityData()
      Checks if sensitivity data is available from convergence.
      Returns:
      true if Broyden Jacobian is available