ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
elecstate.h
Go to the documentation of this file.
1#ifndef ELECSTATE_H
2#define ELECSTATE_H
3
4#include "fp_energy.h"
5#include "source_cell/klist.h"
8#include "source_psi/psi.h"
10
11namespace elecstate
12{
13
15{
16 public:
18 {
19 }
21 {
22 this->charge = chr_in;
23 this->charge->set_rhopw(rhopw_in);
24 this->bigpw = bigpw_in;
26 }
27 virtual ~ElecState()
28 {
29 if (this->pot != nullptr)
30 {
31 delete this->pot;
32 this->pot = nullptr;
33 }
34 }
35 void init_ks(Charge* chr_in, // pointer for class Charge
36 const K_Vectors* klist_in,
37 int nk_in, // number of k points
38 const ModulePW::PW_Basis_Big* bigpw_in);
39
40 // return current electronic density rho, as a input for constructing Hamiltonian
41 virtual const double* getRho(int spin) const;
42
43 // calculate electronic charge density on grid points or density matrix in real space
44 // the consequence charge density rho saved into rho_out, preparing for charge mixing.
45 virtual void psiToRho(const psi::Psi<std::complex<double>>& psi)
46 {
47 return;
48 }
49 virtual void psiToRho(const psi::Psi<double>& psi)
50 {
51 return;
52 }
53 virtual void cal_tau(const psi::Psi<std::complex<double>>& psi)
54 {
55 return;
56 }
57 virtual void cal_tau(const psi::Psi<double>& psi)
58 {
59 return;
60 }
61 virtual void cal_tau(const psi::Psi<std::complex<float>>& psi)
62 {
63 return;
64 }
65
66 // update charge density for next scf step
67 // in this function, 1. input rho for construct Hamilt and 2. calculated rho from Psi will mix to 3. new charge
68 // density rho among these rho,
69 // 1. input rho would be store to file for restart
70 // 2. calculated rho should be near with input rho when convergence has achieved
71 // 3. new rho should be input rho for next scf step.
72 virtual void getNewRho()
73 {
74 return;
75 }
76
77 // use occupied weights from INPUT and skip calculate_weights
78 // mohan updated on 2024-06-08
79
80 // if nupdown is not 0(TWO_EFERMI case),
81 // nelec_spin will be fixed and weights will be constrained
82 void init_nelec_spin();
83 // used to record number of electrons per spin index
84 // for NSPIN=2, it will record number of spin up and number of spin down
85 // for NSPIN=4, it will record total number, magnetization for x, y, z direction
86 std::vector<double> nelec_spin;
87
88 virtual void print_psi(const psi::Psi<double>& psi_in, const int istep = -1)
89 {
90 return;
91 }
92 virtual void print_psi(const psi::Psi<std::complex<double>>& psi_in, const int istep = -1)
93 {
94 return;
95 }
96
105 void init_scf(const UnitCell& ucell,
106 const Parallel_Grid& pgrid,
107 const ModuleBase::ComplexMatrix& strucfac,
108 const bool* numeric,
110 const void* wfcpw = nullptr);
111 std::string classname = "elecstate";
112
113 int iter = 0;
114 Potential* pot = nullptr;
115 Charge* charge = nullptr;
116 const K_Vectors* klist = nullptr;
117 const ModulePW::PW_Basis_Big* bigpw = nullptr;
118
119 public: // something aboud energies. See elecstate_energy.cpp
120 void cal_bandgap();
121 void cal_bandgap_updw();
122
123 double cal_delta_eband(const UnitCell& ucell) const;
124 double cal_delta_escf() const;
125
127 bool vnew_exist = false;
128 void cal_converged();
129 void cal_energies(const int type);
130 void set_exx(const double& Eexx);
131 void set_exx(const std::complex<double>& Eexx);
132
133 double get_hartree_energy();
134 double get_etot_efield();
135 double get_etot_gatefield();
136
137 double get_solvent_model_Ael();
138 double get_solvent_model_Acav();
139
141 {
142 return 0.0;
143 }
144
145 double get_dftu_energy();
146 double get_local_pp_energy();
147
150
151 // below defines the bandgap:
152
153 double bandgap = 0.0;
154 double bandgap_up = 0.0;
155 double bandgap_dw = 0.0;
156
159
160 public:
161
162 bool skip_weights = false;
163};
164
165} // namespace elecstate
166#endif
Definition charge.h:18
void set_rhopw(ModulePW::PW_Basis *rhopw_in)
Definition charge.cpp:51
Definition klist.h:13
Definition complexmatrix.h:14
Definition matrix.h:19
Definition pw_basis_big.h:16
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:56
Definition symmetry.h:16
Definition parallel_grid.h:8
const System_para & globalv
Definition parameter.h:30
Definition unitcell.h:17
Definition elecstate.h:15
const ModulePW::PW_Basis_Big * bigpw
bigpw will be removed later
Definition elecstate.h:117
virtual void cal_tau(const psi::Psi< double > &psi)
Definition elecstate.h:57
ElecState(Charge *chr_in, ModulePW::PW_Basis *rhopw_in, ModulePW::PW_Basis_Big *bigpw_in)
Definition elecstate.h:20
fenergy f_en
energies contribute to the total free energy
Definition elecstate.h:148
void cal_bandgap()
calculate band gap
Definition elecstate_energy.cpp:13
void init_scf(const UnitCell &ucell, const Parallel_Grid &pgrid, const ModuleBase::ComplexMatrix &strucfac, const bool *numeric, ModuleSymmetry::Symmetry &symm, const void *wfcpw=nullptr)
Init rho_core, init rho, renormalize rho, init pot.
Definition elecstate.cpp:30
double get_etot_efield()
Definition elecstate_energy_terms.cpp:17
virtual const double * getRho(int spin) const
Definition elecstate.cpp:13
const K_Vectors * klist
pointer to k points lists
Definition elecstate.h:116
virtual void cal_tau(const psi::Psi< std::complex< float > > &psi)
Definition elecstate.h:61
double bandgap_up
spin up bandgap
Definition elecstate.h:154
virtual void print_psi(const psi::Psi< double > &psi_in, const int istep=-1)
Definition elecstate.h:88
std::string classname
Definition elecstate.h:111
Potential * pot
pointer to potential
Definition elecstate.h:114
virtual double get_spin_constrain_energy()
Definition elecstate.h:140
double get_dftu_energy()
Definition elecstate_energy_terms.cpp:37
virtual void psiToRho(const psi::Psi< std::complex< double > > &psi)
Definition elecstate.h:45
virtual void cal_tau(const psi::Psi< std::complex< double > > &psi)
Definition elecstate.h:53
ModuleBase::matrix vnew
Definition elecstate.h:126
double bandgap_dw
spin down bandgap
Definition elecstate.h:155
ModuleBase::matrix wg
occupation weight for each k-point and band
Definition elecstate.h:158
double get_hartree_energy()
Definition elecstate_energy_terms.cpp:12
double get_local_pp_energy()
Definition elecstate_energy_terms.cpp:42
double cal_delta_escf() const
calculate descf
Definition elecstate_energy.cpp:188
double bandgap
bandgap = E_{lumo} - E_{homo}
Definition elecstate.h:153
double cal_delta_eband(const UnitCell &ucell) const
calculate deband
Definition elecstate_energy.cpp:106
Charge * charge
pointer to charge density
Definition elecstate.h:115
void cal_energies(const int type)
calculate energies
Definition elecstate_energy.cpp:284
void init_nelec_spin()
Definition elecstate.cpp:20
virtual void print_psi(const psi::Psi< std::complex< double > > &psi_in, const int istep=-1)
Definition elecstate.h:92
double get_solvent_model_Acav()
Definition elecstate_energy_terms.cpp:32
double get_solvent_model_Ael()
Definition elecstate_energy_terms.cpp:27
void set_exx(const std::complex< double > &Eexx)
ElecState()
Definition elecstate.h:17
bool skip_weights
Definition elecstate.h:162
void init_ks(Charge *chr_in, const K_Vectors *klist_in, int nk_in, const ModulePW::PW_Basis_Big *bigpw_in)
Definition elecstate.cpp:48
std::vector< double > nelec_spin
Definition elecstate.h:86
virtual void getNewRho()
Definition elecstate.h:72
void set_exx(const double &Eexx)
calculation if converged
Definition elecstate_exx.cpp:8
bool vnew_exist
Definition elecstate.h:127
virtual ~ElecState()
Definition elecstate.h:27
ModuleBase::matrix ekb
band energy at each k point, each band.
Definition elecstate.h:157
int iter
scf iteration
Definition elecstate.h:113
void cal_bandgap_updw()
calculate spin up & down band gap
Definition elecstate_energy.cpp:50
double get_etot_gatefield()
Definition elecstate_energy_terms.cpp:22
void cal_converged()
calculation if converged
Definition elecstate_energy.cpp:266
Efermi eferm
fermi energies
Definition elecstate.h:149
virtual void psiToRho(const psi::Psi< double > &psi)
Definition elecstate.h:49
Definition potential_new.h:49
Definition psi.h:37
This file contains all energies about first-principle calculations.
Definition cal_dm.h:10
Definition exx_lip.h:23
Parameter PARAM
Definition parameter.cpp:3
bool two_fermi
true if "nupdown" is set
Definition system_parameter.h:24
Definition fp_energy.h:63
bool two_efermi
Definition fp_energy.h:67
Definition fp_energy.h:17