Skip to content

Commit 7d8fce1

Browse files
committed
Refactor: dd TITLE and timer::tick for esolver
1 parent c9c0189 commit 7d8fce1

File tree

8 files changed

+44
-4
lines changed

8 files changed

+44
-4
lines changed

source/module_esolver/esolver_fp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
129129
//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
130130
void ESolver_FP::after_scf(UnitCell& ucell, const int istep)
131131
{
132+
ModuleBase::TITLE("ESolver_FP", "after_scf");
133+
132134
// 0) output convergence information
133135
ModuleIO::output_convergence_after_scf(this->conv_esolver, this->pelec->f_en.etot);
134136

source/module_esolver/esolver_ks.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ void ESolver_KS<T, Device>::runner(UnitCell& ucell, const int istep)
427427
ModuleBase::timer::tick(this->classname, "runner");
428428

429429
// 2) before_scf (electronic iteration loops)
430-
ModuleBase::timer::tick(this->classname, "before_scf");
431430
this->before_scf(ucell, istep);
432-
ModuleBase::timer::tick(this->classname, "before_scf");
433431

434432
// 3) write charge density
435433
if (PARAM.inp.dm_to_rho)
@@ -468,9 +466,7 @@ void ESolver_KS<T, Device>::runner(UnitCell& ucell, const int istep)
468466
} // end scf iterations
469467

470468
// 9) after scf
471-
ModuleBase::timer::tick(this->classname, "after_scf");
472469
this->after_scf(ucell, istep);
473-
ModuleBase::timer::tick(this->classname, "after_scf");
474470

475471
ModuleBase::timer::tick(this->classname, "runner");
476472
return;
@@ -740,6 +736,8 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
740736
template <typename T, typename Device>
741737
void ESolver_KS<T, Device>::after_scf(UnitCell& ucell, const int istep)
742738
{
739+
ModuleBase::TITLE("ESolver_KS", "after_scf");
740+
743741
// 1) call after_scf() of ESolver_FP
744742
ESolver_FP::after_scf(ucell, istep);
745743

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ template <typename TK, typename TR>
903903
void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
904904
{
905905
ModuleBase::TITLE("ESolver_KS_LCAO", "after_scf");
906+
ModuleBase::timer::tick("ESolver_KS_LCAO", "after_scf");
907+
906908
// 1) calculate the kinetic energy density tau, sunliang 2024-09-18
907909
if (PARAM.inp.out_elf[0] > 0)
908910
{
@@ -1266,6 +1268,8 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12661268
bp.Macroscopic_polarization(ucell,this->pw_wfc->npwk_max, this->psi, this->pw_rho, this->pw_wfc, this->kv);
12671269
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Berry phase calculation");
12681270
}
1271+
1272+
ModuleBase::timer::tick("ESolver_KS_LCAO", "after_scf");
12691273
}
12701274

12711275
template class ESolver_KS_LCAO<double, double>;

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ void ESolver_KS_LCAO_TDDFT::update_pot(UnitCell& ucell, const int istep, const i
281281

282282
void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int istep)
283283
{
284+
ModuleBase::TITLE("ESolver_KS_LCAO_TDDFT", "after_scf");
285+
ModuleBase::timer::tick("ESolver_KS_LCAO_TDDFT", "after_scf");
286+
284287
for (int is = 0; is < PARAM.inp.nspin; is++)
285288
{
286289
if (module_tddft::Evolve_elec::out_dipole == 1)
@@ -306,6 +309,8 @@ void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int istep)
306309
this->RA);
307310
}
308311
ESolver_KS_LCAO<std::complex<double>, double>::after_scf(ucell, istep);
312+
313+
ModuleBase::timer::tick("ESolver_KS_LCAO_TDDFT", "after_scf");
309314
}
310315

311316
void ESolver_KS_LCAO_TDDFT::weight_dm_rho()

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ template <typename T, typename Device>
247247
void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
248248
{
249249
ModuleBase::TITLE("ESolver_KS_PW", "before_scf");
250+
ModuleBase::timer::tick("ESolver_KS_PW", "before_scf");
250251

251252
//! 1) call before_scf() of ESolver_KS
252253
ESolver_KS<T, Device>::before_scf(ucell, istep);
@@ -427,6 +428,8 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
427428
this->already_initpsi = true;
428429
}
429430
}
431+
432+
ModuleBase::timer::tick("ESolver_KS_PW", "before_scf");
430433
}
431434

