Skip to content

Commit da53d20

Browse files
committed
rename _nks as _nk to avoid ambiguity
1 parent d716da8 commit da53d20

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

source/module_elecstate/module_dm/density_matrix.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ DensityMatrix<TK, TR>::~DensityMatrix()
2626

2727
template <typename TK, typename TR>
2828
DensityMatrix<TK, TR>::DensityMatrix(const Parallel_Orbitals* paraV_in, const int nspin, const std::vector<ModuleBase::Vector3<double>>& kvec_d, const int nk)
29-
: _paraV(paraV_in), _nspin(nspin), _kvec_d(kvec_d), _nks((nk > 0 && nk <= _kvec_d.size()) ? nk : _kvec_d.size())
29+
: _paraV(paraV_in), _nspin(nspin), _kvec_d(kvec_d), _nk((nk > 0 && nk <= _kvec_d.size()) ? nk : _kvec_d.size())
3030
{
3131
ModuleBase::TITLE("DensityMatrix", "DensityMatrix-MK");
32-
const int nks = _nks * _nspin;
32+
const int nks = _nk * _nspin;
3333
this->_DMK.resize(nks);
3434
for (int ik = 0; ik < nks; ik++)
3535
{
@@ -39,7 +39,7 @@ DensityMatrix<TK, TR>::DensityMatrix(const Parallel_Orbitals* paraV_in, const in
3939
}
4040

4141
template <typename TK, typename TR>
42-
DensityMatrix<TK, TR>::DensityMatrix(const Parallel_Orbitals* paraV_in, const int nspin) :_paraV(paraV_in), _nspin(nspin), _kvec_d({ ModuleBase::Vector3<double>(0,0,0) }), _nks(1)
42+
DensityMatrix<TK, TR>::DensityMatrix(const Parallel_Orbitals* paraV_in, const int nspin) :_paraV(paraV_in), _nspin(nspin), _kvec_d({ ModuleBase::Vector3<double>(0,0,0) }), _nk(1)
4343
{
4444
ModuleBase::TITLE("DensityMatrix", "DensityMatrix-GO");
4545
this->_DMK.resize(_nspin);
@@ -236,7 +236,7 @@ template <typename TK, typename TR>
236236
TK* DensityMatrix<TK, TR>::get_DMK_pointer(const int ik) const
237237
{
238238
#ifdef __DEBUG
239-
assert(ik < this->_nks * this->_nspin);
239+
assert(ik < this->_nk * this->_nspin);
240240
#endif
241241
return const_cast<TK*>(this->_DMK[ik].data());
242242
}
@@ -246,7 +246,7 @@ template <typename TK, typename TR>
246246
void DensityMatrix<TK, TR>::set_DMK_pointer(const int ik, TK* DMK_in)
247247
{
248248
#ifdef __DEBUG
249-
assert(ik < this->_nks * this->_nspin);
249+
assert(ik < this->_nk * this->_nspin);
250250
#endif
251251
this->_DMK[ik].assign(DMK_in, DMK_in + this->_paraV->nrow * this->_paraV->ncol);
252252
}
@@ -257,17 +257,17 @@ void DensityMatrix<TK, TR>::set_DMK(const int ispin, const int ik, const int i,
257257
{
258258
#ifdef __DEBUG
259259
assert(ispin > 0 && ispin <= this->_nspin);
260-
assert(ik >= 0 && ik < this->_nks);
260+
assert(ik >= 0 && ik < this->_nk);
261261
#endif
262262
// consider transpose col=>row
263-
this->_DMK[ik + this->_nks * (ispin - 1)][i * this->_paraV->nrow + j] = value;
263+
this->_DMK[ik + this->_nk * (ispin - 1)][i * this->_paraV->nrow + j] = value;
264264
}
265265

266266
// set _DMK element
267267
template <typename TK, typename TR>
268268
void DensityMatrix<TK, TR>::set_DMK_zero()
269269
{
270-
for (int ik = 0; ik < _nspin * _nks; ik++)
270+
for (int ik = 0; ik < _nspin * _nk; ik++)
271271
{
272272
ModuleBase::GlobalFunc::ZEROS(this->_DMK[ik].data(),
273273
this->_paraV->get_row_size() * this->_paraV->get_col_size());
@@ -282,17 +282,17 @@ TK DensityMatrix<TK, TR>::get_DMK(const int ispin, const int ik, const int i, co
282282
assert(ispin > 0 && ispin <= this->_nspin);
283283
#endif
284284
// consider transpose col=>row
285-
return this->_DMK[ik + this->_nks * (ispin - 1)][i * this->_paraV->nrow + j];
285+
return this->_DMK[ik + this->_nk * (ispin - 1)][i * this->_paraV->nrow + j];
286286
}
287287

288288
// get _DMK nks, nrow, ncol
289289
template <typename TK, typename TR>
290290
int DensityMatrix<TK, TR>::get_DMK_nks() const
291291
{
292292
#ifdef __DEBUG
293-
assert(this->_DMK.size() == _nks * _nspin);
293+
assert(this->_DMK.size() == _nk * _nspin);
294294
#endif
295-
return _nks * _nspin;
295+
return _nk * _nspin;
296296
}
297297

298298
template <typename TK, typename TR>
@@ -364,7 +364,7 @@ void DensityMatrix<TK, TR>::cal_DMR_test()
364364
{
365365
for (int is = 1; is <= this->_nspin; ++is)
366366
{
367-
int ik_begin = this->_nks * (is - 1); // jump this->_nks for spin_down if nspin==2
367+
int ik_begin = this->_nk * (is - 1); // jump this->_nk for spin_down if nspin==2
368368
hamilt::HContainer<TR>* tmp_DMR = this->_DMR[is - 1];
369369
// set zero since this function is called in every scf step
370370
tmp_DMR->set_zero();
@@ -396,7 +396,7 @@ void DensityMatrix<TK, TR>::cal_DMR_test()
396396
#endif
397397
std::complex<TR> tmp_res;
398398
// loop over k-points
399-
for (int ik = 0; ik < this->_nks; ++ik)
399+
for (int ik = 0; ik < this->_nk; ++ik)
400400
{
401401
// cal k_phase
402402
// if TK==std::complex<double>, kphase is e^{ikR}
@@ -438,7 +438,7 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR()
438438
int ld_hk2 = 2 * ld_hk;
439439
for (int is = 1; is <= this->_nspin; ++is)
440440
{
441-
int ik_begin = this->_nks * (is - 1); // jump this->_nks for spin_down if nspin==2
441+
int ik_begin = this->_nk * (is - 1); // jump this->_nk for spin_down if nspin==2
442442
hamilt::HContainer<double>* tmp_DMR = this->_DMR[is - 1];
443443
// set zero since this function is called in every scf step
444444
tmp_DMR->set_zero();
@@ -471,7 +471,7 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR()
471471
// loop over k-points
472472
if (PARAM.inp.nspin != 4)
473473
{
474-
for (int ik = 0; ik < this->_nks; ++ik)
474+
for (int ik = 0; ik < this->_nk; ++ik)
475475
{
476476
// cal k_phase
477477
// if TK==std::complex<double>, kphase is e^{ikR}
@@ -517,7 +517,7 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR()
517517
std::vector<std::complex<double>> tmp_DMR(this->_paraV->get_col_size()
518518
* this->_paraV->get_row_size(),
519519
std::complex<double>(0.0, 0.0));
520-
for (int ik = 0; ik < this->_nks; ++ik)
520+
for (int ik = 0; ik < this->_nk; ++ik)
521521
{
522522
// cal k_phase
523523
// if TK==std::complex<double>, kphase is e^{ikR}
@@ -603,7 +603,7 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR(const int ik)
603603
int ld_hk2 = 2 * ld_hk;
604604
for (int is = 1; is <= this->_nspin; ++is)
605605
{
606-
int ik_begin = this->_nks * (is - 1); // jump this->_nks for spin_down if nspin==2
606+
int ik_begin = this->_nk * (is - 1); // jump this->_nk for spin_down if nspin==2
607607
hamilt::HContainer<double>* tmp_DMR = this->_DMR[is - 1];
608608
// set zero since this function is called in every scf step
609609
tmp_DMR->set_zero();
@@ -693,14 +693,14 @@ void DensityMatrix<double, double>::cal_DMR()
693693
int ld_hk = this->_paraV->nrow;
694694
for (int is = 1; is <= this->_nspin; ++is)
695695
{
696-
int ik_begin = this->_nks * (is - 1); // jump this->_nks for spin_down if nspin==2
696+
int ik_begin = this->_nk * (is - 1); // jump this->_nk for spin_down if nspin==2
697697
hamilt::HContainer<double>* tmp_DMR = this->_DMR[is - 1];
698698
// set zero since this function is called in every scf step
699699
tmp_DMR->set_zero();
700700

701701
#ifdef __DEBUG
702702
// assert(tmp_DMR->is_gamma_only() == true);
703-
assert(this->_nks == 1);
703+
assert(this->_nk == 1);
704704
#endif
705705
#ifdef _OPENMP
706706
#pragma omp parallel for
@@ -828,7 +828,7 @@ void DensityMatrix<TK, TR>::read_DMK(const std::string directory, const int ispi
828828
{
829829
for (int j = 0; j < this->_paraV->ncol; ++j)
830830
{
831-
ifs >> this->_DMK[ik + this->_nks * (ispin - 1)][i * this->_paraV->ncol + j];
831+
ifs >> this->_DMK[ik + this->_nk * (ispin - 1)][i * this->_paraV->ncol + j];
832832
}
833833
}
834834
ifs.close();
@@ -865,7 +865,7 @@ void DensityMatrix<double, double>::write_DMK(const std::string directory, const
865865
{
866866
ofs << "\n";
867867
}
868-
ofs << " " << this->_DMK[ik + this->_nks * (ispin - 1)][i * this->_paraV->ncol + j];
868+
ofs << " " << this->_DMK[ik + this->_nk * (ispin - 1)][i * this->_paraV->ncol + j];
869869
}
870870
}
871871

@@ -902,7 +902,7 @@ void DensityMatrix<std::complex<double>, double>::write_DMK(const std::string di
902902
{
903903
ofs << "\n";
904904
}
905-
ofs << " " << this->_DMK[ik + this->_nks * (ispin - 1)][i * this->_paraV->ncol + j].real();
905+
ofs << " " << this->_DMK[ik + this->_nk * (ispin - 1)][i * this->_paraV->ncol + j].real();
906906
}
907907
}
908908

source/module_elecstate/module_dm/density_matrix.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ class DensityMatrix
243243

244244
/**
245245
* @brief density matrix in k space, which is a vector[ik]
246-
* DMK should be a [_nspin][_nks][i][j] matrix,
247-
* whose size is _nspin * _nks * _paraV->get_nrow() * _paraV->get_ncol()
246+
* DMK should be a [_nspin][_nk][i][j] matrix,
247+
* whose size is _nspin * _nk * _paraV->get_nrow() * _paraV->get_ncol()
248248
*/
249249
// std::vector<ModuleBase::ComplexMatrix> _DMK;
250250
std::vector<std::vector<TK>> _DMK;
@@ -268,10 +268,10 @@ class DensityMatrix
268268

269269
/**
270270
* @brief real number of k-points
271-
* _nks is not equal to _kv->get_nks() when spin-polarization is considered
272-
* _nks = kv->_nks / nspin
271+
* _nk is not equal to _kv->get_nks() when spin-polarization is considered
272+
* _nk = kv->get_nks() / nspin when nspin=2
273273
*/
274-
int _nks = 0; // comment by lunasea: I want to rename it as nk
274+
int _nk = 0;
275275

276276

277277
};

source/module_io/td_current_io.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void ModuleIO::cal_tmp_DM(elecstate::DensityMatrix<std::complex<double>, double>
2828
int ld_hk = DM_real.get_paraV_pointer()->nrow;
2929
int ld_hk2 = 2 * ld_hk;
3030
// tmp for is
31-
int ik_begin = DM_real.get_DMK_nks() / nspin * (is - 1); // jump this->_nks for spin_down if nspin==2
31+
int ik_begin = DM_real.get_DMK_nks() / nspin * (is - 1); // jump nk for spin_down if nspin==2
3232

3333
hamilt::HContainer<double>* tmp_DMR_real = DM_real.get_DMR_vector()[is - 1];
3434
hamilt::HContainer<double>* tmp_DMR_imag = DM_imag.get_DMR_vector()[is - 1];

source/module_lr/dm_trans/dmr_complex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace elecstate
1111
ModuleBase::timer::tick("DensityMatrix", "cal_DMR");
1212
for (int is = 1; is <= this->_nspin; ++is)
1313
{
14-
int ik_begin = this->_nks * (is - 1); // jump this->_nks for spin_down if nspin==2
14+
int ik_begin = this->_nk * (is - 1); // jump this->_nk for spin_down if nspin==2
1515
hamilt::HContainer<std::complex<double>>* tmp_DMR = this->_DMR[is - 1];
1616
// set zero since this function is called in every scf step
1717
tmp_DMR->set_zero();
@@ -43,7 +43,7 @@ namespace elecstate
4343
#endif
4444
// loop over k-points
4545
if (PARAM.inp.nspin != 4)
46-
for (int ik = 0; ik < this->_nks; ++ik)
46+
for (int ik = 0; ik < this->_nk; ++ik)
4747
{
4848
// cal k_phase
4949
// if TK==std::complex<double>, kphase is e^{ikR}

0 commit comments

Comments
 (0)