DFT-EFE
 
Loading...
Searching...
No Matches
dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights > Class Template 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 <MixingScheme.h>

Collaboration diagram for dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >:

Public Types

using ValueType = linearAlgebra::blasLapack::scalar_type< ValueTypeWeights, ValueTypeMixingVariable >
 

Public Member Functions

 MixingScheme (const utils::mpi::MPIComm &mpiComm)
 
size_type lengthOfHistory ()
 
void computeAndersonMixingCoeff (const std::vector< mixingVariable > mixingVariablesList, linearAlgebra::LinAlgOpContext< utils::MemorySpace::HOST > &linAlgOpContextHost)
 Computes the mixing coefficients. More...
 
void computeAdaptiveAndersonMixingParameter ()
 Computes the adaptive mixing parameter. More...
 
void popOldHistory (size_type mixingHistory)
 Deletes the old history if the length exceeds max length of history. More...
 
void clearHistory ()
 Clears all the the history. More...
 
void addMixingVariable (const mixingVariable mixingVariableList, const utils::MemoryStorage< ValueTypeWeights, utils::MemorySpace::HOST > &weightDotProducts, const bool performMPIReduce, const double mixingValue, const bool isAdaptiveMixing)
 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. More...
 
template<utils::MemorySpace memorySpace>
void addVariableToInHist (const mixingVariable mixingVariableName, const ValueTypeMixingVariable *inputVariableToInHist, const size_type length)
 Adds to the input history. More...
 
template<utils::MemorySpace memorySpace>
void addVariableToResidualHist (const mixingVariable mixingVariableName, const ValueTypeMixingVariable *inputVariableToResidualHist, const size_type length)
 Adds to the residual history. More...
 
template<utils::MemorySpace memorySpace>
void mixVariable (const mixingVariable mixingVariableName, ValueTypeMixingVariable *outputVariable, const size_type lenVar)
 Computes the input for the next iteration based on the anderson coefficients. More...
 

Private Member Functions

