Class RecycleController
- All Implemented Interfaces:
Serializable
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 Summary
FieldsModifier and TypeFieldDescriptionprivate BroydenAcceleratorCoordinated Broyden accelerator for multi-recycle systems.private int(package private) static org.apache.logging.log4j.LoggerLogger object for class.private intprivate intprivate static final longSerialization version UID.private booleanWhether to use coordinated acceleration across all recycles at current priority. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRecycle(Recycle recycle) addRecycle.private voidapplyAcceleratedValuesToRecycle(Recycle recycle, double[] values) Applies accelerated values to a recycle's outlet stream.voidclear()clear.booleandoSolveRecycle(Recycle recycle) doSolveRecycle.booleanprivate double[]extractRecycleInputValues(Recycle recycle) Extracts input values from a recycle's last iteration stream.private double[]extractRecycleOutputValues(Recycle recycle) Extracts output values from a recycle's mixed stream (after mixing inputs).Gets convergence diagnostics for the current state.double[][]Gets the raw inverse Jacobian matrix from the Broyden accelerator.Gets the coordinated Broyden accelerator.intGetter for the fieldcurrentPriorityLevel.doubleGets the maximum residual error across all recycles at current priority.intGets the number of recycles managed by this controller.Gets all recycles managed by this controller.Gets all recycles at the current priority level.Gets the sensitivity matrix from the Broyden convergence Jacobian.Gets the names of tear stream variables in Jacobian order.intGets the total iteration count across all recycles.inthashCode()booleanhasHigherPriorityLevel.booleanhasLoverPriorityLevel.booleanChecks if sensitivity data is available from convergence.voidinit()Initializes the controller for a new convergence cycle.booleanisHighestPriority(Recycle recycle) isHighestPriority.booleanChecks if coordinated multi-recycle acceleration is enabled.voidnextPriorityLevel.voidresetAll()Resets all recycles and the coordinated accelerator for a new convergence cycle.voidresetPriorityLevel.booleanPerforms simultaneous modular solving for all recycles at the current priority level.voidSets the acceleration method for all recycles managed by this controller.voidsetAccelerationMethod(AccelerationMethod method, int priority) Sets the acceleration method for recycles at the specified priority level.voidsetCurrentPriorityLevel(int currentPriorityLevel) Setter for the fieldcurrentPriorityLevel.voidsetUseCoordinatedAcceleration(boolean useCoordinatedAcceleration) Enables or disables coordinated Broyden acceleration across all recycles at the same priority.booleansolvedAll.booleansolvedCurrentPriorityLevel.
-
Field Details
-
logger
static org.apache.logging.log4j.Logger loggerLogger object for class. -
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
recycleArray
-
priorityArray
-
currentPriorityLevel
private int currentPriorityLevel -
minimumPriorityLevel
private int minimumPriorityLevel -
maximumPriorityLevel
private int maximumPriorityLevel -
coordinatedAccelerator
Coordinated Broyden accelerator for multi-recycle systems. -
useCoordinatedAcceleration
private boolean useCoordinatedAccelerationWhether 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
-
doSolveRecycle
-
isHighestPriority
-
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
-
equals
-
setAccelerationMethod
Sets the acceleration method for all recycles managed by this controller.- Parameters:
method- the acceleration method to use
-
setAccelerationMethod
Sets the acceleration method for recycles at the specified priority level.- Parameters:
method- the acceleration method to usepriority- 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
Gets the coordinated Broyden accelerator.- Returns:
- the coordinated accelerator, or null if not using coordinated acceleration
-
getRecyclesAtCurrentPriority
-
getRecycleCount
public int getRecycleCount()Gets the number of recycles managed by this controller.- Returns:
- number of recycles
-
getRecycles
-
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:
- Extracts current tear stream values from all recycles at current priority
- Runs all equipment between tear streams to get updated outputs
- Applies global Broyden acceleration to the combined variable vector
- Updates all tear streams with accelerated values
- Returns:
- true if all recycles at current priority are converged
-
extractRecycleInputValues
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
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
Applies accelerated values to a recycle's outlet stream.- Parameters:
recycle- the recycle to updatevalues- 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
Gets convergence diagnostics for the current state.- Returns:
- diagnostic string with convergence information
-
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
-
hasSensitivityData
public boolean hasSensitivityData()Checks if sensitivity data is available from convergence.- Returns:
- true if Broyden Jacobian is available
-