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

#include <charge_mixing.h>

Collaboration diagram for Charge_Mixing:

Public Member Functions

 Charge_Mixing ()
 
 ~Charge_Mixing ()
 
void set_mixing (const std::string &mixing_mode_in, const double &mixing_beta_in, const int &mixing_ndim_in, const double &mixing_gg0_in, const bool &mixing_tau_in, const double &mixing_beta_mag_in, const double &mixing_gg0_mag_in, const double &mixing_gg0_min_in, const double &mixing_angle_in, const bool &mixing_dmr_in, double &omega_in, double &tpiba_in)
 Set all private mixing paramters.
 
void close_kerker_gg0 ()
 
void init_mixing ()
 initialize mixing, including constructing mixing and allocating memory for mixing data
 
void allocate_mixing_dmr (const int nnr)
 allocate memory of dmr_mdata
 
void mix_rho (Charge *chr)
 charge mixing
 
void mix_dmr (elecstate::DensityMatrix< double, double > *DM)
 density matrix mixing, only for LCAO
 
void mix_dmr (elecstate::DensityMatrix< std::complex< double >, double > *DM)
 
double get_drho (Charge *chr, const double nelec)
 Get the drho between rho and rho_save, similar for get_dkin.
 
double get_dkin (Charge *chr, const double nelec)
 
void mix_reset ()
 reset mixing, actually we only call init_mixing() to reset mixing instead of this function
 
void set_rhopw (ModulePW::PW_Basis *rhopw_in, ModulePW::PW_Basis *rhodpw_in)
 Set the smooth and dense grids.
 
const std::string & get_mixing_mode () const
 
double get_mixing_beta () const
 
int get_mixing_ndim () const
 
double get_mixing_gg0 () const
 
Base_Mixing::Mixingget_mixing () const
 
bool if_scf_oscillate (const int iteration, const double drho, const int iternum_used, const double threshold)
 

Public Attributes

int mixing_restart_step = 0
 
int mixing_restart_count = 0
 
int mixing_restart_last = 0
 

Private Member Functions

void mix_rho_recip (Charge *chr)
 charge mixing for reciprocal space
 
void mix_rho_real (Charge *chr)
 charge mixing for real space
 
void Kerker_screen_recip (std::complex< double > *rhog)
 Kerker screen method for reciprocal space.
 
void Kerker_screen_real (double *rho)
 Kerker screen method for real space.
 
double inner_product_recip_rho (std::complex< double > *rho1, std::complex< double > *rho2)
 Inner product of two complex vectors.
 
double inner_product_recip_simple (std::complex< double > *rho1, std::complex< double > *rho2)
 
double inner_product_recip_hartree (std::complex< double > *rho1, std::complex< double > *rho2)
 
double inner_product_real (double *rho1, double *rho2)
 Inner product of two double vectors.
 
void divide_data (std::complex< double > *data_d, std::complex< double > *&data_s, std::complex< double > *&data_hf)
 divide rho/tau to smooth and high frequency parts
 
void combine_data (std::complex< double > *data_d, std::complex< double > *&data_s, std::complex< double > *&data_hf)
 gather smooth and high frequency parts to rho/tau
 
void clean_data (std::complex< double > *&data_s, std::complex< double > *&data_hf)
 clean smooth and high frequency parts
 

Private Attributes

Base_Mixing::Mixingmixing = nullptr
 Mixing object to mix charge density, kinetic energy density and compensation density.
 
Base_Mixing::Mixing_Data rho_mdata
 Mixing data for charge density.
 
Base_Mixing::Mixing_Data tau_mdata
 Mixing data for kinetic energy density.
 
Base_Mixing::Mixing_Data nhat_mdata
 Mixing data for compensation density.
 
Base_Mixing::Mixing_Data dmr_mdata
 Mixing data for real space density matrix.
 
Base_Mixing::Plain_Mixingmixing_highf = nullptr
 The high_frequency part is mixed by plain mixing method.
 
std::string mixing_mode = "broyden"
 mixing mode: "plain", "broyden", "pulay"
 
