ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
sto_iter.h
Go to the documentation of this file.
1#ifndef STO_ITER_H
2#define STO_ITER_H
7#include "source_psi/psi.h"
8#include "sto_che.h"
9#include "sto_func.h"
10#include "sto_wf.h"
11
12//----------------------------------------------
13// Solve for the new electron density and iterate
14// until SCF loop converges (mu, epsilon, rho)
15// mu: chemical potential
16// epsilon: eigenvalues
17// rho: charge density
18//----------------------------------------------
19
20template <typename T, typename Device = base_device::DEVICE_CPU>
22{
23 private:
24 using Real = typename GetTypeReal<T>::type;
25 public:
26 // constructor and deconstructor
29
41 void init(K_Vectors* pkv_in,
42 ModulePW::PW_Basis_K* wfc_basis,
46
58 ModulePW::PW_Basis_K* wfc_basis);
59
68 void cal_storho(const UnitCell& ucell,
71 ModulePW::PW_Basis_K* wfc_basis);
72
79 double calne(elecstate::ElecState* pes);
80
87 void itermu(const int iter, elecstate::ElecState* pes);
88
96 void orthog(const int& ik, psi::Psi<T, Device>& psi, Stochastic_WF<T, Device>& stowf);
97
106 void checkemm(const int& ik, const int istep, const int iter, Stochastic_WF<T, Device>& stowf);
107
115 void check_precision(const double ref, const double thr, const std::string info);
116
118
121
122 double mu0; // chemical potential; unit in Ry
123 bool change;
124 double targetne=0.0;
125 Real* spolyv = nullptr; //[Device] coefficients of Chebyshev expansion
126 Real* spolyv_cpu = nullptr; //[CPU] coefficients of Chebyshev expansion
127
128 public:
129 int* nchip = nullptr;
130 bool check = false;
131 double th_ne=0.0;
132 double KS_ne=0.0;
133
134 public:
135 int method; // different methods 1: slow, less memory 2: fast, more memory
136 // cal shchi = \sqrt{f(\hat{H})}|\chi>
138 // cal Pn = \sum_\chi <\chi|Tn(\hat{h})|\chi>
139 void calPn(const int& ik, Stochastic_WF<T, Device>& stowf);
140 // cal Tnchi = \sum_n C_n*T_n(\hat{h})|\chi>
141 void calTnchi_ik(const int& ik, Stochastic_WF<T, Device>& stowf);
142
143 private:
144 K_Vectors* pkv=nullptr;
151 void dot(const int& n, const Real* x, const int& incx, const Real* y, const int& incy, Real& result);
152 private:
153 const Device* ctx = {};
154 const base_device::DEVICE_CPU* cpu_ctx = {};
167};
168
169#endif // Eelectrons_Iter
Definition klist.h:13
A class to treat the Chebyshev expansion.
Definition math_chebyshev.h:84
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:57
Definition sto_che.h:9
Definition sto_func.h:6
Definition sto_iter.h:22
Stochastic_Iter()
Definition test_hsolver_sdft.cpp:97
double mu0
Definition sto_iter.h:122
bool change
Definition sto_iter.h:123
void sum_stoeband(Stochastic_WF< T, Device > &stowf, elecstate::ElecStatePW< T, Device > *pes, hamilt::Hamilt< T, Device > *pHamilt, ModulePW::PW_Basis_K *wfc_basis)
sum demet and eband energies for each k point and each band
Definition test_hsolver_sdft.cpp:167
Real * spolyv
Definition sto_iter.h:125
bool check
Definition sto_iter.h:130
void init(K_Vectors *pkv_in, ModulePW::PW_Basis_K *wfc_basis, Stochastic_WF< T, Device > &stowf, StoChe< Real, Device > &stoche, hamilt::HamiltSdftPW< T, Device > *p_hamilt_sto)
init for iteration process of SDFT
Definition test_hsolver_sdft.cpp:108
hamilt::HamiltSdftPW< T, Device > * p_hamilt_sto
Definition sto_iter.h:120
void calPn(const int &ik, Stochastic_WF< T, Device > &stowf)
Definition test_hsolver_sdft.cpp:143
void itermu(const int iter, elecstate::ElecState *pes)
solve ne(mu) = ne_target and get chemical potential mu
Definition test_hsolver_sdft.cpp:151
const base_device::DEVICE_CPU * cpu_ctx
Definition sto_iter.h:154
~Stochastic_Iter()
Definition test_hsolver_sdft.cpp:105
void check_precision(const double ref, const double thr, const std::string info)
check precision of Chebyshev expansion
Definition sto_iter.cpp:222
void cal_storho(const UnitCell &ucell, Stochastic_WF< T, Device > &stowf, elecstate::ElecStatePW< T, Device > *pes, ModulePW::PW_Basis_K *wfc_basis)
calculate the density
Definition test_hsolver_sdft.cpp:178
int * nchip
Definition sto_iter.h:129
Sto_Func< double > stofunc
Definition sto_iter.h:119
void calHsqrtchi(Stochastic_WF< T, Device > &stowf)
Definition test_hsolver_sdft.cpp:159
Real * spolyv_cpu
Definition sto_iter.h:126
void calTnchi_ik(const int &ik, Stochastic_WF< T, Device > &stowf)
Definition sto_iter.cpp:741
typename container::PsiToContainer< Device >::type ct_Device
Definition sto_iter.h:155
double th_ne
Definition sto_iter.h:131
ModuleBase::Chebyshev< double, Device > * p_che
Definition sto_iter.h:117
void dot(const int &n, const Real *x, const int &incx, const Real *y, const int &incy, Real &result)
return cpu dot result
Definition sto_iter.cpp:29
K_Vectors * pkv
Definition sto_iter.h:144
double targetne
Definition sto_iter.h:124
double KS_ne
Definition sto_iter.h:132
void checkemm(const int &ik, const int istep, const int iter, Stochastic_WF< T, Device > &stowf)
check emax and emin
Definition test_hsolver_sdft.cpp:132
int method
Definition sto_iter.h:135
double calne(elecstate::ElecState *pes)
calculate total number of electrons
Definition sto_iter.cpp:437
const Device * ctx
Definition sto_iter.h:153
void orthog(const int &ik, psi::Psi< T, Device > &psi, Stochastic_WF< T, Device > &stowf)
orthogonalize stochastic wave functions with KS wave functions
Definition test_hsolver_sdft.cpp:121
typename GetTypeReal< T >::type Real
Definition sto_iter.h:24
Definition sto_wf.h:13
Definition unitcell.h:16
Definition elecstate_pw.h:17
Definition elecstate.h:15
Definition hamilt_sdft_pw.h:11
Definition hamilt.h:16
Definition psi.h:37
Definition exx_lip.h:23
T type
Definition macros.h:8
Definition math_kernel_op.h:192
Definition memory_op.h:61
Definition memory_op.h:77
Definition memory_op.h:17
Definition memory_op.h:31
T type
Definition tensor_types.h:114
double ref(const std::vector< double > &a, const std::vector< double > &n)
Definition test_partition.cpp:63