Loading...
Searching...
No Matches
q3::AndersonMixer Class Reference

#include <anderson.hpp>

+ Inheritance diagram for q3::AndersonMixer:

Public Member Functions

 AndersonMixer (Real mixing_parameter=0.7, int history_depth=8)
 
std::vector< Real > mix_one_component (const std::vector< Real > &input_density, const std::vector< Real > &output_density) override
 
std::string name () const override
 
void reset () override
 
- Public Member Functions inherited from q3::RealSpaceMixer
void initialize (const MixerEnvironment &environment) override
 Supply the representation context the mixer needs before the first mix().
 
void mix (const std::vector< std::vector< Real > > &input_density, std::vector< std::vector< Real > > &output_density, int number_of_spin_components) override
 
 Mixer (Real mixing_parameter, int history_depth)
 
void set_global_reduce (std::function< void(std::vector< Real > &)> global_reduce)
 
void set_preconditioner (Preconditioner preconditioner)
 
- Public Member Functions inherited from q3::Mixer
 Mixer (Real mixing_parameter, int history_depth)
 
virtual ~Mixer ()=default
 
int history_depth () const
 
Real last_residual_norm () const
 
Real mixing_parameter () const
 

Additional Inherited Members

- Public Types inherited from q3::RealSpaceMixer
using Preconditioner = std::function< void(std::vector< Real > &)>
 
- Protected Attributes inherited from q3::RealSpaceMixer
std::function< void(std::vector< Real > &)> global_reduce_
 
Preconditioner preconditioner_
 
- Protected Attributes inherited from q3::Mixer
int history_depth_
 
Real last_residual_norm_ {-1.0}
 
Real mixing_parameter_
 

Detailed Description

Anderson (Pulay) mixing with configurable history depth (real-space). Uses the residual minimization approach for faster SCF convergence.

Definition at line 26 of file anderson.hpp.

Constructor & Destructor Documentation

◆ AndersonMixer()

q3::AndersonMixer::AndersonMixer ( Real  mixing_parameter = 0.7,
int  history_depth = 8 
)
inlineexplicit

Definition at line 28 of file anderson.hpp.

Member Function Documentation

◆ mix_one_component()

std::vector< Real > q3::AndersonMixer::mix_one_component ( const std::vector< Real > &  input_density,
const std::vector< Real > &  output_density 
)
inlineoverridevirtual

Mix one spin component to produce the next input density.

Parameters
input_densitydensity used to build the potential (rho_in).
output_densitydensity from diagonalization/sum_band (rho_out).
Returns
mixed density for the next iteration.

Build overlap matrix A[i,j] = <R_i - R_last | R_j - R_last> and RHS b[i] = <R_i - R_last | R_last>

All dot products are accumulated locally first, then reduced together in a single MPI collective call to avoid O(history^2) synchronizations.

Single batched MPI reduction: pack rhs and upper triangle of overlap into one vector, reduce once, then unpack. This is exactly one MPI_Allreduce regardless of history depth.

Implements q3::RealSpaceMixer.

Definition at line 31 of file anderson.hpp.

References q3::lapack::dgels_(), q3::RealSpaceMixer::global_reduce_, q3::Mixer::history_depth_, q3::Mixer::mixing_parameter_, q3::RealSpaceMixer::preconditioner_, and q3::log::warn().

◆ name()

std::string q3::AndersonMixer::name ( ) const
inlineoverridevirtual

Implements q3::Mixer.

Definition at line 207 of file anderson.hpp.

◆ reset()

void q3::AndersonMixer::reset ( )
inlineoverridevirtual

Reimplemented from q3::Mixer.

Definition at line 202 of file anderson.hpp.


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