double mixing_beta = 0.8
 mixing beta for density
 
double mixing_beta_mag = 1.6
 mixing beta for magnetism
 
int mixing_ndim = 8
 mixing ndim for broyden and pulay
 
double mixing_gg0 = 0.0
 mixing gg0 for Kerker screen
 
bool mixing_tau = false
 whether to use tau mixing
 
double mixing_gg0_mag = 0.0
 mixing gg0 for Kerker screen for magnetism
 
double mixing_gg0_min = 0.1
 minimum kerker coefficient
 
double mixing_angle = 0.0
 mixing angle for nspin=4
 
bool mixing_dmr = false
 whether to mixing real space density matrix
 
double * omega = nullptr
 omega for non-linear core correction
 
double * tpiba = nullptr
 2*pi/beta for non-linear core correction
 
double * tpiba2 = nullptr
 2*pi/beta^2 for non-linear core correction
 
std::vector< double > _drho_history
 history of drho used to determine the oscillation, size is scf_nmax
 
bool new_e_iteration = true
 
ModulePW::PW_Basisrhopw = nullptr
 smooth grid
 
ModulePW::PW_Basisrhodpw = nullptr
 dense grid, same as rhopw for ncpp.
 

Constructor & Destructor Documentation

◆ Charge_Mixing()

Charge_Mixing::Charge_Mixing ( )

Charge_Mixing class This class is used to mix charge density, kinetic energy density and real-space density matrix This Charge_Mixing class offers the following interfaces:

  1. set_mixing() to set all private mixing parameters
  2. init_mixing() to initialize mixing, including allocating memory for mixing data and reset mixing
  3. mix_rho() to mix charge density
  4. mix_dmr() to mix real-space density matrix how to use it: you can (re)start a mixing by calling set_mixing() and init_mixing() before calling mix_rho() or mix_dmr()

◆ ~Charge_Mixing()

Charge_Mixing::~Charge_Mixing ( )

Member Function Documentation

◆ allocate_mixing_dmr()

void Charge_Mixing::allocate_mixing_dmr ( const int  nnr)

allocate memory of dmr_mdata

Parameters
nnrsize of real-space density matrix
Here is the call graph for this function:

◆ clean_data()

void Charge_Mixing::clean_data ( std::complex< double > *&  data_s,
std::complex< double > *&  data_hf 
)
private

clean smooth and high frequency parts

Parameters
data_ddense data
data_ssmooth data
data_hfhigh frequency data = dense data - smooth data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ close_kerker_gg0()

void Charge_Mixing::close_kerker_gg0 ( )
inline
Here is the caller graph for this function:

◆ combine_data()

void Charge_Mixing::combine_data ( std::complex< double > *  data_d,
std::complex< double > *&  data_s,
std::complex< double > *&  data_hf 
)
private

gather smooth and high frequency parts to rho/tau

Parameters
data_ddense data
data_ssmooth data
data_hfhigh frequency data = dense data - smooth data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ divide_data()

void Charge_Mixing::divide_data ( std::complex< double > *  data_d,
std::complex< double > *&  data_s,
std::complex< double > *&  data_hf 
)
private

divide rho/tau to smooth and high frequency parts

Parameters
data_ddense data
data_ssmooth data
data_hfhigh frequency data = dense data - smooth data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_dkin()

double Charge_Mixing::get_dkin ( Charge chr,
const double  nelec 
)
Here is the call graph for this function:

◆ get_drho()

double Charge_Mixing::get_drho ( Charge chr,
const double  nelec 
)

Get the drho between rho and rho_save, similar for get_dkin.

Here is the call graph for this function:

◆ get_mixing()

Base_Mixing::Mixing * Charge_Mixing::get_mixing ( ) const
inline
Here is the caller graph for this function:

◆ get_mixing_beta()

double Charge_Mixing::get_mixing_beta ( ) const
inline
Here is the caller graph for this function:

◆ get_mixing_gg0()

double Charge_Mixing::get_mixing_gg0 ( ) const
inline
Here is the caller graph for this function:

◆ get_mixing_mode()