void computeMixingMatrices (const std::deque< std::vector< ValueTypeMixingVariable > > &inHist, const std::deque< std::vector< ValueTypeMixingVariable > > &outHist, const utils::MemoryStorage< ValueTypeWeights, utils::MemorySpace::HOST > &weightDotProducts, const bool isPerformMixing, const bool isMPIAllReduce, std::vector< ValueType > &A, std::vector< ValueType > &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() More...
 

Private Attributes

std::vector< ValueTyped_A
 
std::vector< ValueTyped_c
 
ValueType d_cFinal
 
std::map< mixingVariable, std::deque< std::vector< ValueTypeMixingVariable > > > d_variableHistoryIn
 
std::map< mixingVariable, std::deque< std::vector< ValueTypeMixingVariable > > > d_variableHistoryResidual
 
std::map< mixingVariable, utils::MemoryStorage< ValueTypeWeights, utils::MemorySpace::HOST > > d_vectorDotProductWeights
 
std::map< mixingVariable, bool > d_performMPIReduce
 
const MPI_Comm & d_mpiComm
 
std::map< mixingVariable, double > d_mixingParameter
 
std::map< mixingVariable, bool > d_isAdaptiveMixing
 
bool d_anyMixingParameterAdaptive
 
bool d_adaptiveMixingParameterDecLastIteration
 
bool d_adaptiveMixingParameterDecAllIterations
 
bool d_adaptiveMixingParameterIncAllIterations
 
size_type d_mixingHistory
 
std::map< mixingVariable, bool > d_performMixing
 
utils::ConditionalOStream d_rootCout
 

Detailed Description

template<typename ValueTypeMixingVariable, typename ValueTypeWeights>
class dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >

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

Member Typedef Documentation

◆ ValueType

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
using dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::ValueType = linearAlgebra::blasLapack::scalar_type<ValueTypeWeights, ValueTypeMixingVariable>

Constructor & Destructor Documentation

◆ MixingScheme()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::MixingScheme ( const utils::mpi::MPIComm mpiComm)
Here is the call graph for this function:

Member Function Documentation

◆ addMixingVariable()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::addMixingVariable ( const mixingVariable  mixingVariableList,
const utils::MemoryStorage< ValueTypeWeights, utils::MemorySpace::HOST > &  weightDotProducts,
const bool  performMPIReduce,
const double  mixingValue,
const bool  isAdaptiveMixing 
)

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.

Here is the call graph for this function:

◆ addVariableToInHist()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
template<utils::MemorySpace memorySpace>
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::addVariableToInHist ( const mixingVariable  mixingVariableName,
const ValueTypeMixingVariable *  inputVariableToInHist,
const size_type  length 
)

Adds to the input history.

Here is the call graph for this function:

◆ addVariableToResidualHist()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
template<utils::MemorySpace memorySpace>
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::addVariableToResidualHist ( const mixingVariable  mixingVariableName,
const ValueTypeMixingVariable *  inputVariableToResidualHist,
const size_type  length 
)

Adds to the residual history.

Here is the call graph for this function:

◆ clearHistory()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::clearHistory

Clears all the the history.

◆ computeAdaptiveAndersonMixingParameter()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::computeAdaptiveAndersonMixingParameter

Computes the adaptive mixing parameter.

Here is the call graph for this function:

◆ computeAndersonMixingCoeff()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::computeAndersonMixingCoeff ( const std::vector< mixingVariable mixingVariablesList,
linearAlgebra::LinAlgOpContext< utils::MemorySpace::HOST > &  linAlgOpContextHost 
)

Computes the mixing coefficients.

◆ computeMixingMatrices()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::computeMixingMatrices ( const std::deque< std::vector< ValueTypeMixingVariable > > &  inHist,
const std::deque< std::vector< ValueTypeMixingVariable > > &  outHist,
const utils::MemoryStorage< ValueTypeWeights, utils::MemorySpace::HOST > &  weightDotProducts,
const bool  isPerformMixing,
const bool  isMPIAllReduce,
std::vector< ValueType > &  A,
std::vector< ValueType > &  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()

◆ lengthOfHistory()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
size_type dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::lengthOfHistory

◆ mixVariable()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
template<utils::MemorySpace memorySpace>
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::mixVariable ( const mixingVariable  mixingVariableName,
ValueTypeMixingVariable *  outputVariable,
const size_type  lenVar 
)

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

Here is the call graph for this function:

◆ popOldHistory()

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::popOldHistory ( size_type  mixingHistory)

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

Member Data Documentation

◆ d_A

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::vector<ValueType> dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_A
private

◆ d_adaptiveMixingParameterDecAllIterations

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
bool dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_adaptiveMixingParameterDecAllIterations
private

◆ d_adaptiveMixingParameterDecLastIteration

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
bool dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_adaptiveMixingParameterDecLastIteration
private

◆ d_adaptiveMixingParameterIncAllIterations

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
bool dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_adaptiveMixingParameterIncAllIterations
private

◆ d_anyMixingParameterAdaptive

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
bool dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_anyMixingParameterAdaptive
private

◆ d_c

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::vector<ValueType> dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_c
private

◆ d_cFinal

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
ValueType dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_cFinal
private

◆ d_isAdaptiveMixing

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::map<mixingVariable, bool> dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_isAdaptiveMixing
private

◆ d_mixingHistory

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
size_type dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_mixingHistory
private

◆ d_mixingParameter

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::map<mixingVariable, double> dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_mixingParameter
private

◆ d_mpiComm

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
const MPI_Comm& dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_mpiComm
private

◆ d_performMixing

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::map<mixingVariable, bool> dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_performMixing
private

◆ d_performMPIReduce

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::map<mixingVariable, bool> dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_performMPIReduce
private

◆ d_rootCout

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
utils::ConditionalOStream dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_rootCout
private

◆ d_variableHistoryIn

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::map<mixingVariable, std::deque<std::vector<ValueTypeMixingVariable> > > dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_variableHistoryIn
private

◆ d_variableHistoryResidual

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::map<mixingVariable, std::deque<std::vector<ValueTypeMixingVariable> > > dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_variableHistoryResidual
private

◆ d_vectorDotProductWeights

template<typename ValueTypeMixingVariable , typename ValueTypeWeights >
std::map<mixingVariable, utils::MemoryStorage<ValueTypeWeights, utils::MemorySpace::HOST> > dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::d_vectorDotProductWeights
private

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