Skip to content

Commit fe3b44f

Browse files
authored
Refactor: move print_rhofft and print_wfcfft to ModuleIO (#5358)
* Refactor: move print_rhofft to ModuleIO * Refactor: move print_wfcfft to ModuleIO
1 parent 821b184 commit fe3b44f

File tree

10 files changed

+192
-267
lines changed

10 files changed

+192
-267
lines changed

source/Makefile.Objects

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ OBJS_ESOLVER=esolver.o\
243243
esolver_of.o\
244244
esolver_of_tool.o\
245245
esolver_of_interface.o\
246-
print_funcs.o\
247246
pw_fun.o\
248247
pw_init_after_vc.o\
249248
pw_init_globalc.o\

source/module_esolver/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ list(APPEND objects
1010
esolver_of.cpp
1111
esolver_of_interface.cpp
1212
esolver_of_tool.cpp
13-
print_funcs.cpp
1413
pw_fun.cpp
1514
pw_init_after_vc.cpp
1615
pw_init_globalc.cpp

source/module_esolver/esolver_fp.cpp

Lines changed: 5 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#include "esolver_fp.h"
22

33
#include "module_base/global_variable.h"
4+
#include "module_elecstate/module_charge/symmetry_rho.h"
45
#include "module_hamilt_pw/hamilt_pwdft/global.h"
6+
#include "module_io/cif_io.h"
57
#include "module_io/cube_io.h"
68
#include "module_io/output_log.h"
9+
#include "module_io/print_info.h"
10+
#include "module_io/rhog_io.h"
711
#include "module_io/write_elecstat_pot.h"
812
#include "module_io/write_elf.h"
913
#include "module_parameter/parameter.h"
10-
#include "module_io/rhog_io.h"
11-
#include "module_io/cif_io.h"
12-
#include "module_elecstate/module_charge/symmetry_rho.h"
1314

1415
namespace ModuleESolver
1516
{
@@ -116,7 +117,7 @@ void ESolver_FP::before_all_runners(const Input_para& inp, UnitCell& cell)
116117
"data_?");
117118

118119
//! 4) print some information
119-
this->print_rhofft(inp, GlobalV::ofs_running);
120+
ModuleIO::print_rhofft(this->pw_rhod, this->pw_rho, this->pw_big, GlobalV::ofs_running);
120121

121122
//! 5) initialize the charge extrapolation method if necessary
122123
this->CE.Init_CE(PARAM.inp.nspin, GlobalC::ucell.nat, this->pw_rhod->nrxx, inp.chg_extrap);
@@ -357,135 +358,4 @@ void ESolver_FP::init_after_vc(const Input_para& inp, UnitCell& cell)
357358
return;
358359
}
359360

360-
void ESolver_FP::print_rhofft(const Input_para& inp, std::ofstream& ofs)
361-
{
362-
std::cout << " UNIFORM GRID DIM : " << pw_rho->nx << " * " << pw_rho->ny << " * " << pw_rho->nz << std::endl;
363-
std::cout << " UNIFORM GRID DIM(BIG) : " << pw_big->nbx << " * " << pw_big->nby << " * " << pw_big->nbz
364-
<< std::endl;
365-
if ( PARAM.globalv.double_grid)
366-
{
367-
std::cout << " UNIFORM GRID DIM(DENSE) : " << pw_rhod->nx << " * " << pw_rhod->ny << " * " << pw_rhod->nz
368-
<< std::endl;
369-
}
370-
371-
ofs << "\n\n\n\n";
372-
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
373-
">>>>"
374-
<< std::endl;
375-
ofs << " | "
376-
" |"
377-
<< std::endl;
378-
ofs << " | Setup plane waves of charge/potential: "
379-
" |"
380-
<< std::endl;
381-
ofs << " | Use the energy cutoff and the lattice vectors to generate the "
382-
" |"
383-
<< std::endl;
384-
ofs << " | dimensions of FFT grid. The number of FFT grid on each "
385-
"processor |"
386-
<< std::endl;
387-
ofs << " | is 'nrxx'. The number of plane wave basis in reciprocal space "
388-
"is |"
389-
<< std::endl;
390-
ofs << " | different for charege/potential and wave functions. We also set "
391-
" |"
392-
<< std::endl;
393-
ofs << " | the 'sticks' for the parallel of FFT. The number of plane waves "
394-
" |"
395-
<< std::endl;
396-
ofs << " | is 'npw' in each processor. "
397-
" |"
398-
<< std::endl;
399-
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
400-
"<<<<"
401-
<< std::endl;
402-
ofs << "\n\n\n\n";
403-
ofs << "\n SETUP THE PLANE WAVE BASIS" << std::endl;
404-
405-
double ecut = 4 * PARAM.inp.ecutwfc;
406-
if (inp.nx * inp.ny * inp.nz > 0)
407-
{
408-
ecut = this->pw_rho->gridecut_lat * this->pw_rho->tpiba2;
409-
ofs << "use input fft dimensions for wave functions." << std::endl;
410-
ofs << "calculate energy cutoff from nx, ny, nz:" << std::endl;
411-
}
412-
413-
ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for charge/potential (unit:Ry)", ecut);
414-
415-
ModuleBase::GlobalFunc::OUT(ofs,
416-
"fft grid for charge/potential",
417-
this->pw_rho->nx,
418-
this->pw_rho->ny,
419-
this->pw_rho->nz);
420-
ModuleBase::GlobalFunc::OUT(ofs, "fft grid division", pw_big->bx, pw_big->by, pw_big->bz);
421-
ModuleBase::GlobalFunc::OUT(ofs, "big fft grid for charge/potential", pw_big->nbx, pw_big->nby, pw_big->nbz);
422-
ModuleBase::GlobalFunc::OUT(ofs, "nbxx", pw_big->nbxx);
423-
ModuleBase::GlobalFunc::OUT(ofs, "nrxx", this->pw_rho->nrxx);
424-
425-
ofs << "\n SETUP PLANE WAVES FOR CHARGE/POTENTIAL" << std::endl;
426-
ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", this->pw_rho->npwtot);
427-
ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", this->pw_rho->nstot);
428-
429-
ofs << "\n PARALLEL PW FOR CHARGE/POTENTIAL" << std::endl;
430-
ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl;
431-
432-
for (int i = 0; i < GlobalV::NPROC_IN_POOL; ++i)
433-
{
434-
ofs << " " << std::setw(8) << i + 1 << std::setw(15) << this->pw_rho->nst_per[i] << std::setw(15)
435-
<< this->pw_rho->npw_per[i] << std::endl;
436-
}
437-
ofs << " --------------- sum -------------------" << std::endl;
438-
ofs << " " << std::setw(8) << GlobalV::NPROC_IN_POOL << std::setw(15) << this->pw_rho->nstot << std::setw(15)
439-
<< this->pw_rho->npwtot << std::endl;
440-
441-
ModuleBase::GlobalFunc::OUT(ofs, "number of |g|", this->pw_rho->ngg);
442-
ModuleBase::GlobalFunc::OUT(ofs, "max |g|", this->pw_rho->gg_uniq[this->pw_rho->ngg - 1]);
443-
ModuleBase::GlobalFunc::OUT(ofs, "min |g|", this->pw_rho->gg_uniq[0]);
444-
445-
if ( PARAM.globalv.double_grid)
446-
{
447-
ofs << std::endl;
448-
ofs << std::endl;
449-
ofs << std::endl;
450-
double ecut = PARAM.inp.ecutrho;
451-
if (inp.ndx * inp.ndy * inp.ndz > 0)
452-
{
453-
ecut = this->pw_rhod->gridecut_lat * this->pw_rhod->tpiba2;
454-
ofs << "use input fft dimensions for the dense part of charge "
455-
"density."
456-
<< std::endl;
457-
ofs << "calculate energy cutoff from ndx, ndy, ndz:" << std::endl;
458-
}
459-
ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for dense charge/potential (unit:Ry)", ecut);
460-
461-
ModuleBase::GlobalFunc::OUT(ofs,
462-
"fft grid for dense charge/potential",
463-
this->pw_rhod->nx,
464-
this->pw_rhod->ny,
465-
this->pw_rhod->nz);
466-
467-
ModuleBase::GlobalFunc::OUT(ofs, "nrxx", this->pw_rhod->nrxx);
468-
469-
ofs << "\n SETUP PLANE WAVES FOR dense CHARGE/POTENTIAL" << std::endl;
470-
ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", this->pw_rhod->npwtot);
471-
ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", this->pw_rhod->nstot);
472-
473-
ofs << "\n PARALLEL PW FOR dense CHARGE/POTENTIAL" << std::endl;
474-
ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl;
475-
476-
for (int i = 0; i < GlobalV::NPROC_IN_POOL; ++i)
477-
{
478-
ofs << " " << std::setw(8) << i + 1 << std::setw(15) << this->pw_rhod->nst_per[i] << std::setw(15)
479-
<< this->pw_rhod->npw_per[i] << std::endl;
480-
}
481-
ofs << " --------------- sum -------------------" << std::endl;
482-
ofs << " " << std::setw(8) << GlobalV::NPROC_IN_POOL << std::setw(15) << this->pw_rhod->nstot << std::setw(15)
483-
<< this->pw_rhod->npwtot << std::endl;
484-
485-
ModuleBase::GlobalFunc::OUT(ofs, "number of |g|", this->pw_rhod->ngg);
486-
ModuleBase::GlobalFunc::OUT(ofs, "max |g|", this->pw_rhod->gg_uniq[this->pw_rhod->ngg - 1]);
487-
ModuleBase::GlobalFunc::OUT(ofs, "min |g|", this->pw_rhod->gg_uniq[0]);
488-
}
489-
}
490-
491361
} // namespace ModuleESolver

