PSCF v1.1

An Fd1d::AmIterator<D> object is an iterator that solves the 1D SCFT equations using an Anderson-Mixing algorithm.

Parameter File

An example of the parameter file format for this iterator is shown below:

AmIterator{
epsilon 1e-8
maxItr 100
maxHist 50
verbose int (0-2, 0 by default)
errorType relNorm
}

The format of this block is described more formally below:

AmIterator{
epsilon real
maxItr* int (200 by default)
maxHist* int (50 by default)
verbose* int (0-2, 0 by default)
outputTime* bool (false by default)
errorType* string ("norm", "rms", "max", or "relNorm".
"relNorm" by default)
}

Here, as elsewhere, labels followed by an asterisk (*) represent optional parameters. The meaning of the various parameters are described below:

Label Description
epsilon Desired tolerance for convergence - iteration stops if the magnitude of the error drops below epsilon
maxItr* Maximum number of iterations that will be attempted (200 by default)
maxHist* Maximum number of previous trial solultions that will be retained in memory for use by the AM algorithm (50 by default)
verbose* Optional integer with allowed values 0-2 for the level of verbosity of output to log file during iteration.
Set to 0 (concise) by default.
showTime* Optional boolean (0 or 1). Set true (1) to output a report of components of wall clock time during iteration, or (0) to skip. Set false (0) by default.
errorType* Identifer for the type of scalar error compared to epsilon to test convergence. Allowed values are "norm", "rms", "max" and "relNorm", as discussed below. Optional, and set to "relNorm" by default.

The iterative loop exits if the number of iterations has reached maxItr or if the magnitude of the scalar error is less than epsilon.

errorType : Several different definitions may be used for the scalar error, depending on the value of the identifier errorType.

  • If errorType == norm, then the scalar error is take to be the L2 norm of the residual vector defined below (i.e., the sum of the squares of all residual elements).
  • If errorType == rms, then the scalar error is the root mean squared magnitude per element. This is equal to the L2 norm divided by the square root of the number of elements.
  • If errorType == max, then the scalar error is take to be the maximum of the absolute magnitude of the elements of the residual vector (the L infinity norm of the residual vector).
  • If errorType == norm, then the scalar error is take to be the ratio of the L2 norm of the residual vector to the L2 norm of the w field, as in Stasiak and Matsen, Eur. Phys, Journel E, 2012.

Residual Definition

The algorithm is designed to reduce the values of the elements of a vector of residuals (i.e., errors) until they are zero to within some tolerance, as defined by one of the scalar norms discussed above. The definition of the vector of residuals used in this algorithm is analogous to that given in Eq. (10) of the article by Arora et al. [Arora, Morse, Bates and Dorfman, J. Chem. Phys. vol. 146 224902 (2017)]. The main difference is that here residual values are associated with values at grid points, rather than coefficients in the Fourier expansion used in the algorithm described in that reference. To describe the residuals expressions here, we use zero based indexing for monomer types, use \( N_{x} \) to denote the number of grid points (referred to in the parameter file and source code as nx), and use \( N_{m} \) to denote the number of monomer types (referred to elsewhere as nMonomer).

The vector of residuals for a pscf_fd calculation has \( N_{x}N_{m} \) (or nx * nMonomer) scalar residuals. Let \( w_{ia} \) and \( \phi_{ai} \) denote the values of the chemical potential field \( w_{i} \) and volume fraction \( \phi_{i} \) for monomer type i at grid point \(a\), respectively, The corresponding residual component \( R_{ai}\) associated with grid point \( a \) and monomer type \( i \) is given, by analogy to Eq. (10) of Arora et al. (JCP 2017), as

\[ R_{ai} = \sum_{j=0}^{N_{m}-1} \left ( \chi_{ij} \phi_{aj} - P_{ij}w_{aj} \right ) \quad. \]

where \( P_{ij} \) is an element of an idempotent \( N_{m} \times N_{m} \) matrix \( P \) that can be expressed in matrix notation as

\[ P = I - \frac{\epsilon \epsilon^{T} \chi^{-1} } { \epsilon^{T} \chi^{-1} \epsilon } \quad. \]

Here, \( I \) is the identity matrix, \( \chi^{-1} \) is the matrix inverse of the \(\chi\) matrix, and \(\epsilon\) is a \( N_{m} \)-component column vector with elements given by \( \epsilon_{i} = 1 \) for all \( i = 0, \ldots, N_{m}-1 \).

Closed Systems (Canonical Ensemble)

A slight modification of the residual definition is required in the case when a value of phi rather than mu is specified for every molecular species, giving a closed system, or a canonical statistical ensemble. In this case, the solution of the SCF problem is not unique, becase the values of the residuals defined above can be shown to be invariant under a shift in all of the chemical potential fields at all grid point points by any spatially homgeneous constant. To obtain a unique solution, the update procedure shifts the chemical potential fields so as to guarantee that the w field value for the last monomer type at the last grid point is forced to equal zero by convention.