Skip to content

Commit 4c4552a

Browse files
committed
update get_wf_lcao outputs
1 parent d33b17d commit 4c4552a

File tree

2 files changed

+53
-28
lines changed

2 files changed

+53
-28
lines changed

source/module_io/get_wf_lcao.cpp

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,9 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
4141
const std::string& global_out_dir)
4242
{
4343
ModuleBase::TITLE("Get_wf_lcao", "begin");
44-
45-
std::cout << " Calculate |psi(i, r)|, Re[psi(i, r)], Im[psi(i, r)] for selected bands (gamma only)." << std::endl;
46-
47-
// if ucell is odd, it's correct,
48-
// if ucell is even, it's also correct.
49-
// +1.0e-8 in case like (2.999999999+1)/2
50-
const int fermi_band = static_cast<int>((nelec + 1) / 2 + 1.0e-8);
51-
std::cout << " Number of electrons = " << nelec << std::endl;
52-
std::cout << " Number of occupied bands = " << fermi_band << std::endl;
44+
45+
int fermi_band = 0;
46+
prepare_get_wf(GlobalV::ofs_running, nelec, fermi_band);
5347

5448
// allocate grid wave functions for gamma_only
5549
std::vector<double**> wfc_gamma_grid(nspin);
@@ -70,8 +64,8 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
7064
}
7165

7266
const double mem_size = sizeof(double) * double(gg.gridt->lgd) * double(nbands) * double(nspin) / 1024.0 / 1024.0;
73-
ModuleBase::Memory::record("Get_wf_lcao::begin::wfc_gamma_grid", mem_size);
74-
printf(" Estimated on-the-fly memory consuming by Get_wf_lcao::begin::wfc_gamma_grid: %f MB\n", mem_size);
67+
ModuleBase::Memory::record("Get_wf_lcao::begin", mem_size);
68+
printf(" Estimated on-the-fly memory: %f MB\n", mem_size);
7569

