PSCF v1.5.0
Pscf::Rp::LrAmCompressor< D, T > Class Template Reference

Anderson mixing compressor with linear-response correction step. More...

#include <LrAmCompressor.h>

Inheritance diagram for Pscf::Rp::LrAmCompressor< D, T >:
Pscf::AmIteratorTmpl< Compressor< D, T >, BackendArray< T::Real, T > >

Public Member Functions

 LrAmCompressor (System< D, T > &system)
 Constructor.
 ~LrAmCompressor ()=default
 Destructor.
void readParameters (std::istream &in) override
 Read body of parameter file block and initialize.
int compress () override
 Compress to obtain partial saddle point field.
void clearCache () override
 Mark stored intramolecular correlation function as outdated.
void outputTimers (std::ostream &out) const override
 Return compressor time contributions.
void clearTimers () override
 Clear all timers and MDE solution counter.
Public Member Functions inherited from Pscf::AmIteratorTmpl< Compressor< D, T >, BackendArray< T::Real, T > >
 AmIteratorTmpl ()
 Constructor.
 ~AmIteratorTmpl ()
 Destructor.
int solve (bool isContinuation=false)
 Iterate to a solution.
void outputTimers (std::ostream &out) const
 Log output timing results.
void clearTimers ()
 Clear timers.

Additional Inherited Members

Protected Member Functions inherited from Pscf::AmIteratorTmpl< Compressor< D, T >, BackendArray< T::Real, T > >
void readErrorType (std::istream &in)
 Read and validate the optional errorType string parameter.
virtual bool isValidErrorType ()
 Checks if a string is a valid error type.
void readMixingParameters (std::istream &in, bool useLambdaRamp=true)
 Read optional parameters used in default correction algorithm.
void allocateAM ()
 Allocate memory required by AM algorithm, if necessary.
bool isAllocatedAM () const
 Have data structures required by the AM algorithm been allocated?
virtual void clear ()
 Clear information about history.
virtual double computeError (T &residTrial, T &stateTrial, std::string errorType, int verbose)
 Compute and return error used to test for convergence.
double lambdaRampFactor ()
 Compute ramped prefactor of mixing parameter lambda.
virtual double computeLambda ()
 Compute mixing parameter for correction step of Anderson mixing.
int verbose () const
 Verbosity level, allowed values 0, 1, or 2.
std::string errorType () const
 Get error type string.
T const & residual () const
 Get the current residual vector by const reference.
T const & state () const
 Return the current state vector by const reference.
int totalItr ()
 Return the total number of iterations needed to converge.
double timerTotal ()
 Get total time.
double timerMDE ()
 Get time spent solving the modified diffusion equation (MDE).
double timerAM ()
 Get total time for AM algorithm, excluding MDE solution.
double timerResid ()
 Get time spent computing residual.
double timerError ()
 Get time evaluating scalar error.
double timerCoeff ()
 Get time spent evaluating Anderson mixing coefficients.
double timerOmega ()
 Get time spent updating w states.
Protected Attributes inherited from Pscf::AmIteratorTmpl< Compressor< D, T >, BackendArray< T::Real, T > >
double epsilon_
 Error tolerance.
int maxItr_
 Maximum number of iterations to attempt.
int maxHist_
 Maximum number of basis vectors in AM algorithm.
int verbose_
 Verbosity level.
std::string errorType_
 Type of error criterion used to test convergence.

Detailed Description

template<int D, class T>
class Pscf::Rp::LrAmCompressor< D, T >

Anderson mixing compressor with linear-response correction step.

Class LrAmCompressor implements an Anderson mixing algorithm in which the second "correction" step is treated as a quasi-Newton step, while the Jacobian is approximated by the linear response of a hypothetical homogenous liquid. The residual is an r-grid vector in which each element represents the deviation of the sum of volume fractions from unity.

Template parameters:

  • D : dimension
  • T : backend identifier class (e.g. (CPT or CUT))
See also
Manual Page

Definition at line 51 of file LrAmCompressor.h.

Constructor & Destructor Documentation

◆ LrAmCompressor()

template<int D, class T>
Pscf::Rp::LrAmCompressor< D, T >::LrAmCompressor ( System< D, T > & system)

Constructor.

Parameters
systemparent System object

Definition at line 40 of file LrAmCompressor.tpp.

References Util::ParamComposite::setClassName(), and Pscf::Rp::Compressor< D, T >::setSystem().

Referenced by Pscf::Rp::CompressorFactory< D, CPT >::CompressorFactory().

◆ ~LrAmCompressor()

Member Function Documentation

◆ readParameters()

◆ compress()

template<int D, class T>
int Pscf::Rp::LrAmCompressor< D, T >::compress ( )
override

Compress to obtain partial saddle point field.

Returns
0 for convergence, 1 for failure

Definition at line 69 of file LrAmCompressor.tpp.

References Pscf::AmIteratorTmpl< Compressor< D, T >, BackendArray< T::Real, T > >::solve(), and Pscf::AmIteratorTmpl< Compressor< D, T >, VectorT >::solve().

Referenced by ~LrAmCompressor().

◆ clearCache()

template<int D, class T>
void Pscf::Rp::LrAmCompressor< D, T >::clearCache ( )
override

Mark stored intramolecular correlation function as outdated.

Definition at line 79 of file LrAmCompressor.tpp.

Referenced by ~LrAmCompressor().

◆ outputTimers()

template<int D, class T>
void Pscf::Rp::LrAmCompressor< D, T >::outputTimers ( std::ostream & out) const
override

Return compressor time contributions.

Parameters
outoutput stream

Definition at line 86 of file LrAmCompressor.tpp.

References Pscf::AmIteratorTmpl< Compressor< D, T >, VectorT >::outputTimers().

Referenced by ~LrAmCompressor().

◆ clearTimers()

template<int D, class T>
void Pscf::Rp::LrAmCompressor< D, T >::clearTimers ( )
override

Clear all timers and MDE solution counter.

Definition at line 97 of file LrAmCompressor.tpp.

References Pscf::AmIteratorTmpl< Compressor< D, T >, VectorT >::clearTimers(), and Pscf::Rp::Compressor< D, T >::mdeCounter_.

Referenced by ~LrAmCompressor().


The documentation for this class was generated from the following files: