Skip to content

Commit 67fda40

Browse files
committed
add get_cur_effective_basis func
1 parent a3817e4 commit 67fda40

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

source/module_elecstate/elecstate_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
154154

155155
this->init_rho_data();
156156
int ik = psi.get_current_k();
157-
int npw = psi.get_current_nbas();
157+
int npw = psi.get_cur_effective_basis();
158158
int current_spin = 0;
159159
if (PARAM.inp.nspin == 2)
160160
{
@@ -258,7 +258,7 @@ void ElecStatePW<T, Device>::cal_becsum(const psi::Psi<T, Device>& psi)
258258
psi.fix_k(ik);
259259
const T* psi_now = psi.get_pointer();
260260
const int currect_spin = this->klist->isk[ik];
261-
const int npw = psi.get_current_nbas();
261+
const int npw = psi.get_cur_effective_basis();
262262

263263
// get |beta>
264264
if (this->ppcell->nkb > 0)

source/module_elecstate/elecstate_pw_cal_tau.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void ElecStatePW<T, Device>::cal_tau(const psi::Psi<T, Device>& psi)
1515
for (int ik = 0; ik < psi.get_nk(); ++ik)
1616
{
1717
psi.fix_k(ik);
18-
int npw = psi.get_current_nbas();
18+
int npw = psi.get_cur_effective_basis();
1919
int current_spin = 0;
2020
if (PARAM.inp.nspin == 2)
2121
{

source/module_hamilt_pw/hamilt_stodft/sto_iter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void Stochastic_Iter<T, Device>::orthog(const int& ik, psi::Psi<T, Device>& psi,
6060
if (PARAM.inp.nbands > 0)
6161
{
6262
const int nchipk = stowf.nchip[ik];
63-
const int npw = psi.get_current_nbas();
63+
const int npw = psi.get_cur_effective_basis();
6464
const int npwx = psi.get_nbasis();
6565
stowf.chi0->fix_k(ik);
6666
stowf.chiortho->fix_k(ik);

source/module_psi/psi.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,26 @@ const int& Psi<T, Device>::get_psi_bias() const
295295
return this->psi_bias;
296296
}
297297

298+
template <typename T, typename Device>
299+
const int& Psi<T, Device>::get_cur_effective_basis() const
300+
{
301+
if (this->npol == 1)
302+
{
303+
if (this->ngk != nullptr)
304+
{
305+
return this->ngk[this->current_k];
306+
}
307+
else
308+
{
309+
return this->current_nbasis;
310+
}
311+
}
312+
else
313+
{
314+
return this->nbasis;
315+
}
316+
}
317+
298318
template <typename T, typename Device>
299319
const int& Psi<T, Device>::get_nk() const
300320
{

source/module_psi/psi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class Psi
127127
// return psi_bias
128128
const int& get_psi_bias() const;
129129

130+
const int& get_cur_effective_basis() const;
131+
130132
// mark
131133
void zero_out();
132134

0 commit comments

Comments
 (0)