ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
hamilt_zeq_r.h
Go to the documentation of this file.
1#ifndef ABACUS_SOURCE_LCAO_MODULE_LR_HAMILT_ZEQ_R_H
2#define ABACUS_SOURCE_LCAO_MODULE_LR_HAMILT_ZEQ_R_H
8#include "hamilt_zequlr.h"
11#ifdef __EXX
13#endif
14namespace LR
15{
16 template<typename T>
17 class Z_vector_R : public HamiltLR<T>
18 {
20#ifdef __EXX
21 using ATYPE_EXX = typename OperatorLREXX<T>::MO_TO_AO_TYPE;
22#endif
23 public:
24 Z_vector_R(const std::string& xc_kernel,
25 const int& nspin,
26 const int& naos,
27 const std::vector<int>& nocc,
28 const std::vector<int>& nvirt,
29 const UnitCell& ucell,
30 const std::vector<double>& orb_cutoff,
31 const Grid_Driver& gd,
32 const psi::Psi<T>& psi_ks,
33 const ModuleBase::matrix& eig_ks,
34#ifdef __EXX
35 std::weak_ptr<Exx_LRI<T>> exx_lri,
36 const double& exx_alpha,
37#endif
38 std::weak_ptr<PotHxcLR> pot,
39 std::weak_ptr<PotHxcLR> pot_hxc_gs,
40 const K_Vectors& kv,
41 const std::vector<Parallel_Blkcyclic>& pX,
42 const Parallel_Blkcyclic& pc,
43 const Parallel_Orbitals& pmat,
44 const std::string& in_dir,
45 const std::string& out_dir,
46 const std::string& dft_functional,
47 const std::string& spin_type = "singlet")
48 : HamiltLR<T>(nspin, nocc, nvirt, pX, kv, pmat)
49 {
50 ModuleBase::TITLE("Z_vector_R", "Z_vector_R");
51
52 LR_Util::initialize_DMR(*this->DM_trans, pmat, ucell, gd, orb_cutoff);
54 LR_Util::initialize_DMR(*this->DM_diff, pmat, ucell, gd, orb_cutoff);
55
56 // note: calculation_type cannot repeated, or it will be ignored in ops->add()
57 // 1. $2\sum_bX_{ib}K_{ab}[D^X]-2\sum_jX_{ja}K_{ij}[D^X]$
58 // kernel: excited state
59 this->ops = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks,
60 *this->DM_trans, pot, ucell, orb_cutoff, gd, kv, pX, pc, pmat,
61 { 0 }, T(-2.0), ATYPE::CXC, hamilt::calculation_type::lr_dmtrans_hxc);
62#ifdef __EXX
63 if (exx_kernel_list().count(xc_kernel))
64 {
65 hamilt::Operator<T>* op_hz_exx = new OperatorLREXX<T>(nspin, naos, nocc[0], nvirt[0], ucell, psi_ks,
66 *this->DM_trans, exx_lri, kv, pX[0], pc, pmat,
67 /*cal_force=*/true,
68 -2.0 * exx_alpha, //alpha; H=2K when D is symmetrized
70 this->ops->add(op_hz_exx);
71 }
72#endif
73 // 2. $H_{ia}[T]$, equals to $2K_{ab}[T]$ when $T$ is symmetrized
74 // kernel: ground state
75 // Factor -4 (not -2), for the same reason as in `hamilt_zeq_left.h`:
76 // $K^S_\text{Hxc}=2$`pot_hxc_gs`, so $H^S=2K^S$ needs 4.
77 hamilt::Operator<T>* op_ht = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks,
78 *this->DM_diff, pot_hxc_gs, ucell, orb_cutoff, gd, kv, pX, pc, pmat,
79 { 0 }, T(-4.0), ATYPE::CC_vo, hamilt::calculation_type::lr_dmdiff_hxc);
80 this->ops->add(op_ht);
81#ifdef __EXX
82 if (gs_is_hybrid(dft_functional))
83 {
84 hamilt::Operator<T>* op_ht_exx = new OperatorLREXX<T>(nspin, naos, nocc[0], nvirt[0], ucell, psi_ks,
85 *this->DM_diff, exx_lri, kv, pX[0], pc, pmat,
86 /*cal_force=*/true,
87 -2.0 * exx_alpha, //alpha; H=2K when D is symmetrized
88 ATYPE_EXX::CC_vo, {}, hamilt::calculation_type::lr_dmdiff_exx);
89 this->ops->add(op_ht_exx);
90 }
91#endif
92
93 // 3. $2\sum_{jb,kc} g^{xc}_{ia, jb, kc}X_{jb}X_{kc}$
94 // NOT singlet-only for a local functional where the triplet kernel is
95 // $K^T_{xc}=f_{uu}-f_{ud}\ne0$ -- exactly what `PotHxcLR`'s `S2_triplet` branch
96 // evaluates -- so $\partial K^T$ carries a $g^{xc}$ term too, with the "-" spin
97 // combination. `PotGradXCLR` picks it via the `triplet` flag.
98 if (LR_Util::has_local_xc(xc_kernel))
99 {
100 const std::shared_ptr<LR::PotHxcLR> lr_potential = pot.lock();
101 const LR::KernelXC& kernel = lr_potential->xc_kernel_components();
102 const ModulePW::PW_Basis& rho_basis = lr_potential->get_rho_basis();
103 const bool triplet = spin_type == "triplet";
104 const int kernel_nspin = kernel.nspin();
105 this->pot_grad = std::make_shared<PotGradXCLR>(kernel, rho_basis, ucell,
106 lr_potential->nrxx, kernel_nspin, triplet);
107 hamilt::Operator<T>* op_gxc = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks,
108 *this->DM_trans, this->pot_grad, ucell, orb_cutoff, gd, kv, pX, pc, pmat,
109 { 0 }, T(-2.0), ATYPE::CC_vo, hamilt::calculation_type::lr_dmtrans_gxc);
110 assert(op_gxc != nullptr);
111 this->ops->add(op_gxc);
112 }
113 // // test: op_ht only
114 // delete this->ops;
115 // this->ops = new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks,
116 // *this->DM_diff, pot_hxc_gs, ucell, orb_cutoff, gd, kv, pX, pc, pmat,
117 // { 0 }, T(-2.0), ATYPE::CC_vo);
118
119 // $D^X$ is fed to the CXC operators TRANSPOSED.
120 //
121 // The RHS needs $K^{S/T}_{ba}[D^X]$ -- the same kernel the Casida equation was solved
122 // with, which `HamiltLR` builds from the un-symmetrized $D^X$ (`tdm_sym = false`).
123 // `CVCX_virt`/`CVCX_occ` give the kernel matrix with its two MO indices in
124 // the opposite order to what this term needs, and since
125 // $(K[D])^T = K[D^T]$,
126 // transposing the density matrix on the way in restores it.
127 this->cal_dm_trans = [this, &psi_ks, &pc, naos, &nocc, &nvirt, &pmat](const int& is, const T* X)->void
128 {
129 const psi::Psi<T> psi_ks_is = LR_Util::get_psi_spin(psi_ks, is, this->nk);
130#ifdef __MPI
131 std::vector<ct::Tensor> dm_trans_2d = cal_dm_trans_pblas(X, this->pX[is], psi_ks_is, pc, naos, nocc[is], nvirt[is], pmat.para_2d());
132 for (container::Tensor& t: dm_trans_2d)
133 {
134 LR_Util::mattrans(t.data<T>(), naos, pmat.para_2d());
135 }
136#else
137 std::vector<ct::Tensor> dm_trans_2d = cal_dm_trans_blas(X, psi_ks_is, nocc[is], nvirt[is]);
138 for (auto& t : dm_trans_2d)
139 {
140 T* d = t.data<T>();
141 for (int u = 0; u < naos; ++u)
142 {
143 for (int v = u + 1; v < naos; ++v)
144 {
145 std::swap(d[u * naos + v], d[v * naos + u]);
146 }
147 }
148 }
149#endif
150 for (int ik = 0; ik < this->nk; ++ik)
151 {
152 this->DM_trans->set_dmk_ptr(ik, dm_trans_2d[ik].data<T>());
153 }
154 };
155
156 this->cal_dm_diff = [this, &psi_ks, &pc, naos, &nocc, &nvirt, &pmat](const int& is, const T* const X, const std::vector<ct::Tensor>* density_add)->void
157 {
158 const psi::Psi<T> psi_ks_is = LR_Util::get_psi_spin(psi_ks, is, this->nk);
159#ifdef __MPI
160 std::vector<ct::Tensor> dm_diff_2d = cal_dm_diff_pblas(X, this->pX[is], psi_ks_is, pc, naos, nocc[is], nvirt[is], pmat.para_2d());
161 for (container::Tensor& t: dm_diff_2d)
162 LR_Util::matsym(t.data<T>(), naos, pmat.para_2d());
163#else
164 std::vector<ct::Tensor> dm_diff_2d = cal_dm_diff_blas(X, psi_ks_is, naos, nocc[is], nvirt[is]);
165 for (auto& t: dm_diff_2d)
166 LR_Util::matsym(t.data<T>(), naos);
167#endif
168 for (int ik = 0; ik < this->nk; ++ik)
169 {
170 if (density_add != nullptr)
171 {
172 dm_diff_2d[ik] = dm_diff_2d[ik] + density_add->at(ik);
173 }
174 this->DM_diff->set_dmk_ptr(ik, dm_diff_2d[ik].data<T>());
175 }
176 // std::cout << "difference density matrix" << std::endl;
177 // for (int ik = 0;ik < this->nk;++ik) { LR_Util::print_value(dm_diff_2d[ik].data<T>(), naos, naos); }
178 // std::cout << "test: set dm_diff to zero" << std::endl;
179 // for (int ik = 0;ik < this->nk;++ik) { dm_diff_2d[ik].zero(); }
180 };
181 }
182 virtual void hPsi(const T* const psi, T* const hpsi, const int ld_psi, const int nband) const override
183 {
184 const std::vector<std::vector<ct::Tensor>> no_density;
185 this->hPsi(psi, hpsi, ld_psi, nband, no_density);
186 }
187 // Each state supplies symmetric Dwin; only the linear Hgs[T] term reads it.
188 void hPsi(const T* psi, T* hpsi, const int ld_psi, const int nband,
189 const std::vector<std::vector<ct::Tensor>>& window_density) const
190 {
191 assert(window_density.empty() || window_density.size() == nband);
192 assert(ld_psi == this->nk * this->pX[0].size());
193 for (int ib = 0;ib < nband;++ib)
194 {
195 const int offset = ib * ld_psi;
196 this->cal_dm_trans(0, psi + offset); // transition density matrix, only for test
197 const auto* density_add = window_density.empty() ? nullptr : &window_density[ib];
198 this->cal_dm_diff(0, psi + offset, density_add); // T + Dwin
199 hamilt::Operator<T>* node(this->ops);
200 while (node != nullptr)
201 {
202 node->act(/*nband=*/1, ld_psi, /*npol=*/1, psi + offset, hpsi + offset);
203 node = (hamilt::Operator<T>*)(node->next_op);
204 }
205 }
206 }
207
208 private:
209 std::unique_ptr<module_dm::DensityMatrix<T, T>> DM_diff;
210 std::function<void(const int&, const T*, const std::vector<ct::Tensor>*)> cal_dm_diff;
211 std::shared_ptr<PotLRBase> pot_grad;
212 };
213
227 template<typename T>
228 class Z_vector_UR : public ZeqULR<T>
229 {
231#ifdef __EXX
232 using ATYPE_EXX = typename OperatorLREXX<T>::MO_TO_AO_TYPE;
233#endif
234 public:
235 Z_vector_UR(const std::string& xc_kernel,
236 const int& nspin,
237 const int& naos,
238 const std::vector<int>& nocc,
239 const std::vector<int>& nvirt,
240 const UnitCell& ucell,
241 const std::vector<double>& orb_cutoff,
242 const Grid_Driver& gd,
243 const psi::Psi<T>& psi_ks,
244 const ModuleBase::matrix& eig_ks,
245#ifdef __EXX
246 std::weak_ptr<Exx_LRI<T>> exx_lri,
247 const double& exx_alpha,
248#endif
249 std::weak_ptr<PotHxcLR> pot,
250 std::weak_ptr<PotHxcLR> pot_hxc_gs,
251 const K_Vectors& kv,
252 const std::vector<Parallel_Blkcyclic>& pX,
253 const Parallel_Blkcyclic& pc,
254 const Parallel_Orbitals& pmat,
255 const std::string& ks_solver,
256 const std::string& dft_functional,
257 const int nk,
258 const int local_dimension,
259 const int global_dimension)
260 : ZeqULR<T>(nocc, nvirt, pX, nk, local_dimension, global_dimension),
261 naos_(naos), pc_(pc), pmat_(pmat), psi_ks_(psi_ks)
262 {
263 ModuleBase::TITLE("Z_vector_UR", "Z_vector_UR");
265 LR_Util::initialize_DMR(*this->DM_trans, pmat, ucell, gd, orb_cutoff);
267 LR_Util::initialize_DMR(*this->DM_diff, pmat, ucell, gd, orb_cutoff);
268
269 // 1. $\sum_bX_{bi\sigma}H_{ba\sigma}[D^X]-\sum_kX_{ak\sigma}H_{ik\sigma}[D^X]$,
270 // excited-state kernel, $D^X$ fed TRANSPOSED (see `set_dm` below)
271 auto newCXC = [this, &nspin, &naos, &nocc, &nvirt, &psi_ks, &pot, &ucell, &orb_cutoff, &gd, &kv, &pX, &pc, &pmat](const int sl, const int sr)
272 {
273 return new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks,
274 *this->DM_trans, pot, ucell, orb_cutoff, gd, kv, pX, pc, pmat,
275 { sl, sr }, T(-2.0), ATYPE::CXC, hamilt::calculation_type::lr_dmtrans_hxc);
276 };
277 this->ops[0] = newCXC(0, 0);
278 this->ops[1] = newCXC(0, 1);
279 this->ops[2] = newCXC(1, 0);
280 this->ops[3] = newCXC(1, 1);
281
282 // 2. $H_{ai\sigma}[T]$, ground-state kernel
283 auto newHT = [this, &nspin, &naos, &nocc, &nvirt, &psi_ks, &pot_hxc_gs, &ucell, &orb_cutoff, &gd, &kv, &pX, &pc, &pmat](const int sl, const int sr)
284 {
285 return new OperatorLRHxc<T>(nspin, naos, nocc, nvirt, psi_ks,
286 *this->DM_diff, pot_hxc_gs, ucell, orb_cutoff, gd, kv, pX, pc, pmat,
287 { sl, sr }, T(-2.0), ATYPE::CC_vo, hamilt::calculation_type::lr_dmdiff_hxc);
288 };
289 this->ops[0]->add(newHT(0, 0));
290 this->ops[1]->add(newHT(0, 1));
291 this->ops[2]->add(newHT(1, 0));
292 this->ops[3]->add(newHT(1, 1));
293
294 // 3. $2\sum_{\sigma'\sigma''}D^X_{\sigma'}D^X_{\sigma''}g^{xc}_{\dots,ai\tau}$.
295 // Quadratic in $D^X$, so it lives outside the 2x2 block structure (see `band_extra`).
296 // Factor -2.0, straight from the spin-orbital formula -- the closed-shell code uses the
297 // same number only because its `PotGradXCLR` carries the doubled S/T combination.
298 if (LR_Util::has_local_xc(xc_kernel))
299 {
300 this->gxc_ = LR_Util::make_unique<OperatorGxcULR<T>>(pot.lock()->xc_kernel_components(),
301 pot.lock()->get_rho_basis(), ucell, orb_cutoff, gd, kv, pmat, pc, psi_ks,
302 nocc, nvirt, naos, pX, pX, LR_Util::MO_TYPE::VO, T(-2.0), nspin, ks_solver);
303 }
304
305#ifdef __EXX
306 for (int is: {0, 1})
307 {
308 this->psi_ks_spin_.push_back(LR_Util::get_psi_spin(psi_ks, is, this->nk));
309 }
310 if (exx_kernel_list().count(xc_kernel))
311 {
312 for (int is : {0, 1})
313 {
314 this->ops[(is << 1) + is]->add(new OperatorLREXX<T>(nspin, naos, nocc[is], nvirt[is],
315 ucell, this->psi_ks_spin_[is], *this->DM_trans, exx_lri, kv, pX[is], pc, pmat,
316 /*cal_force=*/true, -2.0 * exx_alpha, ATYPE_EXX::CXC, {}, hamilt::calculation_type::lr_dmtrans_exx));
317 }
318 }
319 if (gs_is_hybrid(dft_functional))
320 {
321 for (int is : {0, 1})
322 {
323 this->ops[(is << 1) + is]->add(new OperatorLREXX<T>(nspin, naos, nocc[is], nvirt[is],
324 ucell, this->psi_ks_spin_[is], *this->DM_diff, exx_lri, kv, pX[is], pc, pmat,
325 /*cal_force=*/true, -2.0 * exx_alpha, ATYPE_EXX::CC_vo, {}, hamilt::calculation_type::lr_dmdiff_exx));
326 }
327 }
328#endif
329 }
330
331 protected:
332 void band_extra(const T* const X, T* const out) const override
333 {
334 if (this->gxc_)
335 {
336 this->gxc_->act(X, out);
337 }
338 }
339
343 void set_dm(const int is, const T* const X,
344 const std::vector<ct::Tensor>* density_add) override
345 {
346 const psi::Psi<T> psi_ks_is = LR_Util::get_psi_spin(this->psi_ks_, is, this->nk);
347#ifdef __MPI
348 this->dmx_buf_ = cal_dm_trans_pblas(X, this->pX[is], psi_ks_is, this->pc_,
349 this->naos_, this->nocc[is], this->nvirt[is], this->pmat_.para_2d());
350 for (auto& t: this->dmx_buf_)
351 {
352 LR_Util::mattrans(t.template data<T>(), this->naos_, this->pmat_.para_2d());
353 }
354 this->dmd_buf_ = cal_dm_diff_pblas(X, this->pX[is], psi_ks_is, this->pc_,
355 this->naos_, this->nocc[is], this->nvirt[is], this->pmat_.para_2d());
356 for (auto& t: this->dmd_buf_)
357 {
358 LR_Util::matsym(t.template data<T>(), this->naos_, this->pmat_.para_2d());
359 }
360#else
361 this->dmx_buf_ = cal_dm_trans_blas(X, psi_ks_is, this->nocc[is], this->nvirt[is]);
362 for (auto& t : this->dmx_buf_)
363 {
364 T* d = t.template data<T>();
365 for (int u = 0;u < this->naos_;++u)
366 {
367 for (int v = u + 1; v < this->naos_; ++v)
368 {
369 std::swap(d[u * this->naos_ + v], d[v * this->naos_ + u]);
370 }
371 }
372 }
373 this->dmd_buf_ = cal_dm_diff_blas(X, psi_ks_is, this->naos_, this->nocc[is], this->nvirt[is]);
374 for (auto& t: this->dmd_buf_)
375 {
376 LR_Util::matsym(t.template data<T>(), this->naos_);
377 }
378#endif
379 for (int ik = 0;ik < this->nk;++ik)
380 {
381 this->DM_trans->set_dmk_ptr(ik, this->dmx_buf_[ik].template data<T>());
382 if (density_add != nullptr)
383 {
384 const int block = is * this->nk + ik;
385 this->dmd_buf_[ik] = this->dmd_buf_[ik] + density_add->at(block);
386 }
387 this->DM_diff->set_dmk_ptr(ik, this->dmd_buf_[ik].template data<T>());
388 }
389 }
390
391 private:
392 const int naos_ = 1;
396 std::vector<psi::Psi<T>> psi_ks_spin_;
397 std::unique_ptr<module_dm::DensityMatrix<T, T>> DM_trans;
398 std::unique_ptr<module_dm::DensityMatrix<T, T>> DM_diff;
399 std::vector<ct::Tensor> dmx_buf_;
400 std::vector<ct::Tensor> dmd_buf_;
401 std::unique_ptr<OperatorGxcULR<T>> gxc_;
402 };
403}
404
405#endif // ABACUS_SOURCE_LCAO_MODULE_LR_HAMILT_ZEQ_R_H
Definition exx_lri.h:50
Grid_Driver class for neighbor search interface.
Definition sltk_grid_driver.h:63
Class for k-points management.
Definition klist.h:20
const int nk
Definition hamilt_casida.h:200
const std::vector< Parallel_Blkcyclic > & pX
Definition hamilt_casida.h:201
std::function< void(const int &, const T *const)> cal_dm_trans
Definition hamilt_casida.h:229
const int nspin
Definition hamilt_casida.h:199
HamiltLR(const std::string &xc_kernel, const int &nspin, const int &naos, const std::vector< int > &nocc, const std::vector< int > &nvirt, const UnitCell &ucell_in, const std::vector< double > &orb_cutoff, const Grid_Driver &gd_in, const psi::Psi< T > &psi_ks_in, const ModuleBase::matrix &eig_ks, std::weak_ptr< PotLRBase > pot_in, const K_Vectors &kv_in, const std::vector< Parallel_Blkcyclic > &pX_in, const Parallel_Blkcyclic &pc_in, const Parallel_Orbitals &pmat_in, const std::string &spin_type, const std::string &in_dir, const std::string &out_dir, const std::string &ri_hartree_benchmark="none", const std::vector< int > &aims_nbasis={})
Definition hamilt_casida.h:23
const std::vector< int > & nocc
Definition hamilt_casida.h:197
std::unique_ptr< module_dm::DensityMatrix< T, T > > DM_trans
Definition hamilt_casida.h:224
hamilt::Operator< T, base_device::DEVICE_CPU > * ops
first node operator, add operations from each operators
Definition hamilt_casida.h:227
const std::vector< int > & nvirt
Definition hamilt_casida.h:198
Calculate the exchange-correlation (XC) kernel ($f_{xc}=\delta^2E_xc/\delta\rho^2$) and store its com...
Definition xc_kernel.h:84
int nspin() const
Metadata belongs to this coefficient set, independent of later global XC changes.
Definition xc_kernel.h:109
Definition exx_lri.h:35
Hxc part of A operator for LR-TDDFT.
Definition operator_lr_hxc.h:17
MO_TO_AO_TYPE
type of molecular orbital to atomic orbital transformation: CC_vo: MO = C_v^* AO C_o; CC_oo: MO = C_o...
Definition operator_lr_hxc.h:24
std::unique_ptr< module_dm::DensityMatrix< T, T > > DM_diff
Definition hamilt_zeq_r.h:209
Z_vector_R(const std::string &xc_kernel, const int &nspin, const int &naos, const std::vector< int > &nocc, const std::vector< int > &nvirt, const UnitCell &ucell, const std::vector< double > &orb_cutoff, const Grid_Driver &gd, const psi::Psi< T > &psi_ks, const ModuleBase::matrix &eig_ks, std::weak_ptr< PotHxcLR > pot, std::weak_ptr< PotHxcLR > pot_hxc_gs, const K_Vectors &kv, const std::vector< Parallel_Blkcyclic > &pX, const Parallel_Blkcyclic &pc, const Parallel_Orbitals &pmat, const std::string &in_dir, const std::string &out_dir, const std::string &dft_functional, const std::string &spin_type="singlet")
Definition hamilt_zeq_r.h:24
typename OperatorLRHxc< T >::MO_TO_AO_TYPE ATYPE
Definition hamilt_zeq_r.h:19
std::function< void(const int &, const T *, const std::vector< ct::Tensor > *)> cal_dm_diff
Definition hamilt_zeq_r.h:210
std::shared_ptr< PotLRBase > pot_grad
Definition hamilt_zeq_r.h:211
void hPsi(const T *psi, T *hpsi, const int ld_psi, const int nband, const std::vector< std::vector< ct::Tensor > > &window_density) const
Definition hamilt_zeq_r.h:188
virtual void hPsi(const T *const psi, T *const hpsi, const int ld_psi, const int nband) const override
Definition hamilt_zeq_r.h:182
std::unique_ptr< OperatorGxcULR< T > > gxc_
Definition hamilt_zeq_r.h:401
Z_vector_UR(const std::string &xc_kernel, const int &nspin, const int &naos, const std::vector< int > &nocc, const std::vector< int > &nvirt, const UnitCell &ucell, const std::vector< double > &orb_cutoff, const Grid_Driver &gd, const psi::Psi< T > &psi_ks, const ModuleBase::matrix &eig_ks, std::weak_ptr< PotHxcLR > pot, std::weak_ptr< PotHxcLR > pot_hxc_gs, const K_Vectors &kv, const std::vector< Parallel_Blkcyclic > &pX, const Parallel_Blkcyclic &pc, const Parallel_Orbitals &pmat, const std::string &ks_solver, const std::string &dft_functional, const int nk, const int local_dimension, const int global_dimension)
Definition hamilt_zeq_r.h:235
std::unique_ptr< module_dm::DensityMatrix< T, T > > DM_trans
Definition hamilt_zeq_r.h:397
void set_dm(const int is, const T *const X, const std::vector< ct::Tensor > *density_add) override
Definition hamilt_zeq_r.h:343
const psi::Psi< T > & psi_ks_
Definition hamilt_zeq_r.h:395
const Parallel_Orbitals & pmat_
Definition hamilt_zeq_r.h:394
std::vector< ct::Tensor > dmd_buf_
Definition hamilt_zeq_r.h:400
void band_extra(const T *const X, T *const out) const override
optional per-band contribution that does not fit the 2x2 block structure. NOTE matrix() deliberately ...
Definition hamilt_zeq_r.h:332
typename OperatorLRHxc< T >::MO_TO_AO_TYPE ATYPE
Definition hamilt_zeq_r.h:230
std::unique_ptr< module_dm::DensityMatrix< T, T > > DM_diff
Definition hamilt_zeq_r.h:398
const Parallel_Blkcyclic & pc_
Definition hamilt_zeq_r.h:393
const int naos_
Definition hamilt_zeq_r.h:392
std::vector< ct::Tensor > dmx_buf_
Definition hamilt_zeq_r.h:399
std::vector< psi::Psi< T > > psi_ks_spin_
Definition hamilt_zeq_r.h:396
std::vector< hamilt::Operator< T > * > ops
Definition hamilt_zequlr.h:193
const std::vector< int > & nvirt
Definition hamilt_zequlr.h:179
ZeqULR(const std::vector< int > &nocc_in, const std::vector< int > &nvirt_in, const std::vector< Parallel_Blkcyclic > &pX_in, const int nk_in, const int local_dimension, const int global_dimension)
Definition hamilt_zequlr.h:35
const std::vector< int > & nocc
Definition hamilt_zequlr.h:178
const int nk
Definition hamilt_zequlr.h:181
const std::vector< Parallel_Blkcyclic > & pX
Definition hamilt_zequlr.h:180
Definition matrix.h:15
std::vector< ModuleBase::Vector3< double > > kvec_d
Direct coordinates of the points.
Definition reciprocal_grid.h:57
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Parallel block-cyclic matrix distribution.
Definition parallel_blkcyc.h:25
Definition parallel_orbitals.h:16
Parallel_Blkcyclic & para_2d()
Definition parallel_orbitals.h:24
Provide the basic information about unitcell.
Definition unitcell.h:16
A multi-dimensional array of elements of a single data type.
Definition tensor.h:32
Definition operator.h:42
Operator * next_op
interface type 3: return a Psi-type HPsi
Definition operator.h:112
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
Definition operator.h:95
Definition psi.h:37
#define T
Definition exp.cpp:237
psi::Psi< T > get_psi_spin(const psi::Psi< T > &psi_in, const int &is, const int &nk)
get the Psi wrapper of the selected spin from the Psi object
Definition lr_util.hpp:235
std::unique_ptr< T > make_unique(Args &&... args)
Definition lr_util.hpp:33
void matsym(const T *in, const int n, T *out)
Definition lr_util.hpp:79
@ VO
Definition mo_type.h:9
bool has_local_xc(const std::string &name)
check if the xc functional has local xc kernel
Definition lr_util.h:80
void initialize_DMR(module_dm::DensityMatrix< T, TR > &dm, const Parallel_Orbitals &pmat, const UnitCell &ucell, const Grid_Driver &gd, const std::vector< double > &orb_cutoff)
Definition lr_util_hcontainer.h:179
void mattrans(const T *in, const int n, const Parallel_Blkcyclic &pmat, T *out)
Definition esolver_lr_lcao_tddft.h:28
std::vector< container::Tensor > cal_dm_diff_pblas(const T *const X_istate, const Parallel_Blkcyclic &px, const psi::Psi< T, base_device::DEVICE_CPU > &c, const Parallel_Blkcyclic &pc, const int &naos, const int &nocc, const int &nvirt, const Parallel_Blkcyclic &pmat, const bool renorm_k=true, const int nspin=1)
calculate the 2d-block difference density matrix in AO basis using p?gemm
Definition dm_diff_par.cpp:235
std::vector< container::Tensor > cal_dm_trans_blas(const T *const X_istate, const psi::Psi< T > &c, const int &nocc, const int &nvirt, const T factor=(T) 1.0, const LR_Util::MO_TYPE type=LR_Util::MO_TYPE::VO)
calculate the 2d-block transition density matrix in AO basis using ?gemm
std::vector< container::Tensor > cal_dm_trans_pblas(const T *const X_istate, const Parallel_Blkcyclic &px, const psi::Psi< T > &c, const Parallel_Blkcyclic &pc, const int naos, const int nocc, const int nvirt, const Parallel_Blkcyclic &pmat, const T factor=(T) 1.0, const LR_Util::MO_TYPE type=LR_Util::MO_TYPE::VO)
calculate the 2d-block transition density matrix in AO basis using p?gemm
std::vector< container::Tensor > cal_dm_diff_blas(const T *const X_istate, const psi::Psi< T, base_device::DEVICE_CPU > &c, const int &naos, const int &nocc, const int &nvirt, const bool renorm_k=true, const int nspin=1)
calculate the 2d-block transition density matrix in AO basis using ?gemm
Definition dm_diff_ser.cpp:184
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
@ lr_dmtrans_exx
Definition operator.h:32
@ lr_dmdiff_hxc
Definition operator.h:31
@ lr_dmtrans_hxc
Definition operator.h:29
@ lr_dmdiff_exx
Definition operator.h:33
@ lr_dmtrans_gxc
Definition operator.h:30
Definition diag_lcao.h:14