Skip to content

Commit e805788

Browse files
author
abacus_fixer
committed
refactor(dftu): rename protected copy/zero/mix/set_locale -> *_occ_mat (Step 4/5)
Rename the four protected internal helpers of Plus_U_Base and their ModuleBase::TITLE / timer tag strings for consistency: copy_locale(ucell) -> copy_occ_mat(ucell) zero_locale(ucell) -> zero_occ_mat(ucell) mix_locale(ucell, mixing_beta) -> mix_occ_mat(ucell, mixing_beta) set_locale(ucell) -> set_occ_mat(ucell) The single-argument batch setter set_occ_mat(const UnitCell&) now overloads the public element-wise setter set_occ_mat(iat,l,n,spin,m1,m2,val) with a different signature — no ambiguity, no change to callers. Declarations (dftu_base.h), definitions + internal call sites in dftu_base.cpp (init_base flow, also all TITLE/timer labels), and call sites in cal_occ_pw (dftu_pw.cpp) and cal_occup_m_{k,gamma} (dftu_occup.cpp) are all updated together. 4 files changed, 32 insertions(+), 32 deletions(-).
1 parent 4afb72a commit e805788

4 files changed

Lines changed: 32 additions & 32 deletions

File tree

source/source_lcao/module_dftu/dftu_occup.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#endif
77
#include "source_base/module_external/scalapack_connector.h"
88

9-
// copy_locale(), zero_locale(), mix_locale(), set_locale(ucell),
9+
// copy_occ_mat(), zero_occ_mat(), mix_occ_mat(), set_locale(ucell),
1010
// get_locale_flat(), set_locale_flat()
1111
// are now implemented in dftu_base.cpp as Plus_U_Base methods (inherited by Plus_U).
1212

@@ -22,8 +22,8 @@ void Plus_U::cal_occup_m_k(const int iter,
2222
ModuleBase::TITLE("Plus_U", "cal_occup_m_k");
2323
ModuleBase::timer::start("Plus_U", "cal_occup_m_k");
2424

25-
this->copy_locale(ucell);
26-
this->zero_locale(ucell);
25+
this->copy_occ_mat(ucell);
26+
this->zero_occ_mat(ucell);
2727

2828
//=================Part 1======================
2929
// call SCALAPACK routine to calculate the product of the S and density matrix
@@ -238,7 +238,7 @@ void Plus_U::cal_occup_m_k(const int iter,
238238

239239
if(is_mixing_enabled() && is_occ_mat_initialized())
240240
{
241-
this->mix_locale(ucell,mixing_beta);
241+
this->mix_occ_mat(ucell,mixing_beta);
242242
}
243243

244244
mark_occ_mat_initialized();
@@ -254,8 +254,8 @@ void Plus_U::cal_occup_m_gamma(const int iter,
254254
{
255255
ModuleBase::TITLE("Plus_U", "cal_occup_m_gamma");
256256
ModuleBase::timer::start("Plus_U", "cal_occup_m_gamma");
257-
this->copy_locale(ucell);
258-
this->zero_locale(ucell);
257+
this->copy_occ_mat(ucell);
258+
this->zero_occ_mat(ucell);
259259

260260
//=================Part 1======================
261261
// call PBLAS routine to calculate the product of the S and density matrix
@@ -395,7 +395,7 @@ void Plus_U::cal_occup_m_gamma(const int iter,
395395

396396
if(is_mixing_enabled() && is_occ_mat_initialized())
397397
{
398-
this->mix_locale(ucell,mixing_beta);
398+
this->mix_occ_mat(ucell,mixing_beta);
399399
}
400400

401401
mark_occ_mat_initialized();

source/source_pw/module_pwdft/dftu_base.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void Plus_U_Base::init_base(UnitCell& cell,
239239
#endif
240240

241241
mark_occ_mat_initialized();
242-
this->copy_locale(cell);
242+
this->copy_occ_mat(cell);
243243
}
244244
else
245245
{
@@ -255,7 +255,7 @@ void Plus_U_Base::init_base(UnitCell& cell,
255255
}
256256
else
257257
{
258-
this->zero_locale(cell);
258+
this->zero_occ_mat(cell);
259259
}
260260
}
261261

@@ -307,10 +307,10 @@ bool Plus_U_Base::u_converged()
307307

308308

309309
// copy_locale — save current occ_mat to occ_mat_save and uom_save
310-
void Plus_U_Base::copy_locale(const UnitCell& ucell)
310+
void Plus_U_Base::copy_occ_mat(const UnitCell& ucell)
311311
{
312-
ModuleBase::TITLE("Plus_U_Base", "copy_locale");
313-
ModuleBase::timer::start("Plus_U_Base", "copy_locale");
312+
ModuleBase::TITLE("Plus_U_Base", "copy_occ_mat");
313+
ModuleBase::timer::start("Plus_U_Base", "copy_occ_mat");
314314

315315
for (int T = 0; T < ucell.ntype; T++)
316316
{
@@ -351,14 +351,14 @@ void Plus_U_Base::copy_locale(const UnitCell& ucell)
351351
}
352352
}
353353
}
354-
ModuleBase::timer::end("Plus_U_Base", "copy_locale");
354+
ModuleBase::timer::end("Plus_U_Base", "copy_occ_mat");
355355
}
356356

357357

358-
void Plus_U_Base::zero_locale(const UnitCell& ucell)
358+
void Plus_U_Base::zero_occ_mat(const UnitCell& ucell)
359359
{
360-
ModuleBase::TITLE("Plus_U_Base", "zero_locale");
361-
ModuleBase::timer::start("Plus_U_Base", "zero_locale");
360+
ModuleBase::TITLE("Plus_U_Base", "zero_occ_mat");
361+
ModuleBase::timer::start("Plus_U_Base", "zero_occ_mat");
362362

363363
for (int T = 0; T < ucell.ntype; T++)
364364
{
@@ -390,15 +390,15 @@ void Plus_U_Base::zero_locale(const UnitCell& ucell)
390390
}
391391
}
392392
}
393-
ModuleBase::timer::end("Plus_U_Base", "zero_locale");
393+
ModuleBase::timer::end("Plus_U_Base", "zero_occ_mat");
394394
}
395395

396396

397-
void Plus_U_Base::mix_locale(const UnitCell& ucell,
397+
void Plus_U_Base::mix_occ_mat(const UnitCell& ucell,
398398
const double& mixing_beta)
399399
{
400-
ModuleBase::TITLE("Plus_U_Base", "mix_locale");
401-
ModuleBase::timer::start("Plus_U_Base", "mix_locale");
400+
ModuleBase::TITLE("Plus_U_Base", "mix_occ_mat");
401+
ModuleBase::timer::start("Plus_U_Base", "mix_occ_mat");
402402

403403
double beta = mixing_beta;
404404

@@ -447,14 +447,14 @@ void Plus_U_Base::mix_locale(const UnitCell& ucell,
447447
}
448448
}
449449
}
450-
ModuleBase::timer::end("Plus_U_Base", "mix_locale");
450+
ModuleBase::timer::end("Plus_U_Base", "mix_occ_mat");
451451
}
452452

