ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Base_Mixing::Broyden_Mixing Class Reference

Simplified modified broyden_mixing method. Ref: D.D. Johnson PRB 38, 12807 (1988) Here the weight w0 of the error of the inverse Jacobian is set to 0 and the weight wn of the error of each previous iteration is set to same. More...

#include <broyden_mixing.h>

Inheritance diagram for Base_Mixing::Broyden_Mixing:
Collaboration diagram for Base_Mixing::Broyden_Mixing:

Public Member Functions

 Broyden_Mixing (const int &mixing_ndim)
 
 Broyden_Mixing (const int &mixing_ndim, const double &mixing_beta)
 
virtual ~Broyden_Mixing () override
 
virtual void reset () override
 reset mixing
 
virtual void push_data (Mixing_Data &mdata, const double *data_in, const double *data_out, std::function< void(double *)> screen, std::function< void(double *, const double *, const double *)> mix, const bool &need_calcoef) override
 
virtual void push_data (Mixing_Data &mdata, const std::complex< double > *data_in, const std::complex< double > *data_out, std::function< void(std::complex< double > *)> screen, std::function< void(std::complex< double > *, const std::complex< double > *, const std::complex< double > *)> mix, const bool &need_calcoef) override
 
virtual void cal_coef (const Mixing_Data &mdata, std::function< double(double *, double *)> inner_product) override
 calculate coeficients for mixing
 
virtual void cal_coef (const Mixing_Data &mdata, std::function< double(std::complex< double > *, std::complex< double > *)> inner_product) override
 
virtual void push_data (Mixing_Data &mdata, const double *data_in, const double *data_out, std::function< void(double *)> screen, std::function< void(double *, const double *, const double *)> mix, const bool &need_calcoef)=0
 
virtual void push_data (Mixing_Data &mdata, const std::complex< double > *data_in, const std::complex< double > *data_out, std::function< void(std::complex< double > *)> screen, std::function< void(std::complex< double > *, const std::complex< double > *, const std::complex< double > *)> mix, const bool &need_calcoef)=0
 
virtual void push_data (Mixing_Data &mdata, const double *data_in, const double *data_out, std::function< void(double *)> screen, const bool &need_calcoef)
 
virtual void push_data (Mixing_Data &mdata, const std::complex< double > *data_in, const std::complex< double > *data_out, std::function< void(std::complex< double > *)> screen, const bool &need_calcoef)
 
- Public Member Functions inherited from Base_Mixing::Mixing
 Mixing ()
 
virtual ~Mixing ()
 
virtual void init_mixing_data (Mixing_Data &mdata, const int &length, const size_t &type_size) const
 init mixing data
 
void mix_data (const Mixing_Data &mdata, double *data_mix)
 calculate the mixing data
 
void mix_data (const Mixing_Data &mdata, std::complex< double > *data_mix)
 

Private Member Functions

template<class FPTYPE >
void tem_push_data (Mixing_Data &mdata, const FPTYPE *data_in, const FPTYPE *data_out, std::function< void(FPTYPE *)> screen, std::function< void(FPTYPE *, const FPTYPE *, const FPTYPE *)> mix, const bool &need_calcoef)
 
template<class FPTYPE >
void tem_cal_coef (const Mixing_Data &mdata, std::function< double(FPTYPE *, FPTYPE *)> inner_product)
 calculate coeficients for mixing
 
int dFindex_move (const int &index)
 

Private Attributes

void * F = nullptr
 
void * dF = nullptr
 
Mixing_Dataaddress = nullptr
 
ModuleBase::matrix beta
 
int mixing_ndim = -1
 
int start_dF = -1
 
int ndim_cal_dF = 0
 

Additional Inherited Members

- Public Attributes inherited from Base_Mixing::Mixing
double mixing_beta = 0.7
 
std::vector< double > coef
 
int data_ndim = 1
 

Detailed Description

Simplified modified broyden_mixing method. Ref: D.D. Johnson PRB 38, 12807 (1988) Here the weight w0 of the error of the inverse Jacobian is set to 0 and the weight wn of the error of each previous iteration is set to same.

Note
Formula: F = n_out - n_in dF{i} = F_{i-1} - F{i} //different from Ref dn_in{i} = n_in_{i-1} - n_in{i} //different from Ref alpha{ij} = <dF{i}, dF{j}> beta{ij} = inv(alpha){ij} c{mk} = <dF{k}, F{m}> gamma{mn} = \sum_k c{mk} * beta{kn} n{m+1} = n_in{m} + mixing_beta*F{m} - \sum_n gamma{mn} * (dn_in{n} + mixing_beta*dF{n}) mixing_data{i} = n_in{i} + mixing_beta*F{i} n{m+1} = \sum_i coef{i} * mixing_data{i}

Constructor & Destructor Documentation

◆ Broyden_Mixing() [1/2]

Base_Mixing::Broyden_Mixing::Broyden_Mixing ( const int &  mixing_ndim)
inline

◆ Broyden_Mixing() [2/2]

Base_Mixing::Broyden_Mixing::Broyden_Mixing ( const int &  mixing_ndim,
const double &  mixing_beta 
)
inline

◆ ~Broyden_Mixing()

virtual Base_Mixing::Broyden_Mixing::~Broyden_Mixing ( )
inlineoverridevirtual

Member Function Documentation

◆ cal_coef() [1/2]

virtual void Base_Mixing::Broyden_Mixing::cal_coef ( const Mixing_Data mdata,
std::function< double(double *, double *)>  inner_product 
)
inlineoverridevirtual

calculate coeficients for mixing

Parameters
mdataMixing_Data
inner_productpointer to the inner dot function