432435
template <typename T, typename Device>
@@ -647,6 +650,9 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
647650
template <typename T, typename Device>
648651
void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep)
649652
{
653+
ModuleBase::TITLE("ESolver_KS_PW", "after_scf");
654+
ModuleBase::timer::tick("ESolver_KS_PW", "after_scf");
655+
650656
// 1) calculate the kinetic energy density tau, sunliang 2024-09-18
651657
if (PARAM.inp.out_elf[0] > 0)
652658
{
@@ -741,6 +747,8 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep)
741747
auto* onsite_p = projectors::OnsiteProjector<double, Device>::get_instance();
742748
onsite_p->cal_occupations(reinterpret_cast<psi::Psi<std::complex<double>, Device>*>(this->kspw_psi), this->pelec->wg);
743749
}
750+
751+
ModuleBase::timer::tick("ESolver_KS_PW", "after_scf");
744752
}
745753

746754
template <typename T, typename Device>

source/module_esolver/esolver_of.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ void ESolver_OF::runner(UnitCell& ucell, const int istep)
200200
*/
201201
void ESolver_OF::before_opt(const int istep, UnitCell& ucell)
202202
{
203+
ModuleBase::TITLE("ESolver_OF", "before_opt");
204+
ModuleBase::timer::tick("ESolver_OF", "before_opt");
205+
203206
//! 1) call before_scf() of ESolver_FP
204207
ESolver_FP::before_scf(ucell, istep);
205208

@@ -299,6 +302,8 @@ void ESolver_OF::before_opt(const int istep, UnitCell& ucell)
299302
{
300303
this->theta_[0] = 0.2;
301304
}
305+
306+
ModuleBase::timer::tick("ESolver_OF", "before_opt");
302307
}
303308

304309
/**
@@ -483,6 +488,9 @@ bool ESolver_OF::check_exit()
483488
*/
484489
void ESolver_OF::after_opt(const int istep, UnitCell& ucell)
485490
{
491+
ModuleBase::TITLE("ESolver_OF", "after_opt");
492+
ModuleBase::timer::tick("ESolver_OF", "after_opt");
493+
486494
// 1) calculate the kinetic energy density
487495
if (PARAM.inp.out_elf[0] > 0)
488496
{
@@ -491,6 +499,8 @@ void ESolver_OF::after_opt(const int istep, UnitCell& ucell)
491499

492500
// 2) call after_scf() of ESolver_FP
493501
ESolver_FP::after_scf(ucell, istep);
502+
503+
ModuleBase::timer::tick("ESolver_OF", "after_opt");
494504
}
495505

496506
/**

source/module_esolver/esolver_sdft_pw.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ void ESolver_SDFT_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input
9494
template <typename T, typename Device>
9595
void ESolver_SDFT_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
9696
{
97+
ModuleBase::TITLE("ESolver_SDFT_PW", "before_scf");
98+
ModuleBase::timer::tick("ESolver_SDFT_PW", "before_scf");
99+
97100
ESolver_KS_PW<T, Device>::before_scf(ucell, istep);
98101
delete reinterpret_cast<hamilt::HamiltPW<double>*>(this->p_hamilt);
99102
this->p_hamilt = new hamilt::HamiltSdftPW<T, Device>(this->pelec->pot,
@@ -110,6 +113,8 @@ void ESolver_SDFT_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
110113
{
111114
this->stowf.update_sto_orbitals(PARAM.inp.seed_sto);
112115
}
116+
117+
ModuleBase::timer::tick("ESolver_SDFT_PW", "before_scf");
113118
}
114119

115120
template <typename T, typename Device>
@@ -122,8 +127,13 @@ void ESolver_SDFT_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, i
122127
template <typename T, typename Device>
123128
void ESolver_SDFT_PW<T, Device>::after_scf(UnitCell& ucell, const int istep)
124129
{
130+
ModuleBase::TITLE("ESolver_SDFT_PW", "after_scf");
131+
ModuleBase::timer::tick("ESolver_SDFT_PW", "after_scf");
132+
125133
// 1) call after_scf() of ESolver_KS_PW
126134
ESolver_KS_PW<T, Device>::after_scf(ucell, istep);
135+
136+
ModuleBase::timer::tick("ESolver_SDFT_PW", "after_scf");
127137
}
128138

129139
template <typename T, typename Device>

source/module_esolver/lcao_before_scf.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ template <typename TK, typename TR>
4343
void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
4444
{
4545
ModuleBase::TITLE("ESolver_KS_LCAO", "before_scf");
46+
ModuleBase::timer::tick("ESolver_KS_LCAO", "before_scf");
4647

4748
//! 1) call before_scf() of ESolver_KS
4849
ESolver_KS<TK>::before_scf(ucell, istep);
@@ -347,6 +348,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
347348
1);
348349
}
349350

351+
ModuleBase::timer::tick("ESolver_KS_LCAO", "before_scf");
350352
return;
351353
}
352354

@@ -377,6 +379,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
377379
this->sf.strucFac); // add by jghan, 2024-03-16/2024-10-08
378380
}
379381

382+
ModuleBase::timer::tick("ESolver_KS_LCAO", "before_scf");
380383
return;
381384
}
382385

0 commit comments

Comments
 (0)