Skip to content

Commit cc9848e

Browse files
Fix: Yet another wrong index in act_op_kpar for spin-polarized calculations in EXX PW (#6847)
* Final fix for nspin=2 systems? * Add tests * Add tests * Add tests * Add tests * Add tests * Add tests * Add tests * Changes * Add tests * Add tests
1 parent 1348a16 commit cc9848e

File tree

12 files changed

+130
-3
lines changed

12 files changed

+130
-3
lines changed

source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,18 @@ void OperatorEXXPW<T, Device>::act_op_kpar(const int nbands,
322322
// decide which pool does the iq belong to
323323
int iq_pool = kv->para_k.whichpool[iq];
324324
int iq_loc = iq - kv->para_k.startk_pool[iq_pool];
325+
int iq_loc_spin = iq_loc;
325326
if (ispin == 1)
326327
{
327-
iq_loc += wfcpw->nks / nspin_fac;
328+
iq_loc_spin += wfcpw->nks / nspin_fac;
328329
}
329330

330331
for (int m_iband = 0; m_iband < psi.get_nbands(); m_iband++)
331332
{
332333
double wg_mqb = 0;
333334
if (iq_pool == GlobalV::MY_POOL)
334335
{
335-
wg_mqb = (*wg)(iq_loc, m_iband);
336+
wg_mqb = (*wg)(iq_loc_spin, m_iband);
336337
}
337338
#ifdef __MPI
338339
MPI_Bcast(&wg_mqb, 1, MPI_DOUBLE, kv->para_k.get_startpro_pool(iq_pool), MPI_COMM_WORLD);
@@ -342,7 +343,7 @@ void OperatorEXXPW<T, Device>::act_op_kpar(const int nbands,
342343

343344
if (iq_pool == GlobalV::MY_POOL)
344345
{
345-
const T* psi_mq = get_pw(m_iband, iq_loc + ispin * wfcpw->nks / nspin_fac);
346+
const T* psi_mq = get_pw(m_iband, iq_loc_spin);
346347
wfcpw->recip_to_real(ctx, psi_mq, psi_mq_real, iq_loc);
347348
// send
348349
}

tests/01_PW/096_PW_PBE0_AFM/INPUT

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
INPUT_PARAMETERS
2+
#Parameters (System)
3+
suffix autotest
4+
calculation scf
5+
nspin 2
6+
pseudo_dir ../../PP_ORB
7+
orbital_dir ../../PP_ORB
8+
9+
#Parameters (PW)
10+
ecutwfc 30
11+
basis_type pw
12+
13+
#Parameters (SCF)
14+
scf_thr 1.0e-7
15+
scf_nmax 100
16+
smearing_method gaussian
17+
smearing_sigma 0.015
18+
mixing_type pulay
19+
mixing_ndim 8
20+
mixing_beta 0.2
21+
22+
#Parameters (Hybrid Functional)
23+
dft_functional pbe0
24+
25+
#Parameters (Other)
26+
symmetry -1
27+
init_wfc random
28+
pw_seed 1
29+
device cpu
30+
exx_thr_type energy
31+
exx_ene_thr 5e-2

tests/01_PW/096_PW_PBE0_AFM/KPT

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
K_POINTS
2+
0
3+
Gamma
4+
1 1 1 0 0 0
5+
### If you are running an energy calculation, please make sure your final energy is
6+
### converged with respect to the k-point settings, unless you set a loose k-point
7+
### mesh on purpose.

tests/01_PW/096_PW_PBE0_AFM/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fe Anti-ferromagnetic with nspin=2 hybrid functional (PBE0), PW basis, init magnet: up + down

tests/01_PW/096_PW_PBE0_AFM/STRU

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ATOMIC_SPECIES
2+
Fe 55.845 Fe_ONCV_PBE-1.0.upf
3+
4+
5+
LATTICE_CONSTANT
6+
1.889725989
7+
8+
LATTICE_VECTORS
9+
2.8328152400000000 0.0000000000000000 0.0000000000000000
10+
0.0000000000000000 2.8328152400000000 0.0000000000000000
11+
0.0000000000000000 0.0000000000000000 2.8328152400000000
12+
ATOMIC_POSITIONS
13+
Direct
14+
15+
Fe
16+
1.0
17+
2
18+
0.0 0.0 0.0 mag 5
19+
0.5 0.5 0.5 mag -5
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
etotref -6383.448381202996
2+
etotperatomref -3191.7241906015
3+
totaltimeref 1.06

tests/01_PW/096_PW_PBE0_FM/INPUT

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
INPUT_PARAMETERS
2+
#Parameters (System)
3+
suffix autotest
4+
calculation scf
5+
nspin 2
6+
pseudo_dir ../../PP_ORB
7+
orbital_dir ../../PP_ORB
8+
9+
#Parameters (PW)
10+
ecutwfc 30
11+
basis_type pw
12+
13+
#Parameters (SCF)
14+
scf_thr 1.0e-7
15+
scf_nmax 100
16+
smearing_method gaussian
17+
smearing_sigma 0.015
18+
mixing_type pulay
19+
mixing_ndim 8
20+
mixing_beta 0.2
21+
22+
#Parameters (Hybrid Functional)
23+
dft_functional pbe0
24+
25+
#Parameters (Other)
26+
symmetry -1
27+
init_wfc random
28+
pw_seed 1
29+
device cpu
30+
exx_thr_type energy
31+
exx_ene_thr 5e-2

tests/01_PW/096_PW_PBE0_FM/KPT

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
K_POINTS
2+
0
3+
Gamma
4+
1 1 1 0 0 0
5+
### If you are running an energy calculation, please make sure your final energy is
6+
### converged with respect to the k-point settings, unless you set a loose k-point
7+
### mesh on purpose.

tests/01_PW/096_PW_PBE0_FM/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fe Ferromagnetic with nspin=2 hybrid functional (PBE0), PW basis, init magnet: up + up
2+
3+

tests/01_PW/096_PW_PBE0_FM/STRU

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ATOMIC_SPECIES
2+
Fe 55.845 Fe_ONCV_PBE-1.0.upf
3+
4+
5+
LATTICE_CONSTANT
6+
1.889725989
7+
8+
LATTICE_VECTORS
9+
2.8328152400000000 0.0000000000000000 0.0000000000000000
10+
0.0000000000000000 2.8328152400000000 0.0000000000000000
11+
0.0000000000000000 0.0000000000000000 2.8328152400000000
12+
ATOMIC_POSITIONS
13+
Direct
14+
15+
Fe
16+
1.0
17+
2
18+
0.0 0.0 0.0 mag 5
19+
0.5 0.5 0.5 mag 5

0 commit comments

Comments
 (0)