@@ -65,7 +65,7 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
6565
6666 const double mem_size = sizeof (double ) * double (gg.gridt ->lgd ) * double (nbands) * double (nspin) / 1024.0 / 1024.0 ;
6767 ModuleBase::Memory::record (" Get_wf_lcao::begin" , mem_size);
68- printf ( " Estimated on -the-fly memory: %f MB \n " , mem_size);
68+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " On -the-fly memory consumption (MB) " , mem_size);
6969
7070 int mode_norm = 0 ;
7171 if (nbands_istate > 0 && static_cast <int >(out_wfc_norm.size ()) == 0 )
@@ -87,7 +87,6 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
8787 {
8888 if (bands_picked_[ib])
8989 {
90- GlobalV::ofs_running << " Electronic wave funciton " << ib + 1 << std::endl;
9190
9291 for (int is = 0 ; is < nspin; ++is)
9392 {
@@ -97,8 +96,9 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
9796#ifdef __MPI
9897 wfc_2d_to_grid (psid->get_pointer (), para_orb, wfc_gamma_grid[is], gg.gridt ->trace_lo );
9998#else
100- // if not MPI enabled, it is the case psid holds a global matrix. use fix_k to switch between different
101- // spin channels (actually kpoints, because now the same kpoint in different spin channels are treated
99+ // if not MPI enabled, it is the case psid holds a global matrix.
100+ // use fix_k to switch between different spin channels (actually kpoints,
101+ // because now the same kpoint in different spin channels are treated
102102 // as distinct kpoints)
103103
104104 for (int i = 0 ; i < nbands; ++i)
@@ -114,16 +114,26 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
114114
115115 pes_->charge ->save_rho_before_sum_band ();
116116
117- std::stringstream ss;
118- ss << global_out_dir << " wf" << ib + 1 << " s" << is + 1 << " .cube" ;
117+ // pint out information
118+ std::stringstream ss_file;
119+ ss_file << " wf" << ib + 1 << " s" << is + 1 << " .cube" ;
120+
121+ std::stringstream ss_out;
122+ ss_out << global_out_dir << ss_file.str ();
123+
124+ std::stringstream ss_info;
125+ ss_info << " Wave func. " << ib+1 << " spin " << is+1 << " saved in" ;
126+
127+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, ss_info.str (), ss_file.str ());
128+
119129
120130 const double ef_tmp = this ->pes_ ->eferm .get_efval (is);
121131 ModuleIO::write_vdata_palgrid (pgrid,
122132 pes_->charge ->rho_save [is],
123133 is,
124134 nspin,
125135 0 ,
126- ss .str (),
136+ ss_out .str (),
127137 ef_tmp,
128138 &(ucell));
129139 }
@@ -293,7 +303,7 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
293303 const double mem_size
294304 = sizeof (std::complex <double >) * double (gk.gridt ->lgd ) * double (nbands) * double (nks) / 1024.0 / 1024.0 ;
295305 ModuleBase::Memory::record (" Get_wf_lcao::begin" , mem_size);
296- printf ( " Estimated on -the-fly memory %f MB \n " , mem_size);
306+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " On -the-fly memory consumption (MB) " , mem_size);
297307
298308 // for pw_wfc in G space
299309 psi::Psi<std::complex <double >> psi_g;
@@ -322,16 +332,13 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
322332 {
323333 if (bands_picked_[ib])
324334 {
325- GlobalV::ofs_running << " Electronic wave funciton " << ib + 1 << std::endl;
326-
327335 const int nspin0 = (nspin == 2 ) ? 2 : 1 ;
328336 for (int ik = 0 ; ik < nks; ++ik) // the loop of nspin0 is included
329337 {
330338 const int ispin = kv.isk [ik];
331339 ModuleBase::GlobalFunc::ZEROS (pes_->charge ->rho [ispin],
332340 pw_wfc->nrxx ); // terrible, you make changes on another instance's data???
333341
334- GlobalV::ofs_running << " k-point " << ik + 1 << std::endl;
335342
336343 // 2d-to-grid conversion is unified into `wfc_2d_to_grid`.
337344 psi->fix_k (ik);
@@ -341,23 +348,50 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
341348#else
342349 for (int i = 0 ; i < nbands; ++i)
343350 {
344- for (int j = 0 ; j < nlocal; ++j)
345- wfc_k_grid[ik][i][j] = psi[0 ](i, j);
351+ for (int j = 0 ; j < nlocal; ++j)
352+ {
353+ wfc_k_grid[ik][i][j] = psi[0 ](i, j);
354+ }
346355 }
347356#endif
348357 // deal with NSPIN=4
349358 gk.cal_env_k (ik, wfc_k_grid[ik][ib], pes_->charge ->rho [ispin], kv.kvec_c , kv.kvec_d , ucell);
350359
351- std::stringstream ss;
352- ss << global_out_dir << " wf" << ib + 1 << " s" << ispin + 1 << " k" << ik+1 << " .cube" ;
360+
361+ // ik0 is the real k-point index, starting from 0
362+ int ik0 = kv.ik2iktot [ik];
363+ if (nspin == 2 )
364+ {
365+ const int half_k = kv.get_nkstot ()/2 ;
366+ if (ik0 >= half_k)
367+ {
368+ ik0 -= half_k;
369+ }
370+ }
371+
372+ // pint out information
373+ std::stringstream ss_file;
374+ ss_file << " wf" << ib+1 << " s" << ispin + 1 << " k" << ik0+1 << " .cube" ;
375+
376+ std::stringstream ss_out;
377+ ss_out << global_out_dir << ss_file.str ();
378+
379+ std::stringstream ss_info;
380+ ss_info << " Wave func. " << ib+1
381+ << " spin " << ispin+1
382+ << " k-point " << ik0+1
383+ << " saved in" ;
384+
385+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, ss_info.str (), ss_file.str ());
386+
353387 const double ef_tmp = this ->pes_ ->eferm .get_efval (ispin);
354388
355389 ModuleIO::write_vdata_palgrid (pgrid,
356390 pes_->charge ->rho [ispin],
357391 ispin,
358392 nspin,
359393 0 ,
360- ss .str (),
394+ ss_out .str (),
361395 ef_tmp,
362396 &(ucell),
363397 3 ,
@@ -416,6 +450,7 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
416450 }
417451
418452 // Output real part
453+
419454 std::stringstream ss_real;
420455 ss_real << global_out_dir << " wf" << ib + 1 << " s" << ispin + 1 << " k" << ik+1 << " real.cube" ;
421456
@@ -478,9 +513,8 @@ void Get_wf_lcao::select_bands(const int nbands_istate,
478513 bands_below = nbands_istate;
479514 bands_above = nbands_istate;
480515
481- std::cout << " Plot wave functions below the Fermi surface with " << bands_below << " bands." << std::endl;
482-
483- std::cout << " Plot wave functions above the Fermi surface with " << bands_above << " bands." << std::endl;
516+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Number of states below Fermi energy" , bands_below);
517+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Number of states above Fermi energy" , bands_above);
484518
485519 for (int ib = 0 ; ib < nbands; ++ib)
486520 {
0 commit comments