source/module_esolver/esolver_fp.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ namespace ModuleESolver
6767

6868
//! Charge extrapolation
6969
Charge_Extra CE;
70-
71-
private:
72-
73-
//! Print charge density using FFT
74-
void print_rhofft(const Input_para& inp, std::ofstream &ofs);
7570
};
7671
}
7772

source/module_esolver/esolver_ks.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#endif
2727
#include "module_io/json_output/output_info.h"
2828

29-
#include "print_funcs.h" // mohan add 2024-07-27
30-
3129
namespace ModuleESolver
3230
{
3331

@@ -265,7 +263,7 @@ void ESolver_KS<T, Device>::before_all_runners(const Input_para& inp, UnitCell&
265263

266264
this->pw_wfc->collect_local_pw(inp.erf_ecut, inp.erf_height, inp.erf_sigma);
267265

268-
Print_functions::print_wfcfft(inp, *this->pw_wfc, GlobalV::ofs_running);
266+
ModuleIO::print_wfcfft(inp, *this->pw_wfc, GlobalV::ofs_running);
269267

270268
//! 10) initialize the real-space uniform grid for FFT and parallel
271269
//! distribution of plane waves

source/module_esolver/esolver_ks.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,9 @@ class ESolver_KS : public ESolver_FP
9797
// wavefunction coefficients
9898
psi::Psi<T>* psi = nullptr;
9999

100-
protected:
101-
102-
std::string basisname; //PW or LCAO
103-
104-
void print_wfcfft(const Input_para& inp, std::ofstream& ofs);
105-
106-
double esolver_KS_ne = 0.0;
100+
protected:
101+
std::string basisname; // PW or LCAO
102+
double esolver_KS_ne = 0.0;
107103
};
108104
} // end of namespace
109105
#endif

source/module_esolver/print_funcs.cpp

Lines changed: 0 additions & 83 deletions
This file was deleted.

source/module_esolver/print_funcs.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)