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

Rpg implementation of the Anderson Mixing iterator. More...

#include <AmIteratorGrid.h>

Inheritance diagram for Pscf::Rpg::AmIteratorGrid< D >:
Pscf::AmIteratorTmpl< Iterator< D >, DeviceArray< cudaReal > >

Public Types

using VectorT = DeviceArray<cudaReal>
 Typename for state and residual vectors.
using Base = AmIteratorTmpl<Iterator<D>, VectorT >
 Aliase for base class.

Public Member Functions

 AmIteratorGrid (System< D > &system)
 Constructor.
 ~AmIteratorGrid ()
 Destructor.
void readParameters (std::istream &in)
 Read all parameters and initialize.
void outputTimers (std::ostream &out) const
 Output timing results to log file.
int solve (bool isContinuation=false)
 Iterate to a solution.
void clearTimers ()
 Clear timers.
Public Member Functions inherited from Pscf::AmIteratorTmpl< Iterator< 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.

Protected Member Functions

void setup (bool isContinuation) override
 Setup iterator just before entering iteration loop.
int verbose () const
 Verbosity level, allowed values 0, 1, or 2.
VectorT const & residual () const
 Get the current residual vector by const reference.
template<typename Type>
ScalarParam< Type > & readOptional (std::istream &in, const char *label, Type &value)
 Add and read a new optional ScalarParam < Type > object.
void readParamCompositeOptional (std::istream &in, ParamComposite &child, bool next=true)
 Add and attempt to read an optional child ParamComposite.
template<typename Type, int N>
FSArrayParam< Type, N > & readOptionalFSArray (std::istream &in, const char *label, FSArray< Type, N > &array, int size)
 Add and read an optional FSArray < Type, N > array parameter.
void setClassName (const char *className)
 Set class name string.
Protected Member Functions inherited from Pscf::AmIteratorTmpl< Iterator< 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.

Additional Inherited Members

Protected Attributes inherited from Pscf::AmIteratorTmpl< Iterator< 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::AmIteratorGrid< D >

Rpg implementation of the Anderson Mixing iterator.

Definition at line 35 of file rpg/scft/iterator/AmIteratorGrid.h.

Member Typedef Documentation

◆ VectorT

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

Typename for state and residual vectors.

Definition at line 44 of file rpg/scft/iterator/AmIteratorGrid.h.

◆ Base

template<int D>
using Pscf::Rpg::AmIteratorGrid< D >::Base = AmIteratorTmpl<Iterator<D>, VectorT >

Aliase for base class.

Definition at line 47 of file rpg/scft/iterator/AmIteratorGrid.h.

Constructor & Destructor Documentation

◆ AmIteratorGrid()

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

Constructor.

Parameters
systemparent system object

Definition at line 33 of file rpg/scft/iterator/AmIteratorGrid.tpp.

References setClassName().

◆ ~AmIteratorGrid()

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

Destructor.

Definition at line 44 of file rpg/scft/iterator/AmIteratorGrid.tpp.

Member Function Documentation

◆ readParameters()

◆ outputTimers()

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

Output timing results to log file.

Parameters
outoutput stream for timer report

Definition at line 102 of file rpg/scft/iterator/AmIteratorGrid.tpp.

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

◆ setup()

template<int D>
void Pscf::Rpg::AmIteratorGrid< D >::setup ( bool isContinuation)
overrideprotectedvirtual

Setup iterator just before entering iteration loop.

Parameters
isContinuationIs this a continuation within a sweep?

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

Definition at line 116 of file rpg/scft/iterator/AmIteratorGrid.tpp.

References Pscf::AmIteratorTmpl< Iterator< D >, DeviceArray< cudaReal > >::AmIteratorTmpl(), and setup().

Referenced by setup().

◆ solve()

template<int D>
int Pscf::AmIteratorTmpl< Iterator, VectorT >::solve ( bool isContinuation = false)

Iterate to a solution.

Parameters
isContinuationtrue iff continuation within a sweep
Returns
0 for convergence, 1 for failure

◆ clearTimers()

template<int D>
void Pscf::AmIteratorTmpl< Iterator, VectorT >::clearTimers ( )

Clear timers.

◆ verbose()

template<int D>
int Pscf::AmIteratorTmpl< Iterator, VectorT >::verbose ( ) const
protected

Verbosity level, allowed values 0, 1, or 2.

◆ residual()

template<int D>
VectorT const & Pscf::AmIteratorTmpl< Iterator, VectorT >::residual ( ) const
protected

Get the current residual vector by const reference.

◆ readOptional()

template<int D>
template<typename Type>
ScalarParam< Type > & Util::ParamComposite::readOptional ( std::istream & in,
const char * label,
Type & value )
inlineprotected

Add and read a new optional ScalarParam < Type > object.

This is equivalent to ScalarParam<Type>(in, label, value, false).

Parameters
ininput stream for reading
labelLabel string
valuereference to new ScalarParam< Type >

Definition at line 319 of file ParamComposite.h.

Referenced by readParameters().

◆ readParamCompositeOptional()

template<int D>
void Util::ParamComposite::readParamCompositeOptional ( std::istream & in,
ParamComposite & child,
bool next = true )
protected

Add and attempt to read an optional child ParamComposite.

Parameters
ininput stream for reading
childchild ParamComposite object
nexttrue if the indent level is one higher than parent.

Definition at line 292 of file ParamComposite.cpp.

◆ readOptionalFSArray()

template<int D>
template<typename Type, int N>
FSArrayParam< Type, N > & Util::ParamComposite::readOptionalFSArray ( std::istream & in,
const char * label,
FSArray< Type, N > & array,
int size )
inlineprotected

Add and read an optional FSArray < Type, N > array parameter.

Parameters
ininput stream for reading
labelLabel string for new array
arrayFSArray object
sizelogical size of array
Returns
reference to the new FSArrayParam<Type, N> object

Definition at line 427 of file ParamComposite.h.

Referenced by readParameters().

◆ setClassName()

template<int D>
void Util::ParamComposite::setClassName ( const char * className)
protected

Set class name string.

Should be set in subclass constructor.

Definition at line 900 of file ParamComposite.cpp.

Referenced by AmIteratorGrid().


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