Skip to content

Commit 48a3954

Browse files
mohanchenabacus_fixer
andauthored
fix a bug when init_wfc=nao in pw basis for nspin=4 (deepmodeling#7747)
Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
1 parent d2ed0cc commit 48a3954

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

source/source_hsolver/diago_iter_assist.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ void DiagoIterAssist<T, Device>::diag_subspace_init(hamilt::Hamilt<T, Device>* p
223223

224224
if (base_device::get_device_type(ctx) == base_device::GpuDevice)
225225
{
226-
psi::Psi<T, Device> psi_temp(1, 1, psi_nc, dmin, true);
226+
/// NOTE: current_nbasis must be npw (WITHOUT npol) for Nonlocal::act's
227+
/// gemm K (vkb only has npw rows). See CPU branch comment above.
228+
psi::Psi<T, Device> psi_temp(1, 1, psi_nc, evc.get_current_nbas(), true);
227229

228230
T* ppsi = psi_temp.get_pointer();
229231
// hpsi and spsi share the temp space
@@ -270,7 +272,11 @@ void DiagoIterAssist<T, Device>::diag_subspace_init(hamilt::Hamilt<T, Device>* p
270272
}
271273
else if (base_device::get_device_type(ctx) == base_device::CpuDevice)
272274
{
273-
psi::Psi<T, Device> psi_temp(1, nstart, psi_nc, dmin, true);
275+
/// NOTE: the 4th arg (current_nbasis) must be npw (WITHOUT npol),
276+
/// NOT dmin (= nbasis = npol*npwx in SOC). Nonlocal::act uses
277+
/// psi_temp.get_current_nbas() as gemm K, but vkb only has npw rows.
278+
/// dmin (still = nbasis) is kept for hcc/scc gemm K which needs npol.
279+
psi::Psi<T, Device> psi_temp(1, nstart, psi_nc, evc.get_current_nbas(), true);
274280

275281
T* ppsi = psi_temp.get_pointer();
276282
syncmem_complex_op()(ppsi, psi, psi_temp.size());
@@ -295,7 +301,6 @@ void DiagoIterAssist<T, Device>::diag_subspace_init(hamilt::Hamilt<T, Device>* p
295301
delmem_complex_op()(temp);
296302

297303
add_to_hcc(hcc, nstart);
298-
299304
}
300305

301306
if (GlobalV::NPROC_IN_POOL > 1)

source/source_psi/psi_init_nao.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ void psi_init_nao<T>::init_psig(T* psig, const int& ik)
303303
{
304304
/* FOR EACH SPIN CHANNEL */
305305
for (int is_N = 0; is_N < 2; is_N++) // rotate base
306-
// for(int is_N = 0; is_N < 1; is_N++)
307306
{
308307
if (L == 0 && is_N == 1)
309308
{

0 commit comments

Comments
 (0)