Skip to content

Commit 1143ff5

Browse files
committed
Refactor: move print_rhofft to ModuleIO
1 parent 729059f commit 1143ff5

File tree

4 files changed

+124
-160
lines changed

4 files changed

+124
-160
lines changed

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_io/print_info.cpp

Lines changed: 114 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -189,36 +189,131 @@ void print_time(time_t& time_start, time_t& time_finish)
189189
<< unsigned(secs) << " secs "<< std::endl;
190190
}
191191

192-
/*
193-
void ModuleIO::print_scf(const int &istep, const int &iter)
192+
void print_rhofft(ModulePW::PW_Basis* pw_rhod,
193+
ModulePW::PW_Basis* pw_rho,
194+
ModulePW::PW_Basis_Big* pw_big,
195+
std::ofstream& ofs)
194196
{
195-
if(PARAM.inp.basis_type=="pw")
197+
std::cout << " UNIFORM GRID DIM : " << pw_rho->nx << " * " << pw_rho->ny << " * " << pw_rho->nz << std::endl;
198+
std::cout << " UNIFORM GRID DIM(BIG) : " << pw_big->nbx << " * " << pw_big->nby << " * " << pw_big->nbz
199+
<< std::endl;
200+
if (PARAM.globalv.double_grid)
196201
{
197-
GlobalV::ofs_running << "\n PW ALGORITHM ------------- ";
198-
}
199-
else
200-
{
201-
GlobalV::ofs_running << "\n LCAO ALGORITHM ------------- ";
202+
std::cout << " UNIFORM GRID DIM(DENSE) : " << pw_rhod->nx << " * " << pw_rhod->ny << " * " << pw_rhod->nz
203+
<< std::endl;
202204
}
203205

204-
if(PARAM.inp.calculation=="scf")
206+
ofs << "\n\n\n\n";
207+
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
208+
">>>>"
209+
<< std::endl;
210+
ofs << " | "
211+
" |"
212+
<< std::endl;
213+
ofs << " | Setup plane waves of charge/potential: "
214+
" |"
215+
<< std::endl;
216+
ofs << " | Use the energy cutoff and the lattice vectors to generate the "
217+
" |"
218+
<< std::endl;
219+
ofs << " | dimensions of FFT grid. The number of FFT grid on each "
220+
"processor |"
221+
<< std::endl;
222+
ofs << " | is 'nrxx'. The number of plane wave basis in reciprocal space "
223+
"is |"
224+
<< std::endl;
225+
ofs << " | different for charege/potential and wave functions. We also set "
226+
" |"
227+
<< std::endl;
228+
ofs << " | the 'sticks' for the parallel of FFT. The number of plane waves "
229+
" |"
230+
<< std::endl;
231+
ofs << " | is 'npw' in each processor. "
232+
" |"
233+
<< std::endl;
234+
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
235+
"<<<<"
236+
<< std::endl;
237+
ofs << "\n\n\n\n";
238+
ofs << "\n SETUP THE PLANE WAVE BASIS" << std::endl;
239+
240+
double ecut = 4 * PARAM.inp.ecutwfc;
241+
if (PARAM.inp.nx * PARAM.inp.ny * PARAM.inp.nz > 0)
205242
{
206-
GlobalV::ofs_running << "ELEC = " << std::setw(4) << unsigned(iter);
243+
ecut = pw_rho->gridecut_lat * pw_rho->tpiba2;
244+
ofs << "use input fft dimensions for wave functions." << std::endl;
245+
ofs << "calculate energy cutoff from nx, ny, nz:" << std::endl;
207246
}
208-
else if(PARAM.inp.calculation=="relax" || PARAM.inp.calculation=="cell-relax")
247+
248+
ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for charge/potential (unit:Ry)", ecut);
249+
250+
ModuleBase::GlobalFunc::OUT(ofs, "fft grid for charge/potential", pw_rho->nx, pw_rho->ny, pw_rho->nz);
251+
ModuleBase::GlobalFunc::OUT(ofs, "fft grid division", pw_big->bx, pw_big->by, pw_big->bz);
252+
ModuleBase::GlobalFunc::OUT(ofs, "big fft grid for charge/potential", pw_big->nbx, pw_big->nby, pw_big->nbz);
253+
ModuleBase::GlobalFunc::OUT(ofs, "nbxx", pw_big->nbxx);
254+
ModuleBase::GlobalFunc::OUT(ofs, "nrxx", pw_rho->nrxx);
255+
256+
ofs << "\n SETUP PLANE WAVES FOR CHARGE/POTENTIAL" << std::endl;
257+
ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_rho->npwtot);
258+
ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_rho->nstot);
259+
260+
ofs << "\n PARALLEL PW FOR CHARGE/POTENTIAL" << std::endl;
261+
ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl;
262+
263+
for (int i = 0; i < GlobalV::NPROC_IN_POOL; ++i)
209264
{
210-
GlobalV::ofs_running << "ION = " << std::setw(4) << unsigned(istep+1)
211-
<< " ELEC = " << std::setw(4) << unsigned(iter);
265+
ofs << " " << std::setw(8) << i + 1 << std::setw(15) << pw_rho->nst_per[i] << std::setw(15)
266+
<< pw_rho->npw_per[i] << std::endl;
212267
}
213-
else if(PARAM.inp.calculation=="md")
268+
ofs << " --------------- sum -------------------" << std::endl;
269+
ofs << " " << std::setw(8) << GlobalV::NPROC_IN_POOL << std::setw(15) << pw_rho->nstot << std::setw(15)
270+
<< pw_rho->npwtot << std::endl;
271+
272+
ModuleBase::GlobalFunc::OUT(ofs, "number of |g|", pw_rho->ngg);
273+
ModuleBase::GlobalFunc::OUT(ofs, "max |g|", pw_rho->gg_uniq[pw_rho->ngg - 1]);
274+
ModuleBase::GlobalFunc::OUT(ofs, "min |g|", pw_rho->gg_uniq[0]);
275+
276+
if (PARAM.globalv.double_grid)
214277
{
215-
GlobalV::ofs_running << "MD = " << std::setw(4) << unsigned(istep+1)
216-
<< " ELEC = " << std::setw(4) << unsigned(iter);
217-
}
278+
ofs << std::endl;
279+
ofs << std::endl;
280+
ofs << std::endl;
281+
double ecut = PARAM.inp.ecutrho;
282+
if (PARAM.inp.ndx * PARAM.inp.ndy * PARAM.inp.ndz > 0)
283+
{
284+
ecut = pw_rhod->gridecut_lat * pw_rhod->tpiba2;
285+
ofs << "use input fft dimensions for the dense part of charge "
286+
"density."
287+
<< std::endl;
288+
ofs << "calculate energy cutoff from ndx, ndy, ndz:" << std::endl;
289+
}
290+
ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for dense charge/potential (unit:Ry)", ecut);
291+
292+
ModuleBase::GlobalFunc::OUT(ofs, "fft grid for dense charge/potential", pw_rhod->nx, pw_rhod->ny, pw_rhod->nz);
293+
294+
ModuleBase::GlobalFunc::OUT(ofs, "nrxx", pw_rhod->nrxx);
295+
296+
ofs << "\n SETUP PLANE WAVES FOR dense CHARGE/POTENTIAL" << std::endl;
297+
ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_rhod->npwtot);
298+
ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_rhod->nstot);
218299

219-
GlobalV::ofs_running << " --------------------------------\n";
300+
ofs << "\n PARALLEL PW FOR dense CHARGE/POTENTIAL" << std::endl;
301+
ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl;
302+
303+
for (int i = 0; i < GlobalV::NPROC_IN_POOL; ++i)
304+
{
305+
ofs << " " << std::setw(8) << i + 1 << std::setw(15) << pw_rhod->nst_per[i] << std::setw(15)
306+
<< pw_rhod->npw_per[i] << std::endl;
307+
}
308+
ofs << " --------------- sum -------------------" << std::endl;
309+
ofs << " " << std::setw(8) << GlobalV::NPROC_IN_POOL << std::setw(15) << pw_rhod->nstot << std::setw(15)
310+
<< pw_rhod->npwtot << std::endl;
311+
312+
ModuleBase::GlobalFunc::OUT(ofs, "number of |g|", pw_rhod->ngg);
313+
ModuleBase::GlobalFunc::OUT(ofs, "max |g|", pw_rhod->gg_uniq[pw_rhod->ngg - 1]);
314+
ModuleBase::GlobalFunc::OUT(ofs, "min |g|", pw_rhod->gg_uniq[0]);
315+
}
220316
}
221-
*/
222317

223318
void print_screen(const int& stress_step, const int& force_step, const int& istep)
224319
{

source/module_io/print_info.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ namespace ModuleIO
1515
// print out to screen about the readin parameters
1616
void setup_parameters(UnitCell& ucell, K_Vectors& kv);
1717
void print_time(time_t& time_start, time_t& time_finish);
18-
void print_scf(const int& istep, const int& iter);
1918
void print_screen(const int& stress_step, const int& force_step, const int& istep);
19+
//! Print charge density using FFT
20+
void print_rhofft(ModulePW::PW_Basis* pw_rhod,
21+
ModulePW::PW_Basis* pw_rho,
22+
ModulePW::PW_Basis_Big* pw_big,
23+
std::ofstream& ofs);
2024

2125
} // namespace ModuleIO
2226

0 commit comments

Comments
 (0)