DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
dftfe::MixingScheme Class Reference

This class performs the anderson mixing in a variable agnostic way This class takes can take different input variables as input in a std::vector format and computes the mixing coefficients These coefficients can then be used to compute the new variable at the start of the SCF. More...

#include <mixingClass.h>

Public Member Functions

 MixingScheme (const MPI_Comm &mpi_comm_parent, const MPI_Comm &mpi_comm_domain, const unsigned int verbosity)
 
unsigned int lengthOfHistory ()
 
void computeAndersonMixingCoeff (const std::vector< mixingVariable > mixingVariablesList)
 Computes the mixing coefficients.
 
void computeAdaptiveAndersonMixingParameter ()
 Computes the adaptive mixing parameter.
 
void popOldHistory (unsigned int mixingHistory)
 Deletes the old history if the length exceeds max length of history.
 
void clearHistory ()
 Clears all the the history.
 
void addMixingVariable (const mixingVariable mixingVariableList, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &weightDotProducts, const bool performMPIReduce, const double mixingValue, const bool adaptMixingValue)
 This function is used to add the mixing variables and its corresponding JxW values For dependent variables which are not used in mixing, the weightDotProducts is set to a vector of size zero. Later the dependent variables can be mixed with the same mixing coefficients.
 
void addVariableToInHist (const mixingVariable mixingVariableName, const double *inputVariableToInHist, const unsigned int length)
 Adds to the input history.
 
void addVariableToResidualHist (const mixingVariable mixingVariableName, const double *inputVariableToResidualHist, const unsigned int length)
 Adds to the residual history.
 
void mixVariable (const mixingVariable mixingVariableName, double *outputVariable, const unsigned int lenVar)
 Computes the input for the next iteration based on the anderson coefficients.
 
void getOptimizedResidual (const mixingVariable mixingVariableName, double *outputVariable, const unsigned int lenVar)
 
void mixPreconditionedResidual (const mixingVariable mixingVariableName, double *inputVariable, double *outputVariable, const unsigned int lenVar)
 

Private Member Functions

void computeMixingMatrices (const std::deque< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &inHist, const std::deque< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &outHist, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &weightDotProducts, const bool isPerformMixing, const bool isMPIAllReduce, std::vector< double > &A, std::vector< double > &c)
 Computes the matrix A and c vector that will be needed for anderson mixing. This function computes the A and c values for each variable which will be then added up in computeAndersonMixingCoeff()
 

Private Attributes

std::vector< double > d_A
 
std::vector< double > d_c
 
double d_cFinal
 
std::map< mixingVariable, std::deque< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > > d_variableHistoryIn
 
std::map< mixingVariable, std::deque< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > > d_variableHistoryResidual
 
std::map< mixingVariable, dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > d_vectorDotProductWeights
 
std::map< mixingVariable, bool > d_performMPIReduce
 
const MPI_Comm d_mpi_comm_domain
 
const MPI_Comm d_mpi_comm_parent
 
std::map< mixingVariable, double > d_mixingParameter
 
std::map< mixingVariable, bool > d_adaptMixingParameter
 
bool d_anyMixingParameterAdaptive
 
bool d_adaptiveMixingParameterDecLastIteration
 
bool d_adaptiveMixingParameterDecAllIterations
 
bool d_adaptiveMixingParameterIncAllIterations
 
unsigned int d_mixingHistory
 
std::map< mixingVariable, bool > d_performMixing
 
const int d_verbosity
 
dealii::ConditionalOStream pcout
 conditional stream object
 

Detailed Description

This class performs the anderson mixing in a variable agnostic way This class takes can take different input variables as input in a std::vector format and computes the mixing coefficients These coefficients can then be used to compute the new variable at the start of the SCF.

Author
Vishal Subramanian

Constructor & Destructor Documentation

◆ MixingScheme()

dftfe::MixingScheme::MixingScheme ( const MPI_Comm & mpi_comm_parent,
const MPI_Comm & mpi_comm_domain,
const unsigned int verbosity )

Member Function Documentation

◆ addMixingVariable()

void dftfe::MixingScheme::addMixingVariable ( const mixingVariable mixingVariableList,
const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > & weightDotProducts,
const bool performMPIReduce,
const double mixingValue,
const bool adaptMixingValue )

This function is used to add the mixing variables and its corresponding JxW values For dependent variables which are not used in mixing, the weightDotProducts is set to a vector of size zero. Later the dependent variables can be mixed with the same mixing coefficients.

◆ addVariableToInHist()

void dftfe::MixingScheme::addVariableToInHist ( const mixingVariable mixingVariableName,
const double * inputVariableToInHist,
const unsigned int length )

Adds to the input history.

