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>
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< ValueType > | d_A |
std::vector< ValueType > | d_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 |
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.
using dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::ValueType = linearAlgebra::blasLapack::scalar_type<ValueTypeWeights, ValueTypeMixingVariable> |
dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::MixingScheme | ( | const utils::mpi::MPIComm & | mpiComm | ) |
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.
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::addVariableToInHist | ( | const mixingVariable | mixingVariableName, |
const ValueTypeMixingVariable * | inputVariableToInHist, | ||
const size_type | length | ||
) |
Adds to the input history.
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::addVariableToResidualHist | ( | const mixingVariable | mixingVariableName, |
const ValueTypeMixingVariable * | inputVariableToResidualHist, | ||
const size_type | length | ||
) |
Adds to the residual history.
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::clearHistory |
Clears all the the history.
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::computeAdaptiveAndersonMixingParameter |
Computes the adaptive mixing parameter.
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::computeAndersonMixingCoeff | ( | const std::vector< mixingVariable > | mixingVariablesList, |
linearAlgebra::LinAlgOpContext< utils::MemorySpace::HOST > & | linAlgOpContextHost | ||
) |
Computes the mixing coefficients.
|
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()
size_type dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::lengthOfHistory |
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.
void dftefe::ksdft::MixingScheme< ValueTypeMixingVariable, ValueTypeWeights >::popOldHistory | ( | size_type | mixingHistory | ) |
Deletes the old history if the length exceeds max length of history.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |