Skip to content

Commit d14d6db

Browse files
committed
fix some output formats
1 parent 64987aa commit d14d6db

File tree

12 files changed

+82
-135
lines changed

12 files changed

+82
-135
lines changed

source/module_elecstate/elecstate_print.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ void print_etot(const Magnetism& magnet,
166166
const double& scf_thr,
167167
const double& scf_thr_kin,
168168
const double& duration,
169-
const int printe,
170169
const double& pw_diag_thr,
171170
const double& avg_iter,
172171
const bool print)
@@ -190,8 +189,8 @@ void print_etot(const Magnetism& magnet,
190189
std::vector<double> energies_Ry;
191190
std::vector<double> energies_eV;
192191

193-
if (printe > 0 && ((iter + 1) % printe == 0 || converged || iter == PARAM.inp.scf_nmax))
194-
{
192+
if( (iter % PARAM.inp.out_freq_elec == 0) || converged || iter == PARAM.inp.scf_nmax )
193+
{
195194
int n_order = std::max(0, Occupy::gaussian_type);
196195
titles.push_back("E_KohnSham");
197196
energies_Ry.push_back(elec.f_en.etot);

source/module_elecstate/elecstate_print.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace elecstate
1515
const double& scf_thr,
1616
const double& scf_thr_kin,
1717
const double& duration,
18-
const int printe,
1918
const double& pw_diag_thr = 0,
2019
const double& avg_iter = 0,
2120
bool print = true);

source/module_elecstate/read_pseudo.cpp

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,15 @@ namespace elecstate {
1212
void read_pseudo(std::ofstream& ofs, UnitCell& ucell) {
1313
// read in non-local pseudopotential and ouput the projectors.
1414
ofs << "\n\n";
15-
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
16-
">>>>" << std::endl;
17-
ofs << " | "
18-
" |" << std::endl;
19-
ofs << " | Reading pseudopotentials files: "
20-
" |" << std::endl;
21-
ofs << " | The pseudopotential file is in UPF format. The 'NC' indicates "
22-
"that |" << std::endl;
23-
ofs << " | the type of pseudopotential is 'norm conserving'. Functional of "
24-
" |" << std::endl;
25-
ofs << " | exchange and correlation is decided by 4 given parameters in "
26-
"UPF |" << std::endl;
27-
ofs << " | file. We also read in the 'core correction' if there exists. "
28-
" |" << std::endl;
29-
ofs << " | Also we can read the valence electrons number and the maximal "
30-
" |" << std::endl;
31-
ofs << " | angular momentum used in this pseudopotential. We also read in "
32-
"the |" << std::endl;
33-
ofs << " | trail wave function, trail atomic density and "
34-
"local-pseudopotential|" << std::endl;
35-
ofs << " | on logrithmic grid. The non-local pseudopotential projector is "
36-
"also|" << std::endl;
37-
ofs << " | read in if there is any. "
38-
" |" << std::endl;
39-
ofs << " | "
40-
" |" << std::endl;
41-
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
42-
"<<<<" << std::endl;
15+
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
16+
ofs << " | |" << std::endl;
17+
ofs << " | #Read Pseudopotentials Files# |" << std::endl;
18+
ofs << " | ABACUS supports norm-conserving (NC) pseudopotentials for both |" << std::endl;
19+
ofs << " | plane wave basis and numerical atomic orbital basis sets. |" << std::endl;
20+
ofs << " | In addition, ABACUS supports ultrasoft pseudopotentials (USPP) |" << std::endl;
21+
ofs << " | for plane wave basis set. |" << std::endl;
22+
ofs << " | |" << std::endl;
23+
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
4324
ofs << "\n";
4425

4526
read_cell_pseudopots(PARAM.inp.pseudo_dir, ofs, ucell);

source/module_elecstate/test/elecstate_print_test.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ TEST_F(ElecStatePrintTest, PrintEtot)
122122
double scf_thr = 0.1;
123123
double scf_thr_kin = 0.0;
124124
double duration = 2.0;
125-
int printe = 1;
126125
double pw_diag_thr = 0.1;
127126
int avg_iter = 2;
128127
bool print = true;
129128
elecstate.charge = new Charge;
130129
elecstate.charge->nrxx = 100;
131130
elecstate.charge->nxyz = 1000;
131+
PARAM.input.out_freq_elec = 1;
132132
PARAM.input.imp_sol = true;
133133
PARAM.input.efield_flag = true;
134134
PARAM.input.gate_flag = true;
@@ -137,20 +137,23 @@ TEST_F(ElecStatePrintTest, PrintEtot)
137137
GlobalV::MY_RANK = 0;
138138
PARAM.input.basis_type = "pw";
139139
PARAM.input.nspin = 2;
140+
140141
// iteration of different vdw_method
141142
std::vector<std::string> vdw_methods = {"d2", "d3_0", "d3_bj"};
142143
for (int i = 0; i < vdw_methods.size(); i++)
143144
{
144145
PARAM.input.vdw_method = vdw_methods[i];
145-
elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, false);
146+
elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr,
147+
scf_thr_kin, duration, pw_diag_thr, avg_iter, false);
146148
}
149+
147150
// iteration of different ks_solver
148151
std::vector<std::string> ks_solvers = {"cg", "lapack", "genelpa", "dav", "scalapack_gvx", "cusolver"};
149152
for (int i = 0; i < ks_solvers.size(); i++)
150153
{
151154
PARAM.input.ks_solver = ks_solvers[i];
152155
testing::internal::CaptureStdout();
153-
elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
156+
elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, pw_diag_thr, avg_iter, print);
154157
output = testing::internal::GetCapturedStdout();
155158
if (PARAM.input.ks_solver == "cg")
156159
{
@@ -202,10 +205,10 @@ TEST_F(ElecStatePrintTest, PrintEtot2)
202205
double scf_thr = 0.1;
203206
double scf_thr_kin = 0.0;
204207
double duration = 2.0;
205-
int printe = 0;
206208
double pw_diag_thr = 0.1;
207209
int avg_iter = 2;
208210
bool print = true;
211+
PARAM.input.out_freq_elec = 0;
209212
elecstate.charge = new Charge;
210213
elecstate.charge->nrxx = 100;
211214
elecstate.charge->nxyz = 1000;
@@ -218,7 +221,9 @@ TEST_F(ElecStatePrintTest, PrintEtot2)
218221
PARAM.input.basis_type = "pw";
219222
PARAM.input.scf_nmax = 100;
220223

221-
elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
224+
elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration,
225+
pw_diag_thr, avg_iter, print);
226+
222227
GlobalV::ofs_running.close();
223228
ifs.open("test.dat", std::ios::in);
224229
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
@@ -240,21 +245,25 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS2)
240245
double scf_thr = 2.0;
241246
double scf_thr_kin = 0.0;
242247
double duration = 2.0;
243-
int printe = 1;
244248
double pw_diag_thr = 0.1;
245249
int avg_iter = 2;
246250
bool print = true;
247251
elecstate.charge = new Charge;
248252
elecstate.charge->nrxx = 100;
249253
elecstate.charge->nxyz = 1000;
254+
255+
PARAM.input.out_freq_elec = 1;
250256
PARAM.input.imp_sol = true;
251257
PARAM.input.efield_flag = true;
252258
PARAM.input.gate_flag = true;
253259
PARAM.sys.two_fermi = true;
254260
PARAM.input.out_bandgap = true;
255261
PARAM.input.nspin = 2;
256262
GlobalV::MY_RANK = 0;
257-
elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
263+
264+
elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr,
265+
scf_thr_kin, duration, pw_diag_thr, avg_iter, print);
266+
258267
delete elecstate.charge;
259268
}
260269

@@ -265,13 +274,14 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS4)
265274
double scf_thr = 0.1;
266275
double scf_thr_kin = 0.0;
267276
double duration = 2.0;
268-
int printe = 1;
269277
double pw_diag_thr = 0.1;
270278
int avg_iter = 2;
271279
bool print = true;
272280
elecstate.charge = new Charge;
273281
elecstate.charge->nrxx = 100;
274282
elecstate.charge->nxyz = 1000;
283+
284+
PARAM.input.out_freq_elec = 1;
275285
PARAM.input.imp_sol = true;
276286
PARAM.input.efield_flag = true;
277287
PARAM.input.gate_flag = true;
@@ -280,6 +290,9 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS4)
280290
PARAM.input.nspin = 4;
281291
PARAM.input.noncolin = true;
282292
GlobalV::MY_RANK = 0;
283-
elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print);
293+
294+
elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr, scf_thr_kin,
295+
duration, pw_diag_thr, avg_iter, print);
296+
284297
delete elecstate.charge;
285298
}

source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,9 @@ void HamiltPW<T, Device>::set_exx_helper(Exx_Helper<T, Device> &exx_helper)
400400

401401
template class HamiltPW<std::complex<float>, base_device::DEVICE_CPU>;
402402
template class HamiltPW<std::complex<double>, base_device::DEVICE_CPU>;
403-
// template HamiltPW<std::complex<double>, base_device::DEVICE_CPU>::HamiltPW(const HamiltPW<std::complex<double>,
404-
// base_device::DEVICE_CPU> *hamilt);
405403
#if ((defined __CUDA) || (defined __ROCM))
406404
template class HamiltPW<std::complex<float>, base_device::DEVICE_GPU>;
407405
template class HamiltPW<std::complex<double>, base_device::DEVICE_GPU>;
408-
// template HamiltPW<std::complex<double>, base_device::DEVICE_GPU>::HamiltPW(const HamiltPW<std::complex<double>,
409-
// base_device::DEVICE_GPU> *hamilt);
410406
#endif
411407

412-
} // namespace hamilt
408+
} // namespace hamilt

source/module_io/output_log.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ void output_convergence_after_scf(const bool &convergence, double& energy, std::
1717
{
1818
if (convergence)
1919
{
20-
ofs_running << "\n charge density convergence is achieved" << std::endl;
21-
ofs_running << " final etot is " << std::setprecision(11) << energy * ModuleBase::Ry_to_eV << " eV" << std::endl;
20+
ofs_running << " #SCF IS CONVERGED#" << std::endl;
21+
// ofs_running << " final etot is " << std::setprecision(11) << energy * ModuleBase::Ry_to_eV << " eV" << std::endl;
2222
}
2323
else
2424
{
25-
ofs_running << " !! convergence has not been achieved @_@" << std::endl;
26-
std::cout << " !! CONVERGENCE HAS NOT BEEN ACHIEVED !!" << std::endl;
25+
ofs_running << " !!SCF IS NOT CONVERGED!!" << std::endl;
26+
std::cout << " !!SCF IS NOT CONVERGED!!" << std::endl;
2727
}
2828
}
2929

source/module_io/print_info.cpp

Lines changed: 27 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -209,38 +209,25 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod,
209209
}
210210

211211
ofs << "\n\n";
212-
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
213-
">>>>" << std::endl;
214-
ofs << " | "
215-
" |" << std::endl;
216-
ofs << " | Setup plane waves of charge/potential: "
217-
" |" << std::endl;
218-
ofs << " | Use the energy cutoff and the lattice vectors to generate the "
219-
" |" << std::endl;
220-
ofs << " | dimensions of FFT grid. The number of FFT grid on each "
221-
"processor |" << std::endl;
222-
ofs << " | is 'nrxx'. The number of plane wave basis in reciprocal space "
223-
"is |" << std::endl;
224-
ofs << " | different for charege/potential and wave functions. We also set "
225-
" |" << std::endl;
226-
ofs << " | the 'sticks' for the parallel of FFT. The number of plane waves "
227-
" |" << std::endl;
228-
ofs << " | is 'npw' in each processor. "
229-
" |" << std::endl;
230-
ofs << " | "
231-
" |" << std::endl;
232-
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
233-
"<<<<" << std::endl;
212+
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
213+
ofs << " | |" << std::endl;
214+
ofs << " | #Setup Plane Waves of Charge/Potential# |" << std::endl;
215+
ofs << " | Use the kinetic energy cutoff and the lattice vectors to generate |" << std::endl;
216+
ofs << " | the dimensions of FFT grid, which is used to represent the charge |" << std::endl;
217+
ofs << " | density or potential. If USPP is used, a double grid technique |" << std::endl;
218+
ofs << " | is applied. |" << std::endl;
219+
ofs << " | |" << std::endl;
220+
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
234221
ofs << "\n";
235-
ofs << " SETUP THE PLANE WAVE BASIS" << std::endl;
222+
ofs << " SETUP PLANE WAVES FOR CHARGE/POTENTIAL" << std::endl;
236223

237224

238225
double ecut = 4 * PARAM.inp.ecutwfc;
239226
if (PARAM.inp.nx * PARAM.inp.ny * PARAM.inp.nz > 0)
240227
{
241228
ecut = pw_rho->gridecut_lat * pw_rho->tpiba2;
242-
ofs << "use input fft dimensions for wave functions." << std::endl;
243-
ofs << "calculate energy cutoff from nx, ny, nz:" << std::endl;
229+
ofs << " FFT DIMENSIONS ARE FROM INPUT" << std::endl;
230+
ofs << " KINETIC ENEGY CUTOFF IS DETERMINED FROM nx, ny, nz" << std::endl;
244231
}
245232

246233
ModuleBase::GlobalFunc::OUT(ofs, "Energy cutoff for charge/potential (Ry)", ecut);
@@ -251,7 +238,6 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod,
251238
ModuleBase::GlobalFunc::OUT(ofs, "FFT (big) grid for charge/potential", pw_big->nbx, pw_big->nby, pw_big->nbz);
252239
ModuleBase::GlobalFunc::OUT(ofs, "Number of FFT (big) grids this proc.", pw_big->nbxx);
253240

254-
ofs << "\n SETUP PLANE WAVES FOR CHARGE/POTENTIAL" << std::endl;
255241
ModuleBase::GlobalFunc::OUT(ofs, "Number of plane waves", pw_rho->npwtot);
256242
ModuleBase::GlobalFunc::OUT(ofs, "Number of sticks on FFT x-y plane", pw_rho->nstot);
257243

@@ -292,9 +278,9 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod,
292278

293279
ModuleBase::GlobalFunc::OUT(ofs, "nrxx", pw_rhod->nrxx);
294280

295-
ofs << "\n SETUP PLANE WAVES FOR dense CHARGE/POTENTIAL" << std::endl;
296-
ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_rhod->npwtot);
297-
ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_rhod->nstot);
281+
ofs << "\n SETUP PLANE WAVES FOR DENSE CHARGE/POTENTIAL" << std::endl;
282+
ModuleBase::GlobalFunc::OUT(ofs, "Number of plane waves", pw_rhod->npwtot);
283+
ModuleBase::GlobalFunc::OUT(ofs, "Number of sticks", pw_rhod->nstot);
298284

299285
ofs << "\n PARALLEL PW FOR dense CHARGE/POTENTIAL" << std::endl;
300286
ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl;
@@ -317,28 +303,14 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod,
317303
void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofstream& ofs)
318304
{
319305
ofs << "\n\n";
320-
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
321-
">>>>" << std::endl;
322-
ofs << " | "
323-
" |" << std::endl;
324-
ofs << " | Setup plane waves of wave functions: "
325-
" |" << std::endl;
326-
ofs << " | Use the energy cutoff and the lattice vectors to generate the "
327-
" |" << std::endl;
328-
ofs << " | dimensions of FFT grid. The number of FFT grid on each "
329-
"processor |" << std::endl;
330-
ofs << " | is 'nrxx'. The number of plane wave basis in reciprocal space "
331-
"is |" << std::endl;
332-
ofs << " | different for charege/potential and wave functions. We also set "
333-
" |" << std::endl;
334-
ofs << " | the 'sticks' for the parallel of FFT. The number of plane wave "
335-
"of |" << std::endl;
336-
ofs << " | each k-point is 'npwk[ik]' in each processor "
337-
" |" << std::endl;
338-
ofs << " | "
339-
" |" << std::endl;
340-
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
341-
"<<<<" << std::endl;
306+
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
307+
ofs << " | |" << std::endl;
308+
ofs << " | #Setup Plane Waves of Wave Functions# |" << std::endl;
309+
ofs << " | Use the kinetic energy cutoff and the lattice vectors to generate |" << std::endl;
310+
ofs << " | the dimensions of FFT grid, which is used to represent the wave |" << std::endl;
311+
ofs << " | functions of electrons. |" << std::endl;
312+
ofs << " | |" << std::endl;
313+
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
342314
ofs << "\n";
343315
ofs << " SETUP PLANE WAVES FOR WAVE FUNCTIONS" << std::endl;
344316

@@ -350,10 +322,10 @@ void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofst
350322
"it will be reduced!"
351323
<< std::endl;
352324
}
353-
ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for wavefunc (unit:Ry)", ecut);
354-
ModuleBase::GlobalFunc::OUT(ofs, "fft grid for wave functions", pw_wfc.nx, pw_wfc.ny, pw_wfc.nz);
355-
ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_wfc.npwtot);
356-
ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_wfc.nstot);
325+
ModuleBase::GlobalFunc::OUT(ofs, "Energy cutoff for wavefunc (unit:Ry)", ecut);
326+
ModuleBase::GlobalFunc::OUT(ofs, "FFT grid for wave functions", pw_wfc.nx, pw_wfc.ny, pw_wfc.nz);
327+
ModuleBase::GlobalFunc::OUT(ofs, "Number of total plane waves", pw_wfc.npwtot);
328+
ModuleBase::GlobalFunc::OUT(ofs, "Number of sticks on FFT x-y plane", pw_wfc.nstot);
357329

358330
ofs << "\n PARALLEL PW FOR WAVE FUNCTIONS" << std::endl;
359331
ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl;

0 commit comments

Comments
 (0)