Class BroydenAccelerator

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

public class BroydenAccelerator extends Object implements Serializable
Broyden's quasi-Newton acceleration method for multi-variable recycle convergence.

This class implements Broyden's "good" method for accelerating the convergence of multi-variable fixed-point iteration problems, particularly suited for process simulations with multiple coupled recycle streams.

The method approximates the Jacobian matrix of the fixed-point function and updates it using rank-one corrections based on the secant condition. This avoids the expensive computation of numerical derivatives while still providing Newton-like convergence.

Broyden's update formula: B_{k+1} = B_k + (delta_f - B_k * delta_x) * delta_x^T / (delta_x^T * delta_x)

Where: - B_k is the current Jacobian approximation (stored as inverse for efficiency) - delta_x = x_k - x_{k-1} (change in input) - delta_f = f(x_k) - f(x_{k-1}) (change in residual)

Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    Minimum number of iterations before applying acceleration.
    private int
    Number of variables being accelerated.
    private static final double
    Tolerance for detecting near-zero denominators.
    private double[][]
    Inverse Jacobian approximation (stored for efficiency using Sherman-Morrison).
    private int
    Number of iterations performed.
    private static final org.apache.logging.log4j.Logger
    Logger object for class.
    private double
    Maximum step size to prevent divergence.
    private double[]
    Previous iteration residual values (f(x) = g(x) - x).
    private double[]
    Previous iteration input values.
    private double
    Relaxation factor for damping updates (0 < factor <= 1).
    private static final long
    Serialization version UID.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Broyden accelerator.
    BroydenAccelerator(int dimension)
    Creates a new Broyden accelerator with specified dimension.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    accelerate(double[] currentX, double[] functionOutput)
    Computes the accelerated next iterate using Broyden's method.
    private double
    dotProduct(double[] a, double[] b)
    Computes dot product of two vectors.
    int
    Gets the number of delay iterations before acceleration starts.
    int
    Gets the dimension of the problem.
    double[][]
    Gets a copy of the current inverse Jacobian approximation.
    int
    Gets the current iteration count.
    double
    Gets the maximum step size.
    double
    Gets the relaxation factor.
    double
    Gets the current residual norm (||f(x)||).
    void
    initialize(int dim)
    Initializes the accelerator for a given dimension.
    private double[]
    matrixVectorMultiply(double[][] matrix, double[] vector)
    Multiplies a matrix by a vector.
    void
    Resets the accelerator state while keeping the dimension.
    void
    setDelayIterations(int delayIterations)
    Sets the number of delay iterations before acceleration starts.
    void
    setMaxStepSize(double maxStepSize)
    Sets the maximum step size to prevent divergence.
    void
    setRelaxationFactor(double relaxationFactor)
    Sets the relaxation factor for damping updates.
    private void
    updateInverseJacobian(double[] deltaX, double[] deltaF)
    Updates the inverse Jacobian approximation using Broyden's "good" method.
    private double
    vectorNorm(double[] v)
    Computes Euclidean norm of a vector.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

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

      private static final org.apache.logging.log4j.Logger logger
      Logger object for class.
    • dimension

      private int dimension
      Number of variables being accelerated.
    • inverseJacobian

      private double[][] inverseJacobian
      Inverse Jacobian approximation (stored for efficiency using Sherman-Morrison).
    • previousX

      private double[] previousX
      Previous iteration input values.
    • previousF

      private double[] previousF
      Previous iteration residual values (f(x) = g(x) - x).
    • iterationCount

      private int iterationCount
      Number of iterations performed.
    • delayIterations

      private int delayIterations
      Minimum number of iterations before applying acceleration.
    • relaxationFactor

      private double relaxationFactor
      Relaxation factor for damping updates (0 < factor <= 1).
    • maxStepSize

      private double maxStepSize
      Maximum step size to prevent divergence.
    • EPSILON

      private static final double EPSILON
      Tolerance for detecting near-zero denominators.
      See Also:
  • Constructor Details

    • BroydenAccelerator

      public BroydenAccelerator()
      Creates a new Broyden accelerator.
    • BroydenAccelerator

      public BroydenAccelerator(int dimension)
      Creates a new Broyden accelerator with specified dimension.
      Parameters:
      dimension - number of variables to accelerate
  • Method Details

    • initialize

      public void initialize(int dim)
      Initializes the accelerator for a given dimension. Must be called before first use or when dimension changes.
      Parameters:
      dim - number of variables
    • reset

      public void reset()
      Resets the accelerator state while keeping the dimension.
    • accelerate

      public double[] accelerate(double[] currentX, double[] functionOutput)
      Computes the accelerated next iterate using Broyden's method.

      Given the current iterate x and the fixed-point function output g(x), this method computes an accelerated next iterate that should converge faster than direct substitution (x_{n+1} = g(x_n)).

      Parameters:
      currentX - current input values (x_n)
      functionOutput - output from fixed-point function (g(x_n))
      Returns:
      accelerated next iterate
    • updateInverseJacobian

      private void updateInverseJacobian(double[] deltaX, double[] deltaF)
      Updates the inverse Jacobian approximation using Broyden's "good" method.

      Uses Sherman-Morrison formula for efficient rank-one update of the inverse: B^{-1}_{k+1} = B^{-1}_k + (delta_x - B^{-1}_k * delta_f) * delta_x^T * B^{-1}_k / (delta_x^T * B^{-1}_k * delta_f)

      Parameters:
      deltaX - change in input (x_k - x_{k-1})
      deltaF - change in residual (f_k - f_{k-1})
    • matrixVectorMultiply

      private double[] matrixVectorMultiply(double[][] matrix, double[] vector)
      Multiplies a matrix by a vector.
      Parameters:
      matrix - the matrix
      vector - the vector
      Returns:
      result vector
    • dotProduct

      private double dotProduct(double[] a, double[] b)
      Computes dot product of two vectors.
      Parameters:
      a - first vector
      b - second vector
      Returns:
      dot product
    • vectorNorm

      private double vectorNorm(double[] v)
      Computes Euclidean norm of a vector.
      Parameters:
      v - the vector
      Returns:
      norm
    • getIterationCount

      public int getIterationCount()
      Gets the current iteration count.
      Returns:
      iteration count
    • getDelayIterations

      public int getDelayIterations()
      Gets the number of delay iterations before acceleration starts.
      Returns:
      delay iterations
    • setDelayIterations

      public void setDelayIterations(int delayIterations)
      Sets the number of delay iterations before acceleration starts.
      Parameters:
      delayIterations - number of iterations to delay
    • getRelaxationFactor

      public double getRelaxationFactor()
      Gets the relaxation factor.
      Returns:
      relaxation factor (0 < factor <= 1)
    • setRelaxationFactor

      public void setRelaxationFactor(double relaxationFactor)
      Sets the relaxation factor for damping updates. Values less than 1.0 provide damping for difficult convergence cases.
      Parameters:
      relaxationFactor - factor between 0 and 1
    • getMaxStepSize

      public double getMaxStepSize()
      Gets the maximum step size.
      Returns:
      maximum step size
    • setMaxStepSize

      public void setMaxStepSize(double maxStepSize)
      Sets the maximum step size to prevent divergence.
      Parameters:
      maxStepSize - maximum allowed step norm
    • getDimension

      public int getDimension()
      Gets the dimension of the problem.
      Returns:
      number of variables
    • getInverseJacobian

      public double[][] getInverseJacobian()
      Gets a copy of the current inverse Jacobian approximation.
      Returns:
      copy of inverse Jacobian matrix
    • getResidualNorm

      public double getResidualNorm()
      Gets the current residual norm (||f(x)||).
      Returns:
      residual norm, or -1 if not yet computed