Implements Base_Mixing::Mixing.

Here is the call graph for this function:

◆ cal_coef() [2/2]

virtual void Base_Mixing::Broyden_Mixing::cal_coef ( const Mixing_Data mdata,
std::function< double(std::complex< double > *, std::complex< double > *)>  inner_product 
)
inlineoverridevirtual

Implements Base_Mixing::Mixing.

Here is the call graph for this function:

◆ dFindex_move()

int Base_Mixing::Broyden_Mixing::dFindex_move ( const int &  index)
inlineprivate
Here is the caller graph for this function:

◆ push_data() [1/6]

void Base_Mixing::Mixing::push_data ( Mixing_Data mdata,
const double *  data_in,
const double *  data_out,
std::function< void(double *)>  screen,
const bool &  need_calcoef 
)
virtual
Parameters
mdatastore information of this iterative step
data_inx_in
data_outx_out = f(x_in)
screenpointer to the screen function for Ker-Ker mixing
need_calcoefwhether need to calculate the coef

Reimplemented from Base_Mixing::Mixing.

◆ push_data() [2/6]

virtual void Base_Mixing::Broyden_Mixing::push_data ( Mixing_Data mdata,
const double *  data_in,
const double *  data_out,
std::function< void(double *)>  screen,
std::function< void(double *, const double *, const double *)>  mix,
const bool &  need_calcoef 
)
inlineoverridevirtual
Parameters
mdatastore information of this iterative step
data_inx_in
data_outx_out = f(x_in)
screenpointer to the screen function for Ker-Ker mixing
mix(double* out, const double* in, const double* residual) calculate 'out' with 'in' and residual
need_calcoefwhether need to calculate the coef

Implements Base_Mixing::Mixing.

Here is the call graph for this function:

◆ push_data() [3/6]

virtual void Base_Mixing::Mixing::push_data ( Mixing_Data mdata,
const double *  data_in,
const double *  data_out,
std::function< void(double *)>  screen,
std::function< void(double *, const double *, const double *)>  mix,
const bool &  need_calcoef 
)
virtual
Parameters
mdatastore information of this iterative step
data_inx_in
data_outx_out = f(x_in)
screenpointer to the screen function for Ker-Ker mixing
mix(double* out, const double* in, const double* residual) calculate 'out' with 'in' and residual
need_calcoefwhether need to calculate the coef

Implements Base_Mixing::Mixing.

◆ push_data() [4/6]

void Base_Mixing::Mixing::push_data ( Mixing_Data mdata,
const std::complex< double > *  data_in,
const std::complex< double > *  data_out,
std::function< void(std::complex< double > *)>  screen,
const bool &  need_calcoef 
)
virtual

Reimplemented from Base_Mixing::Mixing.

◆ push_data() [5/6]

virtual void Base_Mixing::Broyden_Mixing::push_data ( Mixing_Data mdata,
const std::complex< double > *  data_in,
const std::complex< double > *  data_out,
std::function< void(std::complex< double > *)>  screen,
std::function< void(std::complex< double > *, const std::complex< double > *, const std::complex< double > *)>  mix,
const bool &  need_calcoef 
)
inlineoverridevirtual

Implements Base_Mixing::Mixing.

Here is the call graph for this function:

◆ push_data() [6/6]

virtual void Base_Mixing::Mixing::push_data ( Mixing_Data mdata,
const std::complex< double > *  data_in,
const std::complex< double > *  data_out,
std::function< void(std::complex< double > *)>  screen,
std::function< void(std::complex< double > *, const std::complex< double > *, const std::complex< double > *)>  mix,
const bool &  need_calcoef 
)
virtual

Implements Base_Mixing::Mixing.

◆ reset()

virtual void Base_Mixing::Broyden_Mixing::reset ( )
inlineoverridevirtual

reset mixing

Implements Base_Mixing::Mixing.

◆ tem_cal_coef()

template<class FPTYPE >
void Base_Mixing::Broyden_Mixing::tem_cal_coef ( const Mixing_Data mdata,
std::function< double(FPTYPE *, FPTYPE *)>  inner_product 
)
private

calculate coeficients for mixing

Parameters
mdataMixing_Data
inner_productpointer to the inner dot function
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tem_push_data()

template<class FPTYPE >
void Base_Mixing::Broyden_Mixing::tem_push_data ( Mixing_Data mdata,
const FPTYPE *  data_in,
const FPTYPE *  data_out,
std::function< void(FPTYPE *)>  screen,
std::function< void(FPTYPE *, const FPTYPE *, const FPTYPE *)>  mix,
const bool &  need_calcoef 
)
private
Parameters
mdatastore information of this iterative step
data_inx_in
data_outx_out = f(x_in)
screenpointer to the screen function for Ker-Ker mixing
mix(double* out, const double* in, const double* residual) calculate 'out' with 'in' and residual
need_calcoefwhether need to calculate the coef
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ address

Mixing_Data* Base_Mixing::Broyden_Mixing::address = nullptr
private

◆ beta

ModuleBase::matrix Base_Mixing::Broyden_Mixing::beta
private

◆ dF

void* Base_Mixing::Broyden_Mixing::dF = nullptr
private

◆ F

void* Base_Mixing::Broyden_Mixing::F = nullptr
private

◆ mixing_ndim

int Base_Mixing::Broyden_Mixing::mixing_ndim = -1
private

◆ ndim_cal_dF

int Base_Mixing::Broyden_Mixing::ndim_cal_dF = 0
private

◆ start_dF

int Base_Mixing::Broyden_Mixing::start_dF = -1
private

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