ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
exx_lip.hpp
Go to the documentation of this file.
1//==========================================================
2// AUTHOR : Peize Lin
3
4// DATE : 2015-03-10
5//==========================================================
6
7#ifndef EXX_LIP_HPP
8#define EXX_LIP_HPP
9
10#include "exx_lip.h"
11#include "source_base/vector3.h"
13#include "source_base/vector3.h"
14#include "source_cell/klist.h"
20#include "source_psi/psi_base.h"
22#include "source_base/timer.h"
24
25#include <limits>
26#include <sys/stat.h>
27#include <sys/types.h>
28#include <unistd.h>
29#include <cerrno>
30
31template <typename T, typename Device>
33{
34 ModuleBase::TITLE("Exx_Lip", "cal_exx");
35 ModuleBase::timer::start("Exx_Lip", "cal_exx");
36
37 this->wf_wg_cal();
38 this->psi_cal();
39 for (int ik = 0; ik < this->k_pack->kv_ptr->get_nks(); ++ik)
40 {
41 this->phi_cal(this->k_pack, ik);
42
43 this->judge_singularity(ik);
44 for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l) {
45 for (int iw_r = 0; iw_r < PARAM.globalv.nlocal; ++iw_r) {
46 this->sum1[iw_l * PARAM.globalv.nlocal + iw_r] = T(0.0);
47 } }
49 {
50 this->sum2_factor = 0.0;
52 for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l) {
53 for (int iw_r = 0; iw_r < PARAM.globalv.nlocal; ++iw_r) {
54 this->sum3[iw_l][iw_r] = T(0.0);
55 } } }
56 }
57
58 for (int iq_tmp = this->iq_vecik; iq_tmp < this->iq_vecik + this->q_pack->kv_ptr->get_nks() / PARAM.inp.nspin; ++iq_tmp) // !!! k_point
59 // parallel incompleted.need to loop iq in other pool
60 {
61 const int iq =
62 (ik < (this->k_pack->kv_ptr->get_nks() / PARAM.inp.nspin))
63 ? (iq_tmp % (this->q_pack->kv_ptr->get_nks() / PARAM.inp.nspin))
64 : (iq_tmp % (this->q_pack->kv_ptr->get_nks() / PARAM.inp.nspin) + (this->q_pack->kv_ptr->get_nks() / PARAM.inp.nspin));
65 this->qkg2_exp(ik, iq);
66 for (int ib = 0; ib < PARAM.inp.nbands; ++ib)
67 {
68 this->b_cal(ik, iq, ib);
70 if (iq == this->iq_vecik) {
71 this->sum3_cal(iq, ib);
72 } }
73 this->b_sum(iq, ib);
74 }
75 }
76 this->sum_all(ik);
77 }
78 this->exx_energy_cal();
79
80 ModuleBase::timer::end("Exx_Lip", "cal_exx");
81}
82
83template <typename T, typename Device>
85 K_Vectors* kv_ptr_in,
86 psi::Psi<T, Device>* psi_local_in,
87 psi::Psi<T, Device>* kspw_psi_ptr_in,
88 const ModulePW::PW_Basis_K* wfc_basis_in,
89 const ModulePW::PW_Basis* rho_basis_in,
90 const UnitCell* ucell_ptr_in,
91 const elecstate::ElecState* pelec_in)
92 : info(info_in)
93{
94 ModuleBase::TITLE("Exx_Lip", "init");
95 ModuleBase::timer::start("Exx_Lip", "init");
96
97 this->k_pack = new k_package;
98 this->k_pack->kv_ptr = kv_ptr_in;
99 this->k_pack->psi_local = psi_local_in;
100 this->k_pack->pelec = pelec_in;
101 this->k_pack->kspw_psi_ptr = kspw_psi_ptr_in;
102 this->wfc_basis = wfc_basis_in;
103 this->rho_basis = rho_basis_in;
104 this->ucell_ptr = ucell_ptr_in;
105
106 int gzero_judge = -1;
107 if (this->rho_basis->gg_uniq[0] < 1e-8)
108 { gzero_judge = GlobalV::RANK_IN_POOL; }
109 #ifdef __MPI
110 MPI_Allreduce(&gzero_judge, &gzero_rank_in_pool, 1, MPI_INT, MPI_MAX, POOL_WORLD);
111 #endif
112 this->k_pack->wf_wg.create(this->k_pack->kv_ptr->get_nks(),PARAM.inp.nbands);
113
114 this->k_pack->hvec_array = new psi::Psi<T, Device>(this->k_pack->kv_ptr->get_nks(), PARAM.inp.nbands, PARAM.globalv.nlocal, kv_ptr_in->ngk, true);
115 // this->k_pack->hvec_array = new ModuleBase::ComplexMatrix[this->k_pack->kv_ptr->get_nks()];
116 // for( int ik=0; ik<this->k_pack->kv_ptr->get_nks(); ++ik)
117 // {
118 // this->k_pack->hvec_array[ik].create(PARAM.globalv.nlocal,PARAM.inp.nbands);
119 // }
120
121 // if (PARAM.inp.init_chg=="atomic")
122 {
123 this->q_pack = this->k_pack;
124 }
125 this->phi.resize(PARAM.globalv.nlocal);
126 for (int iw = 0; iw < PARAM.globalv.nlocal; ++iw)
127 { this->phi[iw].resize(this->rho_basis->nrxx); }
128
129 this->psi.resize(this->q_pack->kv_ptr->get_nks());
130 for (int iq = 0; iq < this->q_pack->kv_ptr->get_nks(); ++iq)
131 {
132 this->psi[iq].resize(PARAM.inp.nbands);
133 for (int ib = 0; ib < PARAM.inp.nbands; ++ib)
134 { this->psi[iq][ib].resize(this->rho_basis->nrxx); }
135 }
136
137 this->recip_qkg2.resize(this->rho_basis->npw);
138
139 this->b.resize(PARAM.globalv.nlocal * this->rho_basis->npw);
140
141 this->sum1.resize(PARAM.globalv.nlocal * PARAM.globalv.nlocal);
142
144 {
146 {
147 this->b0.resize(PARAM.globalv.nlocal);
148 this->sum3.resize(PARAM.globalv.nlocal);
149 for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l)
150 { this->sum3[iw_l].resize(PARAM.globalv.nlocal); }
151 }
152 }
153
154 this->exx_matrix.resize(this->k_pack->kv_ptr->get_nks());
155 for (int ik = 0; ik < this->k_pack->kv_ptr->get_nks(); ++ik)
156 {
157 this->exx_matrix[ik].resize(PARAM.globalv.nlocal);
158 for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l)
159 { this->exx_matrix[ik][iw_l].resize(PARAM.globalv.nlocal); }
160 }
161
162 ModuleBase::timer::end("Exx_Lip", "init");
163}
164
165template <typename T, typename Device>
167{
168 if (this->k_pack)
169 { delete this->k_pack->hvec_array; this->k_pack->hvec_array = nullptr; }
170 delete this->k_pack; this->k_pack = nullptr;
171
172 if (PARAM.inp.init_chg == "atomic")
173 {
174 this->q_pack = nullptr;
175 }
176 else if (PARAM.inp.init_chg == "file")
177 {
178 delete this->q_pack->kv_ptr; this->q_pack->kv_ptr = nullptr;
179 // delete this->q_pack->wf_ptr; this->q_pack->wf_ptr = nullptr;
180 // delete[] this->q_pack->hvec_array; this->q_pack->hvec_array=nullptr;
181 delete this->q_pack; this->q_pack = nullptr;
182 }
183}
184
185template <typename T, typename Device>
187{
188 ModuleBase::TITLE("Exx_Lip", "wf_wg_cal");
189 ModuleBase::timer::start("Exx_Lip", "wf_wg_cal");
190 if (PARAM.inp.nspin == 1) {
191 for (int ik = 0; ik < this->k_pack->kv_ptr->get_nks(); ++ik) {
192 for (int ib = 0; ib < PARAM.inp.nbands; ++ib) {
193 this->k_pack->wf_wg(ik, ib) = this->k_pack->pelec->wg(ik, ib) / 2;
194 } } }
195 else if (PARAM.inp.nspin == 2) {
196 for (int ik = 0; ik < this->k_pack->kv_ptr->get_nks(); ++ik) {
197 for (int ib = 0; ib < PARAM.inp.nbands; ++ib) {
198 this->k_pack->wf_wg(ik, ib) = this->k_pack->pelec->wg(ik, ib);
199 } } }
200 ModuleBase::timer::end("Exx_Lip", "wf_wg_cal");
201}
202
203template <typename T, typename Device>
204void Exx_Lip<T, Device>::phi_cal(k_package* kq_pack, const int ikq)
205{
206 ModuleBase::timer::start("Exx_Lip", "phi_cal");
207 std::vector<T> porter (this->wfc_basis->nrxx);
208 for (int iw = 0; iw < PARAM.globalv.nlocal; ++iw)
209 {
210 // this->wfc_basis->recip2real(&kq_pack->wf_ptr->wanf2[ikq](iw,0), porter.data(), ikq);
211 this->wfc_basis->recip2real(&(kq_pack->psi_local->operator()(ikq, iw, 0)), porter.data(), ikq);
212 int ir = 0;
213 for (int ix = 0; ix < this->rho_basis->nx; ++ix)
214 {
215 const Treal phase_x = kq_pack->kv_ptr->kvec_d[ikq].x * ix / this->rho_basis->nx;
216 for (int iy = 0; iy < this->rho_basis->ny; ++iy)
217 {
218 const Treal phase_xy = phase_x + kq_pack->kv_ptr->kvec_d[ikq].y * iy / this->rho_basis->ny;
219 for (int iz = this->rho_basis->startz_current; iz < this->rho_basis->startz_current + this->rho_basis->nplane; ++iz)
220 {
221 const Treal phase_xyz = phase_xy + kq_pack->kv_ptr->kvec_d[ikq].z * iz / this->rho_basis->nz;
222 const T exp_tmp = std::exp(phase_xyz * this->two_pi_i);
223 this->phi[iw][ir] = porter[ir] * exp_tmp;
224 ++ir;
225 }
226 }
227 }
228 }
229 ModuleBase::timer::end("Exx_Lip", "phi_cal");
230}
231
232template <typename T, typename Device>
234{
235 ModuleBase::TITLE("Exx_Lip", "psi_cal");
236 ModuleBase::timer::start("Exx_Lip", "psi_cal");
237 if (PARAM.inp.init_chg == "atomic")
238 {
239 std::vector<T> porter (this->wfc_basis->nrxx);
240 for (int iq = 0; iq < this->q_pack->kv_ptr->get_nks(); ++iq)
241 {
242 for (int ib = 0; ib < PARAM.inp.nbands; ++ib)
243 {
244 this->wfc_basis->recip2real(&(this->q_pack->kspw_psi_ptr->operator()(iq, ib, 0)), porter.data(), iq);
245
246 int ir = 0;
247 for (int ix = 0; ix < this->rho_basis->nx; ++ix)
248 {
249 const Treal phase_x = this->q_pack->kv_ptr->kvec_d[iq].x * ix / this->rho_basis->nx;
250 for (int iy = 0; iy < this->rho_basis->ny; ++iy)
251 {
252 const Treal phase_xy = phase_x + this->q_pack->kv_ptr->kvec_d[iq].y * iy / this->rho_basis->ny;
253 for (int iz = this->rho_basis->startz_current; iz < this->rho_basis->startz_current + this->rho_basis->nplane; ++iz)
254 {
255 const Treal phase_xyz = phase_xy + this->q_pack->kv_ptr->kvec_d[iq].z * iz / this->rho_basis->nz;
256 const T exp_tmp = std::exp(phase_xyz * this->two_pi_i);
257 this->psi[iq][ib][ir] = porter[ir] * exp_tmp;
258 ++ir;
259 }
260 }
261 }
262 }
263 }
264 }
265 else if (PARAM.inp.init_chg == "file")
266 {
267 for (int iq = 0; iq < this->q_pack->kv_ptr->get_nks(); ++iq)
268 {
269 this->phi_cal(this->q_pack, iq);
270 for (int ib = 0; ib < PARAM.inp.nbands; ++ib)
271 {
272 ModuleBase::GlobalFunc::ZEROS(this->psi[iq][ib].data(), this->rho_basis->nrxx);
273 for (int iw = 0; iw < PARAM.globalv.nlocal; ++iw)
274 {
275 for (int ir = 0; ir < this->rho_basis->nrxx; ++ir)
276 {
277 this->psi[iq][ib][ir] += (*this->q_pack->hvec_array)(iq, ib, iw) * this->phi[iw][ir];
278 }
279 }
280 }
281 }
282 }
284 // !!! k_point parallel incompleted. need to loop iq in other pool
286 ModuleBase::timer::end("Exx_Lip", "psi_cal");
287}
288
289template <typename T, typename Device>
291{
292 ModuleBase::timer::start("Exx_Lip", "judge_singularity");
293 if (PARAM.inp.init_chg=="atomic")
294 {
295 this->iq_vecik = ik;
296 }
297 else if(PARAM.inp.init_chg=="file")
298 {
299 Treal min_q_minus_k(std::numeric_limits<Treal>::max());
300 for( int iq=0; iq<this->q_pack->kv_ptr->get_nks(); ++iq)
301 {
302 const Treal q_minus_k((this->q_pack->kv_ptr->kvec_c[iq] - this->k_pack->kv_ptr->kvec_c[ik]).norm2());
303 if(q_minus_k < min_q_minus_k)
304 {
305 min_q_minus_k = q_minus_k;
306 this->iq_vecik = iq;
307 }
308 }
309 }
310 ModuleBase::timer::end("Exx_Lip", "judge_singularity");
311}
312
313template <typename T, typename Device>
314void Exx_Lip<T, Device>::qkg2_exp(const int ik, const int iq)
315{
316 ModuleBase::timer::start("Exx_Lip", "qkg2_exp");
317 for( int ig=0; ig<this->rho_basis->npw; ++ig)
318 {
319 const Treal qkg2 = ((this->q_pack->kv_ptr->kvec_c[iq] - this->k_pack->kv_ptr->kvec_c[ik] + this->rho_basis->gcar[ig]) * (ModuleBase::TWO_PI / this->ucell_ptr->lat0)).norm2();
321 {
322 if (std::abs(qkg2) < 1e-10)
323 { this->recip_qkg2[ig] = 0.0; } // 0 to ignore bb/qkg2 when qkg2==0
324 else
325 { this->recip_qkg2[ig] = 1.0 / qkg2; }
326 this->sum2_factor += this->recip_qkg2[ig] * std::exp(-info.lambda * qkg2);
327 this->recip_qkg2[ig] = std::sqrt(this->recip_qkg2[ig]);
328 }
329 else if (Conv_Coulomb_Pot_K::Ccp_Type::Erfc == info.ccp_type)
330 {
331 if (std::abs(qkg2) < 1e-10)
332 { this->recip_qkg2[ig] = 1.0 / (2 * info.hse_omega); }
333 else
334 { this->recip_qkg2[ig] = std::sqrt((1 - std::exp(-qkg2 / (4 * info.hse_omega * info.hse_omega))) / qkg2); }
335 }
336 else
337 {
338 throw( std::string(__FILE__) + " line " + std::to_string(__LINE__) );
339 }
340 }
341 ModuleBase::timer::end("Exx_Lip", "qkg2_exp");
342}
343
344template <typename T, typename Device>
345void Exx_Lip<T, Device>::b_cal(const int ik, const int iq, const int ib)
346{
347 ModuleBase::timer::start("Exx_Lip", "b_cal");
348 const ModuleBase::Vector3<double> q_minus_k = this->q_pack->kv_ptr->kvec_d[iq] - this->k_pack->kv_ptr->kvec_d[ik];
349 std::vector<T > mul_tmp(this->rho_basis->nrxx);
350 for( std::size_t ir=0,ix=0; ix<this->rho_basis->nx; ++ix)
351 {
352 const Treal phase_x = q_minus_k.x * ix / this->rho_basis->nx;
353 for( std::size_t iy=0; iy<this->rho_basis->ny; ++iy)
354 {
355 const Treal phase_xy = phase_x + q_minus_k.y * iy / this->rho_basis->ny;
356 for( std::size_t iz=this->rho_basis->startz_current; iz<this->rho_basis->startz_current+this->rho_basis->nplane; ++iz)
357 {
358 const Treal phase_xyz = phase_xy + q_minus_k.z * iz / this->rho_basis->nz;
359 mul_tmp[ir] = std::exp(-phase_xyz * this->two_pi_i);
360 mul_tmp[ir] *= this->psi[iq][ib][ir];
361 ++ir;
362 }
363 }
364 }
365
366 std::vector<T> porter (this->rho_basis->nrxx);
367 for(std::size_t iw=0; iw< PARAM.globalv.nlocal; ++iw)
368 {
369 auto& phi_w = this->phi[iw];
370 for( std::size_t ir=0; ir<this->rho_basis->nrxx; ++ir)
371 {
372 porter[ir] = std::conj(phi_w[ir]) * mul_tmp[ir] ;
373 // porter[ir] = phi_w[ir] * psi_q_b[ir] *exp_tmp[ir] ;
374 }
375 T* const b_w = &this->b[iw * this->rho_basis->npw];
376 this->rho_basis->real2recip( porter.data(), b_w);
378 if ((iq == this->iq_vecik) && (gzero_rank_in_pool == GlobalV::RANK_IN_POOL)) {
379 this->b0[iw] = b_w[this->rho_basis->ig_gge0];
380 } }
381
382 for (std::size_t ig = 0; ig < this->rho_basis->npw; ++ig)
383 { b_w[ig] *= this->recip_qkg2[ig]; }
384 }
385 ModuleBase::timer::end("Exx_Lip", "b_cal");
386}
387
388template <typename T, typename Device>
389void Exx_Lip<T, Device>::sum3_cal(const int iq, const int ib)
390{
391 ModuleBase::timer::start("Exx_Lip", "sum3_cal");
393 for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l) {
394 for (int iw_r = 0; iw_r < PARAM.globalv.nlocal; ++iw_r) {
395 this->sum3[iw_l][iw_r] += this->b0[iw_l] * std::conj(this->b0[iw_r]) * (Treal)this->q_pack->wf_wg(iq, ib);
396 } } }
397 ModuleBase::timer::end("Exx_Lip", "sum3_cal");
398}
399
400template <typename T, typename Device>
401void Exx_Lip<T, Device>::b_sum(const int iq, const int ib) // Peize Lin change 2019-04-14
402{
403 ModuleBase::timer::start("Exx_Lip", "b_sum");
404 // this->sum1[iw_l,iw_r] += \sum_{ig} this->b[iw_l,ig] * conj(this->b[iw_r,ig]) * this->q_pack->wf_wg(iq,ib)
405 LapackConnector::herk(
406 'U','N',
407 PARAM.globalv.nlocal, this->rho_basis->npw,
408 (Treal)this->q_pack->wf_wg(iq, ib), this->b.data(), this->rho_basis->npw,
409 1.0, this->sum1.data(), PARAM.globalv.nlocal);
410 // cblas_zherk( CblasRowMajor, CblasUpper, CblasNoTrans,
411 // PARAM.globalv.nlocal, this->rho_basis->npw,
412 // this->q_pack->wf_wg(iq,ib), static_cast<void*>(this->b), this->rho_basis->npw,
413 // 1.0, static_cast<void*>(this->sum1), PARAM.globalv.nlocal);
414 ModuleBase::timer::end("Exx_Lip", "b_sum");
415}
416
417template <typename T, typename Device>
419{
420 ModuleBase::timer::start("Exx_Lip", "sum_all");
421 Treal sum2_factor_g = 0.0;
422 const Treal fourpi_div_omega = 4 * (Treal)(ModuleBase::PI / this->ucell_ptr->omega);
423 const Treal spin_fac = 2.0;
424 #ifdef __MPI
426 { MPI_Reduce(&this->sum2_factor, &sum2_factor_g, 1, MPI_DOUBLE, MPI_SUM, gzero_rank_in_pool, POOL_WORLD); }
427 #endif
428 for (std::size_t iw_l = 1; iw_l < PARAM.globalv.nlocal; ++iw_l) {
429 for (std::size_t iw_r = 0; iw_r < iw_l; ++iw_r) {
430 this->sum1[iw_l * PARAM.globalv.nlocal + iw_r] = std::conj(this->sum1[iw_r * PARAM.globalv.nlocal + iw_l]); // Peize Lin add conj 2019-04-14
431 } }
432
433 for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l)
434 {
435 for( int iw_r=0; iw_r<PARAM.globalv.nlocal; ++iw_r)
436 {
437 this->exx_matrix[ik][iw_l][iw_r] = -fourpi_div_omega * this->sum1[iw_l * PARAM.globalv.nlocal + iw_r] * spin_fac;
439 {
441 {
442 this->exx_matrix[ik][iw_l][iw_r] += spin_fac * (fourpi_div_omega * this->sum3[iw_l][iw_r] * sum2_factor_g);
443 this->exx_matrix[ik][iw_l][iw_r] += spin_fac * (-1 / (Treal)std::sqrt(info.lambda * ModuleBase::PI) * (Treal)(this->q_pack->kv_ptr->get_nks() / PARAM.inp.nspin) * this->sum3[iw_l][iw_r]);
444 }
445 }
446 }
447 }
448 ModuleBase::timer::end("Exx_Lip", "sum_all");
449}
450
451template <typename T, typename Device>
453{
454 ModuleBase::TITLE("Exx_Lip","exx_energy_cal");
455 ModuleBase::timer::start("Exx_Lip", "exx_energy_cal");
456
457 Treal exx_energy_tmp = 0.0;
458
459 for( int ik=0; ik<this->k_pack->kv_ptr->get_nks(); ++ik) {
460 for( int iw_l=0; iw_l<PARAM.globalv.nlocal; ++iw_l) {
461 for( int iw_r=0; iw_r<PARAM.globalv.nlocal; ++iw_r) {
462 for( int ib=0; ib<PARAM.inp.nbands; ++ib) {
463 exx_energy_tmp += (this->exx_matrix[ik][iw_l][iw_r] * std::conj((*this->k_pack->hvec_array)(ik, ib, iw_l)) * (*this->k_pack->hvec_array)(ik, ib, iw_r)).real() * this->k_pack->wf_wg(ik, ib);
464 } } } }
465 #ifdef __MPI
466 MPI_Allreduce( &exx_energy_tmp, &this->exx_energy, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); // !!! k_point parallel incompleted. different pools have different kv.set_nks(>) deadlock
467 #endif
468 this->exx_energy *= (PARAM.inp.nspin==1) ? 2 : 1;
469 this->exx_energy /= 2; // ETOT = E_band - 1/2 E_exx
470 ModuleBase::timer::end("Exx_Lip", "exx_energy_cal");
471}
472
473template <typename T, typename Device>
475{
476 if (PARAM.inp.out_chg[0] == 0)
477 {
478 return;
479 }
480
481 ModuleBase::timer::start("Exx_Lip", "write_q_pack");
482
484 {
485 const std::string exx_q_pack = "exx_q_pack/";
486 const std::string dir_path = PARAM.globalv.global_out_dir + exx_q_pack;
487
488 int ret = mkdir(dir_path.c_str(), 0755);
489 assert(ret == 0 || errno == EEXIST);
490
491 const std::string kpoint_dest = dir_path + PARAM.inp.kpoint_file;
492 struct stat st;
493 if (stat(kpoint_dest.c_str(), &st) != 0)
494 {
495 std::ifstream src(PARAM.inp.kpoint_file, std::ios::binary);
496 std::ofstream dst(kpoint_dest, std::ios::binary);
497 dst << src.rdbuf();
498 assert(dst.good());
499 }
500
501 std::stringstream ss_wf_wg;
502 ss_wf_wg << PARAM.globalv.global_out_dir << exx_q_pack << "wf_wg_" << GlobalV::MY_POOL;
503 std::ofstream ofs_wf_wg(ss_wf_wg.str().c_str());
504 for( int iq = 0; iq < this->q_pack->kv_ptr->get_nks(); ++iq)
505 {
506 for( int ib=0; ib<PARAM.inp.nbands; ++ib)
507 {
508 ofs_wf_wg<<this->q_pack->wf_wg(iq,ib)<<"\t";
509 }
510 ofs_wf_wg<<std::endl;
511 }
512 ofs_wf_wg.close();
513
514 std::stringstream ss_hvec;
515 ss_hvec << PARAM.globalv.global_out_dir << exx_q_pack << "hvec_" << GlobalV::MY_POOL;
516 std::ofstream ofs_hvec(ss_hvec.str().c_str());
517 for( int iq=0; iq<this->q_pack->kv_ptr->get_nks(); ++iq)
518 {
519 for( int iw=0; iw<PARAM.globalv.nlocal; ++iw)
520 {
521 for( int ib=0; ib<PARAM.inp.nbands; ++ib)
522 {
523 ofs_hvec << (*this->q_pack->hvec_array)(iq, ib, iw).real() << " " << (*this->q_pack->hvec_array)(iq, ib, iw).imag() << " ";
524 }
525 ofs_hvec<<std::endl;
526 }
527 }
528 ofs_hvec.close();
529 }
530 ModuleBase::timer::end("Exx_Lip", "write_q_pack");
531}
532
533#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
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
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
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
3 elements vector
Definition vector3.h:21
T x
Definition vector3.h:23
T y
Definition vector3.h:24
T z
Definition vector3.h:25
static void start(void)
Start total time calculation.
Definition timer.cpp:44
static void end(const std::string &class_name_in, const std::string &name_in)
Definition timer.cpp:109
std::vector< ModuleBase::Vector3< double > > kvec_d
Direct coordinates of the points.
Definition reciprocal_grid.h:57
std::vector< int > ngk
Number of plane waves for each point (filled by the PW basis).
Definition reciprocal_grid.h:63
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 psi.h:37
#define T
Definition exp.cpp:237
This is a wrapper of some LAPACK routines. Row-Major version.
@ Erfc
Definition coulomb_config.h:19
@ Ccp
Definition coulomb_config.h:17
@ Hf
Definition coulomb_config.h:18
int MY_POOL
global index of pool (count in pool)
Definition global_variable.cpp:22
int RANK_IN_POOL
global index of pool (count in process), my_rank in each pool
Definition global_variable.cpp:26
void ZEROS(std::complex< T > *u, const TI n)
Definition global_function.h:109
const double TWO_PI
Definition constants.h:21
const double PI
Definition constants.h:19
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
Definition diag_lcao.h:14
MPI_Comm POOL_WORLD
Definition parallel_comm.cpp:6
Parameter PARAM
Definition parameter.cpp:3
Definition exx_info_lip.h:7
Definition exx_lip.h:73
K_Vectors * kv_ptr
Definition exx_lip.h:74
psi::Psi< T, Device > * psi_local
NAOs in PW.
Definition exx_lip.h:77