PSCF v1.3.2
Pscf::Rpg::LrAmCompressor< D > Class Template Reference

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

#include <LrAmCompressor.h>

Inheritance diagram for Pscf::Rpg::LrAmCompressor< D >:
Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >

Public Types

using VectorT = DeviceArray<cudaReal>
 Typename for field and residual vectors.

Public Member Functions

 LrAmCompressor (System< D > &system)
 Constructor.
 ~LrAmCompressor ()
 Destructor.
void readParameters (std::istream &in)
 Read all parameters and initialize.
void setup (bool isContinuation)
 Initialize just before entry to iterative loop.
int compress ()
 Compress to obtain partial saddle point w+.
void outputTimers (std::ostream &out) const
 Return compressor times contributions.
void clearTimers ()
 Clear all timers (reset accumulated time to zero).
Public Member Functions inherited from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >
 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 >, DeviceArray< cudaReal > >
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 (DeviceArray< cudaReal > &residTrial, DeviceArray< cudaReal > &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.
DeviceArray< cudaReal > const & residual () const
 Get the current residual vector by const reference.
DeviceArray< cudaReal > 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 >, DeviceArray< cudaReal > >
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 Pscf::Rpg::LrAmCompressor< D >

Anderson Mixing compressor with linear-response mixing step.

Class LrAmCompressor implements an Anderson mixing algorithm which modifies the second mixing step, estimating Jacobian by linear response of homogenous liquid instead of unity. The residual is a vector in which each that represents a deviations in the sum of volume fractions from unity.

Definition at line 44 of file rpg/fts/compressor/LrAmCompressor.h.

Member Typedef Documentation

◆ VectorT

template<int D>
using Pscf::Rpg::LrAmCompressor< D >::VectorT = DeviceArray<cudaReal>

Typename for field and residual vectors.

Definition at line 51 of file rpg/fts/compressor/LrAmCompressor.h.

Constructor & Destructor Documentation

◆ LrAmCompressor()

template<int D>
Pscf::Rpg::LrAmCompressor< D >::LrAmCompressor ( System< D > & system)

Constructor.

Parameters
systemSystem object associated with this compressor.

Definition at line 27 of file rpg/fts/compressor/LrAmCompressor.tpp.

References Util::ParamComposite::setClassName().

◆ ~LrAmCompressor()

template<int D>
Pscf::Rpg::LrAmCompressor< D >::~LrAmCompressor ( )

Destructor.

Definition at line 38 of file rpg/fts/compressor/LrAmCompressor.tpp.

Member Function Documentation

◆ readParameters()

◆ setup()

template<int D>
void Pscf::Rpg::LrAmCompressor< D >::setup ( bool isContinuation)
virtual

Initialize just before entry to iterative loop.

This function is called by the solve function before entering the loop over iterations. Store the current values of the fields at the beginning of iteration

Parameters
isContinuationtrue iff continuation within a sweep

Reimplemented from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >.

Definition at line 61 of file rpg/fts/compressor/LrAmCompressor.tpp.

References Pscf::Prdc::Cpu::FFT< D >::computeKMesh(), Pscf::Prdc::Cpu::VecOp::eqV(), and Pscf::AmIteratorTmpl< Compressor< D >, VectorT >::setup().

◆ compress()

template<int D>
int Pscf::Rpg::LrAmCompressor< D >::compress ( )

Compress to obtain partial saddle point w+.

Returns
0 for convergence, 1 for failure

Definition at line 119 of file rpg/fts/compressor/LrAmCompressor.tpp.

References Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >::solve(), and Pscf::AmIteratorTmpl< Compressor< D >, VectorT >::solve().

◆ outputTimers()

template<int D>
void Pscf::Rpg::LrAmCompressor< D >::outputTimers ( std::ostream & out) const

Return compressor times contributions.

Definition at line 239 of file rpg/fts/compressor/LrAmCompressor.tpp.

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

◆ clearTimers()

template<int D>
void Pscf::Rpg::LrAmCompressor< D >::clearTimers ( )

Clear all timers (reset accumulated time to zero).

Definition at line 250 of file rpg/fts/compressor/LrAmCompressor.tpp.

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


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