◆ addVariableToResidualHist()

void dftfe::MixingScheme::addVariableToResidualHist ( const mixingVariable mixingVariableName,
const double * inputVariableToResidualHist,
const unsigned int length )

Adds to the residual history.

◆ clearHistory()

void dftfe::MixingScheme::clearHistory ( )

Clears all the the history.

◆ computeAdaptiveAndersonMixingParameter()

void dftfe::MixingScheme::computeAdaptiveAndersonMixingParameter ( )

Computes the adaptive mixing parameter.

◆ computeAndersonMixingCoeff()

void dftfe::MixingScheme::computeAndersonMixingCoeff ( const std::vector< mixingVariable > mixingVariablesList)

Computes the mixing coefficients.

◆ computeMixingMatrices()

void dftfe::MixingScheme::computeMixingMatrices ( const std::deque< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > & inHist,
const std::deque< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > & outHist,
const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > & weightDotProducts,
const bool isPerformMixing,
const bool isMPIAllReduce,
std::vector< double > & A,
std::vector< double > & c )
private

Computes the matrix A and c vector that will be needed for anderson mixing. This function computes the A and c values for each variable which will be then added up in computeAndersonMixingCoeff()

◆ getOptimizedResidual()

void dftfe::MixingScheme::getOptimizedResidual ( const mixingVariable mixingVariableName,
double * outputVariable,
const unsigned int lenVar )

◆ lengthOfHistory()

unsigned int dftfe::MixingScheme::lengthOfHistory ( )

◆ mixPreconditionedResidual()

void dftfe::MixingScheme::mixPreconditionedResidual ( const mixingVariable mixingVariableName,
double * inputVariable,
double * outputVariable,
const unsigned int lenVar )

◆ mixVariable()

void dftfe::MixingScheme::mixVariable ( const mixingVariable mixingVariableName,
double * outputVariable,
const unsigned int lenVar )

Computes the input for the next iteration based on the anderson coefficients.

◆ popOldHistory()

void dftfe::MixingScheme::popOldHistory ( unsigned int mixingHistory)

Deletes the old history if the length exceeds max length of history.

Member Data Documentation

◆ d_A

std::vector<double> dftfe::MixingScheme::d_A
private

◆ d_adaptiveMixingParameterDecAllIterations

bool dftfe::MixingScheme::d_adaptiveMixingParameterDecAllIterations
private

◆ d_adaptiveMixingParameterDecLastIteration

bool dftfe::MixingScheme::d_adaptiveMixingParameterDecLastIteration
private

◆ d_adaptiveMixingParameterIncAllIterations

bool dftfe::MixingScheme::d_adaptiveMixingParameterIncAllIterations
private

◆ d_adaptMixingParameter

std::map<mixingVariable, bool> dftfe::MixingScheme::d_adaptMixingParameter
private

◆ d_anyMixingParameterAdaptive

bool dftfe::MixingScheme::d_anyMixingParameterAdaptive
private

◆ d_c

std::vector<double> dftfe::MixingScheme::d_c
private

◆ d_cFinal

double dftfe::MixingScheme::d_cFinal
private

◆ d_mixingHistory

unsigned int dftfe::MixingScheme::d_mixingHistory
private

◆ d_mixingParameter

std::map<mixingVariable, double> dftfe::MixingScheme::d_mixingParameter
private

◆ d_mpi_comm_domain

const MPI_Comm dftfe::MixingScheme::d_mpi_comm_domain
private

◆ d_mpi_comm_parent

const MPI_Comm dftfe::MixingScheme::d_mpi_comm_parent
private

◆ d_performMixing

std::map<mixingVariable, bool> dftfe::MixingScheme::d_performMixing
private

◆ d_performMPIReduce

std::map<mixingVariable, bool> dftfe::MixingScheme::d_performMPIReduce
private

◆ d_variableHistoryIn

std::map< mixingVariable, std::deque< dftfe::utils::MemoryStorage<double, dftfe::utils::MemorySpace::HOST> > > dftfe::MixingScheme::d_variableHistoryIn
private

◆ d_variableHistoryResidual

std::map< mixingVariable, std::deque< dftfe::utils::MemoryStorage<double, dftfe::utils::MemorySpace::HOST> > > dftfe::MixingScheme::d_variableHistoryResidual
private

◆ d_vectorDotProductWeights

std::map< mixingVariable, dftfe::utils::MemoryStorage<double, dftfe::utils::MemorySpace::HOST> > dftfe::MixingScheme::d_vectorDotProductWeights
private

◆ d_verbosity

const int dftfe::MixingScheme::d_verbosity
private

◆ pcout

dealii::ConditionalOStream dftfe::MixingScheme::pcout
private

conditional stream object


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