ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
exx_lip.h
Go to the documentation of this file.
1//==========================================================
2// AUTHOR : Peize Lin
3// DATE : 2015-03-10
4//==========================================================
5#ifndef EXX_LIP_H
6#define EXX_LIP_H
7
10#include "source_base/matrix.h"
11
12#include <vector>
13#include <memory.h>
14
15 class K_Vectors;
16 class UnitCell;
17 namespace elecstate{ class ElecState; }
18 namespace ModulePW{ class PW_Basis_K; }
19 namespace ModulePW{ class PW_Basis; }
20 namespace psi
21 {
22 template <typename T, typename Device>
23 class PSIInit;
24 }
25
26template<typename T, typename Device = base_device::DEVICE_CPU>
28{
29 using Treal = typename GetTypeReal<T>::type;
30public:
31 Exx_Lip(const Exx_Info_Lip& info_in);
32 ~Exx_Lip();
33
35
36 Exx_Lip(const Exx_Info_Lip& info_in,
37 K_Vectors* kv_ptr_in,
38 psi::Psi<T, Device>* psi_local_in,
39 psi::Psi<T, Device>* kspw_psi_ptr_in,
40 const ModulePW::PW_Basis_K* wfc_basis_in,
41 const ModulePW::PW_Basis* rho_basis_in,
42 const UnitCell* ucell_ptr_in,
43 const elecstate::ElecState* pelec_in);
44
45 // void cal_exx(const int& nks);
46 void cal_exx();
47 const std::vector<std::vector<std::vector<T>>>& get_exx_matrix() const
48 {
49 return this->exx_matrix;
50 }
52 {
53 return this->exx_energy;
54 }
55
56 void write_q_pack() const;
57
58 void set_hvec(const int ik, const T* const hvec, const int naos, const int nbands)
59 {
60 memcpy(&(*this->k_pack->hvec_array)(ik, 0, 0), hvec, sizeof(T) * naos * nbands);
61 }
63 {
64 return *this->k_pack->hvec_array;
65 }
66
67private:
68
70
71 // template<typename T, typename Device = base_device::DEVICE_CPU>
72 struct k_package
73 {
74 K_Vectors* kv_ptr = nullptr;
75 // wavefunc* wf_ptr;
79
82 const elecstate::ElecState* pelec = nullptr;
83 } *k_pack = nullptr, * q_pack = nullptr;
84
86
87 std::vector<std::vector<T>> phi;
88 std::vector<std::vector<std::vector<T>>> psi;
89 std::vector<Treal> recip_qkg2;
91 std::vector<T> b;
92 std::vector<T> b0;
93 std::vector<T> sum1;
94 std::vector<std::vector<T>> sum3;
95
96 std::vector<std::vector<std::vector<T>>> exx_matrix;
98
99 void wf_wg_cal();
100 void phi_cal(k_package* kq_pack, const int ikq);
101 void psi_cal();
102 void judge_singularity(const int ik);
103 void qkg2_exp(const int ik, const int iq);
104 void b_cal(const int ik, int iq, const int ib);
105 void sum3_cal(const int iq, const int ib);
106 void b_sum(const int iq, const int ib);
107 void sum_all(const int ik);
108 void exx_energy_cal();
109
110 //2*pi*i
111 const T two_pi_i = Treal(ModuleBase::TWO_PI) * T(0.0, 1.0);
112public:
115
116 const UnitCell* ucell_ptr = nullptr;
117};
118
119#include "exx_lip.hpp"
120
121#endif
int gzero_rank_in_pool
Definition exx_lip.h:69
std::vector< T > b
Definition exx_lip.h:91
std::vector< std::vector< T > > phi
Definition exx_lip.h:87
int iq_vecik
Definition exx_lip.h:85
const UnitCell * ucell_ptr
Definition exx_lip.h:116
struct Exx_Lip::k_package * q_pack
struct Exx_Lip::k_package * k_pack
const Exx_Info_Lip & info
Definition exx_lip.h:34
void sum_all(const int ik)
Definition exx_lip.hpp:418
void b_sum(const int iq, const int ib)
Definition exx_lip.hpp:401
psi::Psi< T, Device > get_hvec() const
Definition exx_lip.h:62
const std::vector< std::vector< std::vector< T > > > & get_exx_matrix() const
Definition exx_lip.h:47
void cal_exx()
Definition exx_lip.hpp:32
Treal exx_energy
Definition exx_lip.h:97
const ModulePW::PW_Basis_K * wfc_basis
Definition exx_lip.h:114
Exx_Lip(const Exx_Info_Lip &info_in)
void write_q_pack() const
Definition exx_lip.hpp:474
const T two_pi_i
Definition exx_lip.h:111
void exx_energy_cal()
Definition exx_lip.hpp:452
~Exx_Lip()
Definition exx_lip.hpp:166
void set_hvec(const int ik, const T *const hvec, const int naos, const int nbands)
Definition exx_lip.h:58
std::vector< Treal > recip_qkg2
Definition exx_lip.h:89
void qkg2_exp(const int ik, const int iq)
Definition exx_lip.hpp:314
typename GetTypeReal< T >::type Treal
Definition exx_lip.h:29
std::vector< std::vector< std::vector< T > > > exx_matrix
Definition exx_lip.h:96
void phi_cal(k_package *kq_pack, const int ikq)
Definition exx_lip.hpp:204
std::vector< T > sum1
Definition exx_lip.h:93
void wf_wg_cal()
Definition exx_lip.hpp:186
std::vector< std::vector< T > > sum3
Definition exx_lip.h:94
void judge_singularity(const int ik)
Definition exx_lip.hpp:290
std::vector< T > b0
Definition exx_lip.h:92
void sum3_cal(const int iq, const int ib)
Definition exx_lip.hpp:389
Treal sum2_factor
Definition exx_lip.h:90
Treal get_exx_energy() const
Definition exx_lip.h:51
void b_cal(const int ik, int iq, const int ib)
Definition exx_lip.hpp:345
void psi_cal()
Definition exx_lip.hpp:233
const ModulePW::PW_Basis * rho_basis
Definition exx_lip.h:113
Class for k-points management.
Definition klist.h:20
Definition matrix.h:15
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:56
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Provide the basic information about unitcell.
Definition unitcell.h:16
Definition elecstate.h:20
Definition exx_lip.h:23
Definition psi.h:37
#define T
Definition exp.cpp:237
const double TWO_PI
Definition constants.h:21
Definition pw_op.cpp:3
Definition read_atoms_hlp_test.cpp:13
Definition diag_lcao.h:14
Definition exx_info_lip.h:7
Definition exx_lip.h:73
const elecstate::ElecState * pelec
Definition exx_lip.h:82
psi::Psi< T, Device > * kspw_psi_ptr
PW wavefunction.
Definition exx_lip.h:76
K_Vectors * kv_ptr
Definition exx_lip.h:74
psi::Psi< T, Device > * psi_local
NAOs in PW.
Definition exx_lip.h:77
psi::Psi< T, Device > * hvec_array
LCAO wavefunction, the eigenvectors from lapack diagonalization.
Definition exx_lip.h:81
ModuleBase::matrix wf_wg
Definition exx_lip.h:78
T type
Definition macros.h:8