453453

454-
void Plus_U_Base::set_locale(const UnitCell& ucell)
454+
void Plus_U_Base::set_occ_mat(const UnitCell& ucell)
455455
{
456-
ModuleBase::TITLE("Plus_U_Base", "set_locale");
457-
ModuleBase::timer::start("Plus_U_Base", "set_locale");
456+
ModuleBase::TITLE("Plus_U_Base", "set_occ_mat");
457+
ModuleBase::timer::start("Plus_U_Base", "set_occ_mat");
458458

459459
for (int T = 0; T < ucell.ntype; T++)
460460
{
@@ -483,7 +483,7 @@ void Plus_U_Base::set_locale(const UnitCell& ucell)
483483
}
484484
}
485485

486-
ModuleBase::timer::end("Plus_U_Base", "set_locale");
486+
ModuleBase::timer::end("Plus_U_Base", "set_occ_mat");
487487
}
488488

489489

source/source_pw/module_pwdft/dftu_base.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ class Plus_U_Base
145145
static void enable_mixing() { mixing_dftu = 1; }
146146

147147
protected:
148-
void copy_locale(const UnitCell& ucell);
149-
void zero_locale(const UnitCell& ucell);
150-
void mix_locale(const UnitCell& ucell, const double& mixing_beta);
151-
void set_locale(const UnitCell& ucell);
148+
void copy_occ_mat(const UnitCell& ucell);
149+
void zero_occ_mat(const UnitCell& ucell);
150+
void mix_occ_mat(const UnitCell& ucell, const double& mixing_beta);
151+
void set_occ_mat(const UnitCell& ucell);
152152

153153
std::vector<std::complex<double>> eff_pot_pw;
154154
std::vector<int> eff_pot_pw_index;

source/source_pw/module_pwdft/dftu_pw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ void Plus_U_Base::cal_occ_pw(const int iter,
2626
const int* isk)
2727
{
2828
ModuleBase::timer::start("Plus_U_Base", "cal_occ_pw");
29-
this->copy_locale(cell);
30-
this->zero_locale(cell);
29+
this->copy_occ_mat(cell);
30+
this->zero_occ_mat(cell);
3131

3232
if(this->device == "cpu")
3333
{
@@ -243,7 +243,7 @@ void Plus_U_Base::cal_occ_pw(const int iter,
243243
if(is_mixing_enabled() && p_chgmix != nullptr)
244244
{
245245
p_chgmix->mix_uom(this->uom_array, this->uom_save);
246-
this->set_locale(cell);
246+
this->set_occ_mat(cell);
247247
}
248248

249249
Plus_U_Base::energy_u = 0.0;

0 commit comments

Comments
 (0)