const std::string & Charge_Mixing::get_mixing_mode ( ) const
inline
Here is the caller graph for this function:

◆ get_mixing_ndim()

int Charge_Mixing::get_mixing_ndim ( ) const
inline
Here is the caller graph for this function:

◆ if_scf_oscillate()

bool Charge_Mixing::if_scf_oscillate ( const int  iteration,
const double  drho,
const int  iternum_used,
const double  threshold 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_mixing()

void Charge_Mixing::init_mixing ( )

initialize mixing, including constructing mixing and allocating memory for mixing data

this function should be called at eachiterinit()

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner_product_real()

double Charge_Mixing::inner_product_real ( double *  rho1,
double *  rho2 
)
private

Inner product of two double vectors.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner_product_recip_hartree()

double Charge_Mixing::inner_product_recip_hartree ( std::complex< double > *  rho1,
std::complex< double > *  rho2 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner_product_recip_rho()

double Charge_Mixing::inner_product_recip_rho ( std::complex< double > *  rho1,
std::complex< double > *  rho2 
)
private

Inner product of two complex vectors.

inner_product_recip_rho is used for charge, like get_drho()

inner_product_recip_hartree and inner_product_recip_simple are used for charge mixing

inner_product_recip_simple is only used for test

Actually, I am not sure if the definition of inner product for NSPIN=4 is correct, need to be checked.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner_product_recip_simple()

double Charge_Mixing::inner_product_recip_simple ( std::complex< double > *  rho1,
std::complex< double > *  rho2 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kerker_screen_real()

void Charge_Mixing::Kerker_screen_real ( double *  rho)
private

Kerker screen method for real space.

Parameters
rhocharge density in real space

consider a resize for mixing_angle

implement Kerker for density and magnetization separately

inverse FT

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kerker_screen_recip()

void Charge_Mixing::Kerker_screen_recip ( std::complex< double > *  rhog)
private

Kerker screen method for reciprocal space.

Parameters
rhogcharge density in reciprocal space

consider a resize for mixing_angle

implement Kerker for density and magnetization separately

new mixing method only support nspin=2 not nspin=4

Here is the caller graph for this function:

◆ mix_dmr() [1/2]

void Charge_Mixing::mix_dmr ( elecstate::DensityMatrix< double, double > *  DM)

density matrix mixing, only for LCAO

Parameters
DMpointer of DensityMatrix object
Here is the call graph for this function:

◆ mix_dmr() [2/2]

void Charge_Mixing::mix_dmr ( elecstate::DensityMatrix< std::complex< double >, double > *  DM)
Here is the call graph for this function:

◆ mix_reset()

void Charge_Mixing::mix_reset ( )

reset mixing, actually we only call init_mixing() to reset mixing instead of this function

Here is the call graph for this function:

◆ mix_rho()

void Charge_Mixing::mix_rho ( Charge chr)

charge mixing

Parameters
chrpointer of Charge object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mix_rho_real()

void Charge_Mixing::mix_rho_real ( Charge chr)
private

charge mixing for real space

Parameters
chrpointer of Charge object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mix_rho_recip()

void Charge_Mixing::mix_rho_recip ( Charge chr)
private

charge mixing for reciprocal space

Parameters
chrpointer of Charge object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_mixing()

void Charge_Mixing::set_mixing ( const std::string &  mixing_mode_in,
const double &  mixing_beta_in,
const int &  mixing_ndim_in,
const double &  mixing_gg0_in,
const bool &  mixing_tau_in,
const double &  mixing_beta_mag_in,
const double &  mixing_gg0_mag_in,
const double &  mixing_gg0_min_in,
const double &  mixing_angle_in,
const bool &  mixing_dmr_in,
double &  omega_in,
double &  tpiba_in 
)

Set all private mixing paramters.

Parameters
mixing_mode_inmixing mode: "plain", "broyden", "pulay"
mixing_beta_inmixing beta
mixing_ndim_inmixing ndim
mixing_gg0_inmixing gg0 for Kerker screen
mixing_tau_inwhether to use tau mixing
mixing_beta_mag_inmixing beta for magnetism
mixing_gg0_mag_inmixing gg0 for Kerker screen for magnetism
mixing_gg0_min_inminimum kerker coefficient
mixing_angle_inmixing angle for nspin=4
mixing_dmr_inwhether to mixing real space density matrix
omega_inomega for non-linear core correction
tpiba_in2*pi/beta for non-linear core correction
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_rhopw()

void Charge_Mixing::set_rhopw ( ModulePW::PW_Basis rhopw_in,
ModulePW::PW_Basis rhodpw_in 
)

Set the smooth and dense grids.

Parameters
rhopw_insmooth grid
rhodpw_indense grid when double grid is used, otherwise same as rhopw
Here is the caller graph for this function:

Member Data Documentation

◆ _drho_history

std::vector<double> Charge_Mixing::_drho_history
private

history of drho used to determine the oscillation, size is scf_nmax

◆ dmr_mdata

Base_Mixing::Mixing_Data Charge_Mixing::dmr_mdata
private

Mixing data for real space density matrix.

◆ mixing

Base_Mixing::Mixing* Charge_Mixing::mixing = nullptr
private

Mixing object to mix charge density, kinetic energy density and compensation density.

◆ mixing_angle

double Charge_Mixing::mixing_angle = 0.0
private

mixing angle for nspin=4

◆ mixing_beta

double Charge_Mixing::mixing_beta = 0.8
private

mixing beta for density

◆ mixing_beta_mag

double Charge_Mixing::mixing_beta_mag = 1.6
private

mixing beta for magnetism

◆ mixing_dmr

bool Charge_Mixing::mixing_dmr = false
private

whether to mixing real space density matrix

◆ mixing_gg0

double Charge_Mixing::mixing_gg0 = 0.0
private

mixing gg0 for Kerker screen

◆ mixing_gg0_mag

double Charge_Mixing::mixing_gg0_mag = 0.0
private

mixing gg0 for Kerker screen for magnetism

◆ mixing_gg0_min

double Charge_Mixing::mixing_gg0_min = 0.1
private

minimum kerker coefficient

◆ mixing_highf

Base_Mixing::Plain_Mixing* Charge_Mixing::mixing_highf = nullptr
private

The high_frequency part is mixed by plain mixing method.

◆ mixing_mode

std::string Charge_Mixing::mixing_mode = "broyden"
private

mixing mode: "plain", "broyden", "pulay"

◆ mixing_ndim

int Charge_Mixing::mixing_ndim = 8
private

mixing ndim for broyden and pulay

◆ mixing_restart_count

int Charge_Mixing::mixing_restart_count = 0

◆ mixing_restart_last

int Charge_Mixing::mixing_restart_last = 0

◆ mixing_restart_step

int Charge_Mixing::mixing_restart_step = 0

◆ mixing_tau

bool Charge_Mixing::mixing_tau = false
private

whether to use tau mixing

◆ new_e_iteration

bool Charge_Mixing::new_e_iteration = true
private

◆ nhat_mdata

Base_Mixing::Mixing_Data Charge_Mixing::nhat_mdata
private

Mixing data for compensation density.

◆ omega

double* Charge_Mixing::omega = nullptr
private

omega for non-linear core correction

◆ rho_mdata

Base_Mixing::Mixing_Data Charge_Mixing::rho_mdata
private

Mixing data for charge density.

◆ rhodpw

ModulePW::PW_Basis* Charge_Mixing::rhodpw = nullptr
private

dense grid, same as rhopw for ncpp.

◆ rhopw

ModulePW::PW_Basis* Charge_Mixing::rhopw = nullptr
private

smooth grid

◆ tau_mdata

Base_Mixing::Mixing_Data Charge_Mixing::tau_mdata
private

Mixing data for kinetic energy density.

◆ tpiba

double* Charge_Mixing::tpiba = nullptr
private

2*pi/beta for non-linear core correction

◆ tpiba2

double* Charge_Mixing::tpiba2 = nullptr
private

2*pi/beta^2 for non-linear core correction


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