ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
esolver_ks.h
Go to the documentation of this file.
1#ifndef ESOLVER_KS_H
2#define ESOLVER_KS_H
3
4#include "esolver_fp.h" // first-principles esolver
5#include "source_basis/module_pw/pw_basis_k.h" // use plane wave
6#include "source_cell/klist.h" // use k-points in Brillouin zone
7#include "source_estate/module_charge/chg_mix.h" // use charge mixing
8#include "source_hamilt/hamilt.h" // use Hamiltonian
9#include "source_hamilt/hamilt_base.h" // use Hamiltonian base class
10#include "source_hamilt/module_xc/general_exx_info.h" // ESolver owns General_Exx_Info value
11#include "source_pw/module_pwdft/dftu_base.h" // Plus_U_Base for dftu_ member
13
14#include <memory> // std::unique_ptr for dftu_ member
15
16namespace ModuleESolver
17{
18
19class ESolver_KS : public ESolver_FP
20{
21 public:
23 ESolver_KS();
24
26 virtual ~ESolver_KS();
27
28 virtual void before_all_runners(BaseCell &basecell, const Input_para &inp) override;
29
30 virtual void runner(BaseCell &basecell, const int istep) override;
31
32 virtual void after_all_runners(BaseCell &basecell) override;
33
34 protected:
36 virtual int scf_iter_limit(const int istep) const;
37
39 bool scf_loop(UnitCell &ucell, int istep, int iter_limit);
41 void record_iteration(const UnitCell &ucell, double duration);
43 void write_iter_bands();
44
46 enum class DensityStage
47 {
50 };
51
53 virtual DensityStage density_stage(const int istep, const int iter) const;
54
56 virtual void before_scf(UnitCell &ucell, const int istep) override;
57
59 virtual void iter_init(UnitCell &ucell, const int istep, const int iter);
60
62 virtual bool defer_iter_output(const int istep) const;
63
65 virtual void iter_finish(
66 UnitCell &ucell,
67 const int istep,
68 int &iter,
69 bool &conv_esolver) override;
70
71 // calculate electron density from a specific Hamiltonian with ethr
72 virtual void hamilt2rho_single(
73 UnitCell &ucell,
74 const int istep,
75 const int iter,
76 const double ethr);
77
78 // calculate electron density from a specific Hamiltonian
79 void hamilt2rho(
80 UnitCell &ucell,
81 const int istep,
82 const int iter,
83 const double ethr);
84
90 virtual std::string diag_policy(const int istep) const;
91
93 virtual void after_scf(UnitCell &ucell, const int istep, const bool conv_esolver) override;
94
97
100
103
106
109 std::unique_ptr<Plus_U_Base> dftu_;
110
111 std::string basisname;
112 double esolver_KS_ne = 0.0;
113 double diag_ethr;
114 double scf_thr;
115 double scf_ene_thr;
116 double drho;
120 double ds_rms_ = -1.0;
122 int niter;
123 bool oscillate_esolver = false; // whether esolver is oscillated
124 bool scf_nmax_flag = false; // whether scf has reached nmax, mohan add 20250921
125
133 bool scf_rerun_ = false;
134
137};
138} // namespace ModuleESolver
139#endif
Definition basecell.h:9
Definition chg_mix.h:11
ESolver_FP()
Definition esolver_fp.cpp:28
bool scf_loop(UnitCell &ucell, int istep, int iter_limit)
Run SCF iterations without preparing or committing a physical endpoint.
Definition esolver_ks.cpp:200
double scf_ene_thr
scf density threshold
Definition esolver_ks.h:115
virtual std::string diag_policy(const int istep) const
Select the diagonalization threshold and error-control policy for the current stage.
Definition esolver_ks.cpp:131
ESolver_KS()
Constructor.
Definition esolver_ks.cpp:29
int maxniter
Definition esolver_ks.h:121
double scf_thr
the threshold for diagonalization
Definition esolver_ks.h:114
virtual ~ESolver_KS()
Deconstructor.
Definition esolver_ks.cpp:31
virtual bool defer_iter_output(const int istep) const
Whether KS iterations defer output until the final state is accepted.
Definition esolver_ks.cpp:317
void write_iter_bands()
Write current band expectations when iterative band output is requested.
Definition esolver_ks.cpp:466
DensityStage
Select whether the density is an endpoint predictor or an SCF iterate.
Definition esolver_ks.h:47
@ predictor
Definition esolver_ks.h:49
@ standard
Definition esolver_ks.h:48
void record_iteration(const UnitCell &ucell, double duration)
Record an accepted iteration in JSON without changing its convergence status.
Definition esolver_ks.cpp:475
std::unique_ptr< Plus_U_Base > dftu_
Definition esolver_ks.h:109
double ds_rms_
Definition esolver_ks.h:120
virtual int scf_iter_limit(const int istep) const
Maximum SCF iterations for the current electronic step.
Definition esolver_ks.cpp:198
double esolver_KS_ne
esolver_ks_lcao.cpp
Definition esolver_ks.h:112
hamilt::HamiltBase * p_hamilt
Hamiltonian (base class pointer, actual type determined at runtime).
Definition esolver_ks.h:96
virtual void hamilt2rho_single(UnitCell &ucell, const int istep, const int iter, const double ethr)
Definition esolver_ks.cpp:123
bool scf_nmax_flag
Definition esolver_ks.h:124
int niter
maximum iter steps for scf
Definition esolver_ks.h:122
std::string basisname
Definition esolver_ks.h:111
bool oscillate_esolver
iter steps actually used in scf
Definition esolver_ks.h:123
General_Exx_Info general_exx_info_
General EXX info owned by ESolver, initialized from input parameters.
Definition esolver_ks.h:136
bool scf_rerun_
Definition esolver_ks.h:133
double hsolver_error
the difference between rho_in (before HSolver) and rho_out (After HSolver)
Definition esolver_ks.h:117
virtual void before_scf(UnitCell &ucell, const int istep) override
Something to do before SCF iterations.
Definition esolver_ks.cpp:267
virtual void before_all_runners(BaseCell &basecell, const Input_para &inp) override
Initialize of the first-principels energy solver.
Definition esolver_ks.cpp:44
virtual void after_scf(UnitCell &ucell, const int istep, const bool conv_esolver) override
Something to do after SCF iterations when SCF is converged or comes to the max iter step.
Definition esolver_ks.cpp:485
double diag_ethr
number of electrons
Definition esolver_ks.h:113
virtual DensityStage density_stage(const int istep, const int iter) const
Identify mandatory predictor stages before mixing and convergence checks.
Definition esolver_ks.cpp:312
virtual void runner(BaseCell &basecell, const int istep) override
run energy solver
Definition esolver_ks.cpp:179
pseudopot_cell_vnl ppcell
nonlocal pseudopotentials
Definition esolver_ks.h:105
virtual void after_all_runners(BaseCell &basecell) override
perform post processing calculations
Definition esolver_ks.cpp:523
double drho
scf energy threshold
Definition esolver_ks.h:116
void hamilt2rho(UnitCell &ucell, const int istep, const int iter, const double ethr)
Definition esolver_ks.cpp:133
virtual void iter_finish(UnitCell &ucell, const int istep, int &iter, bool &conv_esolver) override
Something to do after hamilt2rho function in each iter loop.
Definition esolver_ks.cpp:319
virtual void iter_init(UnitCell &ucell, const int istep, const int iter)
Something to do before hamilt2rho function in each iter loop.
Definition esolver_ks.cpp:273
ModulePW::PW_Basis_K * pw_wfc
PW for wave functions, only used in KSDFT, not in OFDFT.
Definition esolver_ks.h:99
Charge_Mixing * p_chgmix
Charge mixing method.
Definition esolver_ks.h:102
bool conv_esolver
Definition esolver.h:46
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:56
Provide the basic information about unitcell.
Definition unitcell.h:16
Base class for Hamiltonian.
Definition hamilt_base.h:17
Definition vnl_pw.h:23
The First-Principles (FP) Energy Solver Class.
Definition opt_test_tools.cpp:93
Definition general_exx_info.h:11
Definition input_parameter.h:13