7670
int mode_norm = 0;
7771
if (nbands_istate > 0 && static_cast<int>(out_wfc_norm.size()) == 0)
@@ -93,7 +87,7 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
9387
{
9488
if (bands_picked_[ib])
9589
{
96-
std::cout << " Performing grid integral over real space grid for band " << ib + 1 << "..." << std::endl;
90+
GlobalV::ofs_running << " Electronic wave funciton " << ib + 1 << std::endl;
9791

9892
for (int is = 0; is < nspin; ++is)
9993
{
@@ -281,15 +275,8 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
281275
{
282276
ModuleBase::TITLE("Get_wf_lcao", "begin");
283277

284-
std::cout << " Calculate |psi(i, r)|, Re[psi(i, r)], Im[psi(i, r)] for selected bands (multi-k)." << std::endl;
285-
286-
// if ucell is odd, it's correct,
287-
// if ucell is even, it's also correct.
288-
// +1.0e-8 in case like (2.999999999+1)/2
289-
// if NSPIN=4, each band only one electron, fermi_band should be nelec
290-
const int fermi_band = nspin < 4 ? static_cast<int>((nelec + 1) / 2 + 1.0e-8) : nelec;
291-
std::cout << " number of electrons = " << nelec << std::endl;
292-
std::cout << " number of occupied bands = " << fermi_band << std::endl;
278+
int fermi_band = 0;
279+
prepare_get_wf(GlobalV::ofs_running, nelec, fermi_band);
293280

294281
// allocate grid wave functions for multi-k
295282
const int nks = kv.get_nks();
@@ -305,8 +292,8 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
305292

306293
const double mem_size
307294
= sizeof(std::complex<double>) * double(gk.gridt->lgd) * double(nbands) * double(nks) / 1024.0 / 1024.0;
308-
ModuleBase::Memory::record("Get_wf_lcao::begin::wfc_k_grid", mem_size);
309-
printf(" Estimated on-the-fly memory consuming by Get_wf_lcao::begin::wfc_k_grid: %f MB\n", mem_size);
295+
ModuleBase::Memory::record("Get_wf_lcao::begin", mem_size);
296+
printf(" Estimated on-the-fly memory %f MB\n", mem_size);
310297

311298
// for pw_wfc in G space
312299
psi::Psi<std::complex<double>> psi_g;
@@ -335,17 +322,20 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
335322
{
336323
if (bands_picked_[ib])
337324
{
338-
std::cout << " Performing grid integral over real space grid for band " << ib + 1 << "..." << std::endl;
325+
GlobalV::ofs_running << " Electronic wave funciton " << ib + 1 << std::endl;
339326

340327
const int nspin0 = (nspin == 2) ? 2 : 1;
341328
for (int ik = 0; ik < nks; ++ik) // the loop of nspin0 is included
342329
{
343330
const int ispin = kv.isk[ik];
344331
ModuleBase::GlobalFunc::ZEROS(pes_->charge->rho[ispin],
345332
pw_wfc->nrxx); // terrible, you make changes on another instance's data???
346-
std::cout << " Calculate envelope function for kpoint " << ik + 1 << ", band" << ib + 1 << std::endl;
333+
334+
GlobalV::ofs_running << " k-point " << ik + 1 << std::endl;
335+
347336
// 2d-to-grid conversion is unified into `wfc_2d_to_grid`.
348337
psi->fix_k(ik);
338+
349339
#ifdef __MPI // need to deal with NSPIN=4 !!!!
350340
wfc_2d_to_grid(psi->get_pointer(), para_orb, wfc_k_grid[ik], gk.gridt->trace_lo);
351341
#else
@@ -744,11 +734,43 @@ template void Get_wf_lcao::wfc_2d_to_grid(const std::complex<double>* lowf_2d,
744734
const std::vector<int>& trace_lo);
745735
#endif
746736

737+
738+
void Get_wf_lcao::prepare_get_wf(std::ofstream &ofs_running, const int nelec, int& fermi_band)
739+
{
740+
ofs_running << "\n\n";
741+
ofs_running << " GET_WF CALCULATIONS BEGINS" << std::endl;
742+
743+
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
744+
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
745+
ofs_running << " | "
746+
" |" << std::endl;
747+
ofs_running << " | Here we use real-space (r) grid integral technique to calculate |" << std::endl;
748+
ofs_running << " | the electronic wave function psi(i,r) for each electronic state i. |" << std::endl;
749+
ofs_running << " | The |psi(i, r)|, Re[psi(i, r)], Im[psi(i, r)] are printed out |" << std::endl;
750+
ofs_running << " | using numerical atomic orbitals as basis set. |" << std::endl;
751+
ofs_running << " | "
752+
" |" << std::endl;
753+
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
754+
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
755+
756+
ofs_running << "\n\n";
757+
758+
ofs_running << std::setprecision(6);
759+
760+
// if ucell is odd, it's correct,
761+
// if ucell is even, it's also correct.
762+
// +1.0e-8 in case like (2.999999999+1)/2
763+
fermi_band = static_cast<int>((nelec + 1) / 2 + 1.0e-8);
764+
ModuleBase::GlobalFunc::OUT(ofs_running, "Number of electrons", nelec);
765+
ModuleBase::GlobalFunc::OUT(ofs_running, "Number of occupied bands", fermi_band);
766+
}
767+
768+
769+
747770
int Get_wf_lcao::globalIndex(int localindex, int nblk, int nprocs, int myproc)
748771
{
749-
int iblock, gIndex;
750-
iblock = localindex / nblk;
751-
gIndex = (iblock * nprocs + myproc) * nblk + localindex % nblk;
772+
const int iblock = localindex / nblk;
773+
const int gIndex = (iblock * nprocs + myproc) * nblk + localindex % nblk;
752774
return gIndex;
753775
}
754776

source/module_io/get_wf_lcao.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class Get_wf_lcao
107107
};
108108

109109
private:
110+
111+
void prepare_get_wf(std::ofstream &ofs_running, const int nelec, int& fermi_band);
112+
110113
void select_bands(const int nbands_istate,
111114
const std::vector<int>& out_wfc_kb,
112115
const int nbands,

0 commit comments

Comments
 (0)