Skip to content

Commit b73b88b

Browse files
committed
Refactor: move print_wfcfft to ModuleIO
1 parent fdbd787 commit b73b88b

File tree

8 files changed

+71
-110
lines changed

8 files changed

+71
-110
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_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.

source/module_io/print_info.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,70 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod,
315315
}
316316
}
317317

318+
void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofstream& ofs)
319+
{
320+
ofs << "\n\n\n\n";
321+
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
322+
">>>>"
323+
<< std::endl;
324+
ofs << " | "
325+
" |"
326+
<< std::endl;
327+
ofs << " | Setup plane waves of wave functions: "
328+
" |"
329+
<< std::endl;
330+
ofs << " | Use the energy cutoff and the lattice vectors to generate the "
331+
" |"
332+
<< std::endl;
333+
ofs << " | dimensions of FFT grid. The number of FFT grid on each "
334+
"processor |"
335+
<< std::endl;
336+
ofs << " | is 'nrxx'. The number of plane wave basis in reciprocal space "
337+
"is |"
338+
<< std::endl;
339+
ofs << " | different for charege/potential and wave functions. We also set "
340+
" |"
341+
<< std::endl;
342+
ofs << " | the 'sticks' for the parallel of FFT. The number of plane wave "
343+
"of |"
344+
<< std::endl;
345+
ofs << " | each k-point is 'npwk[ik]' in each processor "
346+
" |"
347+
<< std::endl;
348+
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
349+
"<<<<"
350+
<< std::endl;
351+
ofs << "\n\n\n\n";
352+
ofs << "\n SETUP PLANE WAVES FOR WAVE FUNCTIONS" << std::endl;
353+
354+
double ecut = inp.ecutwfc;
355+
if (std::abs(ecut - pw_wfc.gk_ecut * pw_wfc.tpiba2) > 1e-6)
356+
{
357+
ecut = pw_wfc.gk_ecut * pw_wfc.tpiba2;
358+
ofs << "Energy cutoff for wavefunc is incompatible with nx, ny, nz and "
359+
"it will be reduced!"
360+
<< std::endl;
361+
}
362+
ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for wavefunc (unit:Ry)", ecut);
363+
ModuleBase::GlobalFunc::OUT(ofs, "fft grid for wave functions", pw_wfc.nx, pw_wfc.ny, pw_wfc.nz);
364+
ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_wfc.npwtot);
365+
ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_wfc.nstot);
366+
367+
ofs << "\n PARALLEL PW FOR WAVE FUNCTIONS" << std::endl;
368+
ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl;
369+
370+
for (int i = 0; i < GlobalV::NPROC_IN_POOL; ++i)
371+
{
372+
ofs << " " << std::setw(8) << i + 1 << std::setw(15) << pw_wfc.nst_per[i] << std::setw(15) << pw_wfc.npw_per[i]
373+
<< std::endl;
374+
}
375+
376+
ofs << " --------------- sum -------------------" << std::endl;
377+
ofs << " " << std::setw(8) << GlobalV::NPROC_IN_POOL << std::setw(15) << pw_wfc.nstot << std::setw(15)
378+
<< pw_wfc.npwtot << std::endl;
379+
ModuleBase::GlobalFunc::DONE(ofs, "INIT PLANEWAVE");
380+
}
381+
318382
void print_screen(const int& stress_step, const int& force_step, const int& istep)
319383
{
320384
std::cout << " -------------------------------------------" << std::endl;

source/module_io/print_info.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#define PRINT_INFO
77

88
#include "module_base/timer.h"
9+
#include "module_basis/module_pw/pw_basis_k.h"
910
#include "module_cell/klist.h"
1011
#include "module_cell/unitcell.h"
12+
#include "module_parameter/input_parameter.h"
1113

1214
namespace ModuleIO
1315
{
@@ -21,6 +23,7 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod,
2123
ModulePW::PW_Basis* pw_rho,
2224
ModulePW::PW_Basis_Big* pw_big,
2325
std::ofstream& ofs);
26+
void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofstream& ofs);
2427

2528
} // namespace ModuleIO
2629

0 commit comments

Comments
 (0)