ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
op_exx_pw.h
Go to the documentation of this file.
1#ifndef OPEXXPW_H
2#define OPEXXPW_H
3
4#include "operator_pw.h"
10#include "source_cell/klist.h"
12#include "source_psi/psi.h"
14
15#include <memory>
16#include <utility>
17#include <vector>
18
19namespace hamilt
20{
21
22template <typename T, typename Device>
23class OperatorEXXPW : public OperatorPW<T, Device>
24{
25 private:
26 using Real = typename GetTypeReal<T>::type;
27
28 public:
29 OperatorEXXPW(const int* isk_in,
30 const ModulePW::PW_Basis_K* wfcpw_in,
31 const ModulePW::PW_Basis* rhopw_in,
32 K_Vectors* kv_in,
33 const UnitCell* ucell);
34
35 template <typename T_in, typename Device_in = Device>
36 explicit OperatorEXXPW(const OperatorEXXPW<T_in, Device_in> *op_exx);
37
38 virtual ~OperatorEXXPW();
39
40 virtual void act(const int nbands,
41 const int nbasis,
42 const int npol,
43 const T *tmpsi_in,
44 T *tmhpsi,
45 const int ngk_ik = 0,
46 const bool is_first_node = false) const override;
47
48 double cal_exx_energy(psi::Psi<T, Device> *psi_) const;
49
50 void set_psi(psi::Psi<T, Device> &psi_in) const { psi = psi_in; }
51
52 void set_wg(const ModuleBase::matrix *wg_in) { wg = wg_in; }
53
54 void construct_ace() const;
55
56 bool first_iter = false;
57
58 private:
59 const int* isk = nullptr;
60 const ModulePW::PW_Basis_K* wfcpw = nullptr;
61 const ModulePW::PW_Basis* rhopw = nullptr;
62 ModulePW::PW_Basis* rhopw_dev = nullptr; // for device
63 const UnitCell *ucell = nullptr;
64// Real exx_div = 0;
66
67 std::vector<int> get_q_points(const int ik) const;
68 const T *get_pw(const int m, const int iq) const;
69
70 void multiply_potential(T *density_recip, int ik, int iq) const;
71
72 double exx_divergence(Conv_Coulomb_Pot_K::Coulomb_Type coulomb_type, double erfc_omega = 0) const;
73
74 void get_potential() const;
75
76 void act_op(const int nbands,
77 const int nbasis,
78 const int npol,
79 const T *tmpsi_in,
80 T *tmhpsi,
81 const int ngk_ik = 0,
82 const bool is_first_node = false) const;
83
84 void act_op_ace(const int nbands,
85 const int nbasis,
86 const int npol,
87 const T *tmpsi_in,
88 T *tmhpsi,
89 const int ngk_ik = 0,
90 const bool is_first_node = false) const;
91
92 double cal_exx_energy_op(psi::Psi<T, Device> *psi_) const;
93
94 double cal_exx_energy_ace(psi::Psi<T, Device> *psi_) const;
95
96 void cal_density_recip(const T* psi_nk_real, const T* psi_mq_real, double omega) const;
97
98 void rho_recip2real(const T* rho_recip, T* rho_real, bool add = false, Real factor = 1.0) const;
99
100 mutable int cnt = 0;
101
102 mutable bool potential_got = false;
103
104 // pws
105// mutable std::vector<std::unique_ptr<T[]>> pws;
106
107 // k vectors
108 K_Vectors *kv = nullptr;
109
110 // psi
113
114 // real space memory
115 T *psi_nk_real = nullptr;
116 T *psi_mq_real = nullptr;
117 T *density_real = nullptr;
118 T *h_psi_real = nullptr;
119 // density recip space memory
120 T *density_recip = nullptr;
121 // h_psi recip space memory
122 T *h_psi_recip = nullptr;
123 Real *pot = nullptr;
124
125 // Lin Lin's ACE memory, 10.1021/acs.jctc.6b00092
126 mutable T* h_psi_ace = nullptr; // H \Psi, W in the paper
127 mutable T* psi_h_psi_ace = nullptr; // \Psi^{\dagger} H \Psi, M in the paper
128 mutable T* L_ace = nullptr; // cholesky(-M).L, L in the paper
129 mutable std::vector<T*> Xi_ace_k; // L^{-1} (H \Psi)^{\dagger}, \Xi in the paper
130// mutable T* Xi_ace = nullptr; // L^{-1} (H \Psi)^{\dagger}, \Xi in the paper
131
132 mutable std::map<int, std::vector<int>> q_points;
133
134 // occupational number
136
137// mutable bool update_psi = false;
138
139 Device *ctx = {};
140 base_device::DEVICE_CPU* cpu_ctx = {};
142
162
164
165};
166
167} // namespace hamilt
168
169#endif // OPEXXPW_H
Definition klist.h:13
Definition matrix.h:19
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:57
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:56
Definition unitcell.h:16
Definition op_exx_pw.h:24
psi::Psi< T, Device > psi
Definition op_exx_pw.h:111
bool first_iter
Definition op_exx_pw.h:56
T * h_psi_real
Definition op_exx_pw.h:118
void multiply_potential(T *density_recip, int ik, int iq) const
Definition op_exx_pw.cpp:518
const int * isk
Definition op_exx_pw.h:59
void set_wg(const ModuleBase::matrix *wg_in)
Definition op_exx_pw.h:52
T * density_recip
Definition op_exx_pw.h:120
void get_potential() const
Definition op_exx_pw.cpp:564
T * density_real
Definition op_exx_pw.h:117
ModulePW::PW_Basis * rhopw_dev
Definition op_exx_pw.h:62
Real tpiba
Definition op_exx_pw.h:65
int cnt
Definition op_exx_pw.h:100
void cal_density_recip(const T *psi_nk_real, const T *psi_mq_real, double omega) const
double cal_exx_energy_op(psi::Psi< T, Device > *psi_) const
Definition op_exx_pw.cpp:897
std::map< int, std::vector< int > > q_points
Definition op_exx_pw.h:132
base_device::AbacusDevice_t device
Definition op_exx_pw.h:141
T * psi_nk_real
Definition op_exx_pw.h:115
const ModuleBase::matrix * wg
Definition op_exx_pw.h:112
virtual ~OperatorEXXPW()
Definition op_exx_pw.cpp:89
void rho_recip2real(const T *rho_recip, T *rho_real, bool add=false, Real factor=1.0) const
const ModuleBase::matrix * p_wg
Definition op_exx_pw.h:135
Device * ctx
Definition op_exx_pw.h:139
void construct_ace() const
Definition op_exx_pw.cpp:334
void act_op(const int nbands, const int nbasis, const int npol, const T *tmpsi_in, T *tmhpsi, const int ngk_ik=0, const bool is_first_node=false) const
Definition op_exx_pw.cpp:157
const T * get_pw(const int m, const int iq) const
Definition op_exx_pw.cpp:532
double cal_exx_energy_ace(psi::Psi< T, Device > *psi_) const
Definition op_exx_pw.cpp:862
typename ct::PsiToContainer< Device >::type ct_Device
Definition op_exx_pw.h:143
const ModulePW::PW_Basis_K * wfcpw
Definition op_exx_pw.h:60
T * h_psi_recip
Definition op_exx_pw.h:122
std::vector< T * > Xi_ace_k
Definition op_exx_pw.h:129
const ModulePW::PW_Basis * rhopw
Definition op_exx_pw.h:61
void set_psi(psi::Psi< T, Device > &psi_in) const
Definition op_exx_pw.h:50
void act_op_ace(const int nbands, const int nbasis, const int npol, const T *tmpsi_in, T *tmhpsi, const int ngk_ik=0, const bool is_first_node=false) const
Definition op_exx_pw.cpp:267
T * h_psi_ace
Definition op_exx_pw.h:126
bool gamma_extrapolation
Definition op_exx_pw.h:163
double cal_exx_energy(psi::Psi< T, Device > *psi_) const
Definition op_exx_pw.cpp:849
Real * pot
Definition op_exx_pw.h:123
base_device::DEVICE_CPU * cpu_ctx
Definition op_exx_pw.h:140
std::vector< int > get_q_points(const int ik) const
Definition op_exx_pw.cpp:472
K_Vectors * kv
Definition op_exx_pw.h:108
T * psi_mq_real
Definition op_exx_pw.h:116
T * psi_h_psi_ace
Definition op_exx_pw.h:127
typename GetTypeReal< T >::type Real
Definition op_exx_pw.h:26
T * L_ace
Definition op_exx_pw.h:128
bool potential_got
Definition op_exx_pw.h:102
const UnitCell * ucell
Definition op_exx_pw.h:63
double exx_divergence(Conv_Coulomb_Pot_K::Coulomb_Type coulomb_type, double erfc_omega=0) const
Definition op_exx_pw.cpp:726
virtual void act(const int nbands, const int nbasis, const int npol, const T *tmpsi_in, T *tmhpsi, const int ngk_ik=0, const bool is_first_node=false) const override
Definition op_exx_pw.cpp:131
Definition operator_pw.h:8
int ik
Definition operator.h:101
virtual void add(Operator *next)
bool is_first_node
Definition operator.h:109
Definition psi.h:37
#define T
Definition exp.cpp:237
Coulomb_Type
Definition conv_coulomb_pot_k.h:10
AbacusDevice_t
Definition types.h:12
Definition hamilt.h:12
Definition exx_lip.h:23
T type
Definition macros.h:8
Definition math_kernel_op.h:132
Definition math_kernel_op.h:168
Definition math_kernel_op.h:217
Definition math_kernel_op.h:151
Definition memory_op.h:77
Definition memory_op.h:17
Definition memory_op.h:31
Definition tensor_types.h:113
Definition lapack.h:34
Definition lapack.h:23