PSCF v1.3.2
LrCompressor

The LrCompressor classes used by both the pscf_pc and pscf_pg programs implements a linear-response Anderson mixing (LRAM) algorithm as described in this publication.

Two closely analogous classes named Pscf::Rpc::LrCompressor and Pscf::Rpg::LrCompressor implement this algorithm for the pscf_pc CPU and program and the pscf_pg GPU-accelerated program, respectively. These two classes implement the same step algorithm and use the same parameter file format, which are documented below.

A general discussion of compressor algorithms for PS-FTS is given here. Each LrCompressor class implements the linear response (LR) algorithm that is presented in the following publication: "Improved algorithm for identifying partial saddle-points in polymer field theoretic simulations", K. Chen and D.C. Morse, J. Chem. Phys. 162 , 243901 (2025). . This is a quasi-Newton algorithm in which linear response of an inhomogeneous ideal gas to an infinitesimal change in the pressure-like field \( W_{+}({\bf r}) \) is approximated by the analytically calculable response of a hypothetical homogeneous state of the same fluid.

Parameter file

The LR algorithm does not require any adjustable parameters that affect the progress of iteration towards a solution. The only required parameter for this algorithm is an error threshhold "epsilon". The iteration loop exits when a scalar definition of error is less than epsilon. A minimal block could thus looks something like this:

LrCompressor{
epsilon 1.0E-4
}

The full parameter block format, including several optional parameters, is shown below:

LrCompressor{
epsilon float
maxItr* int (100 by default)
verbose* int (0 by default)
errorType* string ("rms", "norm" or "max". "rms" by default)
}

Meanings of all parameters are described briefly below:

Label Description
epsilon error threshhold
maxItr* maximum number of iterations to attempt before declaring failure (100 by default)
verbose* verbosity level. Lower values are less verbose. (0 by default)
errorType* Type of norm used to define the scalar error, as discussed below. ("rms" by default)

Residual definition

The residual vector for the LrCompressor is defined in real space, as an array in which each element is associated with one node of a regular computational grid. The value \( R({\bf r}) \) of the residual element associated with a grid point located at position \( {\bf r} \) is given by

\[ R({\bf r}) = -1 + \sum_{i=1}^{N_{\rm m}} \phi_{i}({\bf r}) \]

where \( \phi_{i}({\bf r}) \) is the volume fraction of monomer type \( i \) at that grid point, and \( N_{\rm m} \) is the number of monomer types, also known as nMonomer.

Error type

The LrCompressor algorithm terminates either: (1) when the number of iterations reaches the maximum allowed value maxItr, or (2) when the value of a scalar error \( e({\bf R}) \) becomes less than a user-specified error tolerance \( \epsilon \) (or "epsilon").

Users may usually choose from among several possible definitions of the error \( e \) by assigning one of the following allowed values to a string parameter named "errorType":

  • If errorType == "rms", then the scalar error is take to be the root-mean-square magnitude of elements of the residual vector (i.e., the \( l_2 \) norm divided by the square root of the number of elements),

    \[ e = \frac{|{\bf R}|}{\sqrt{N} } = \left ( \frac{1}{N}\sum_{i=0}^{N-1} R_{i}^{2} \right)^{1/2} \]

  • If errorType == "norm", then the scalar error is take to be the \( l_2 \) norm of the residual vector \( {\bf R} \), i.e.,

    \[ e = |{\bf R}| = \left ( \sum_{i=0}^{N-1} R_{i}^{2} \right)^{1/2} \]

  • If errorType == "max", then the scalar error is take to be maximum absolute magnitude of any element in the residual vector (i.e., the \( l_{\infty} \) norm of the residual vector).

An iteration algorithm successfully converges if it terminates with \( e({\bf R}) < \epsilon \) in fewer than maxItr iterations.
Different error types require different choises for the error threshhold \( \epsilon \) (or "epsilon") to obtain comparable accuracy.