Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions source/source_hamilt/module_gint/gint_common.cpp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fix! However, we should have a test! Either unittest or integrate test is OK.

Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,18 @@ void merge_hr_part_to_hR(const std::vector<hamilt::HContainer<double>>& hr_gint_
+ std::complex<double>(clx_i[is], clx_j[is]) * mat_nspin2->get_value(irow, icol);
}
}
//fill the lower triangle matrix at -R by conjugate transpose of upper at R
// This ensures H(-R) = H(R)^dagger, required for Hermiticity of H(k).
// For real matrices (is=0,3), conj has no effect.
// For complex matrices (is=1,2), conj is essential.
// Transpose only the spatial indices within this fixed spin block.
// The real Pauli-channel matrices obey V_mu(-R) = V_mu(R)^T.
// Full spinor Hermiticity also exchanges the spin indices; the
// conjugate coefficients are already in the opposite spin block.
if (iat1 < iat2)
{
auto lower_mat = lower_ap->find_matrix(-R_index);
for (int irow = 0; irow < upper_mat->get_row_size(); ++irow)
{
for (int icol = 0; icol < upper_mat->get_col_size(); ++icol)
{
lower_mat->get_value(icol, irow) = std::conj(upper_mat->get_value(irow, icol));
lower_mat->get_value(icol, irow) = upper_mat->get_value(irow, icol);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/03_NAO_multik/CASES_CPU.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ get_pchg_k
get_s
scf_deltaspin2
scf_deltaspin4
scf_nspin4_nsoc_hr
scf_nspin4_soc_hr
Binary file added tests/03_NAO_multik/pr8183_o2_hr_tests.zip
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_nsoc_hr/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
INPUT_PARAMETERS
suffix autotest
calculation scf
symmetry 0
pseudo_dir ../../PP_ORB
orbital_dir ../../PP_ORB
gamma_only 0
ecutwfc 20
scf_thr 1e-6
scf_nmax 50
noncolin 1
nspin 4
lspinorb 0
basis_type lcao
ks_solver scalapack_gvx
dft_functional pbe
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_beta 0.4
mixing_gg0 3.0
out_hsr 1 12
4 changes: 4 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_nsoc_hr/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
Gamma
1 1 1 0 0 0
8 changes: 8 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_nsoc_hr/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Self-consistent nspin=4 O2 H(R)/S(R) regression, without SOC.
Two O atoms separated by 2.3 bohr along z in a 20-bohr cubic cell.
Existing fully relativistic O PP and minimal 6-bohr 1s1p orbitals; PBE, 20 Ry, Gamma 1x1x1.
Both initial moments are (1/sqrt(2),1/sqrt(2),0) muB; no DeltaSpin constraint.
Full SCF reaches 1e-6 within 50 steps and retains a finite y magnetization.
Complete raw complex references cover the nspin=4 interatomic H(R) export fix.
The pre-fix build converges but fails the H comparison against the fixed-build reference.
Only R=0 is present. This tests the export convention, not material convergence or intercell Bloch phases.
22 changes: 22 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_nsoc_hr/STRU
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ATOMIC_SPECIES
O 15.999 O_ONCV_PBE_FR-1.0.upf

NUMERICAL_ORBITAL
O_gga_6au_60Ry_1s1p.orb

LATTICE_CONSTANT
20.0

LATTICE_VECTORS
1 0 0
0 1 0
0 0 1

ATOMIC_POSITIONS
Direct

O
0.0
2
0.5 0.5 0.4425 0 0 0 mag 0.7071067811865475 0.7071067811865475 0
0.5 0.5 0.5575 0 0 0 mag 0.7071067811865475 0.7071067811865475 0
75 changes: 75 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_nsoc_hr/hrs1_nao.csr.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
--- Ionic Step 1 ---
# print H matrix in real space H(R)
1 # number of spin directions
1 # spin index, E_Fermi = -6.59889 eV
16 # number of localized basis
1 # number of Bravais lattice vector R

user_defined_lattice
10.5835
1 0 0
0 1 0
0 0 1
O
2
Direct
0.5 0.5 0.4424999999992
0.5 0.5 0.5575000000008

#----------------------------------------------------------------------#
# CSR Format #
# The outer loop corresponds to the number of Bravais lattice vectors. #
# The first line contains the index of the Bravais lattice vector #
# (Rx, Ry, Rz), followed by the number of non-zero elements. #
# The subsequent lines consist of three blocks of data, which are #
# values, column indices, row pointers. #
#----------------------------------------------------------------------#

0 0 0 176
# CSR values
(-2.007633384794e+00,0.000000000000e+00) (-4.362949235670e-02,4.362947017816e-02) (-4.159497162204e-01,0.000000000000e+00) (1.259652625142e-03,-1.259682213725e-03) (-1.103721312843e-09,0.000000000000e+00) (-1.109394672457e-09,-1.109362693949e-09)
(-1.005948197227e+00,0.000000000000e+00) (-8.822139488821e-03,8.822117336488e-03) (1.094900063890e+00,0.000000000000e+00) (9.771130281636e-03,-9.771100798884e-03) (-1.103717922653e-09,0.000000000000e+00) (-1.109395077935e-09,-1.109362059317e-09)
(-4.362949235670e-02,-4.362947017816e-02) (-2.007633404793e+00,0.000000000000e+00) (1.259652625142e-03,1.259682213725e-03) (-4.159497439845e-01,0.000000000000e+00) (-1.109394672457e-09,1.109362693949e-09) (1.103714868562e-09,0.000000000000e+00)
(-8.822139488821e-03,-8.822117336488e-03) (-1.005948217119e+00,0.000000000000e+00) (9.771130281636e-03,9.771100798884e-03) (1.094900091226e+00,0.000000000000e+00) (-1.109395077935e-09,1.109362059317e-09) (1.103717050219e-09,0.000000000000e+00)
(-4.159497162204e-01,0.000000000000e+00) (1.259652625142e-03,-1.259682213725e-03) (-1.157369969289e+00,0.000000000000e+00) (-1.805578229644e-02,1.805574267800e-02) (-1.417147887359e-09,0.000000000000e+00) (-1.428456578452e-09,-1.428414588965e-09)
(-1.094900063871e+00,0.000000000000e+00) (-9.771130286489e-03,9.771100793936e-03) (8.106170895977e-01,0.000000000000e+00) (1.679599918853e-03,-1.679560416061e-03) (-1.417148743788e-09,0.000000000000e+00) (-1.428456283077e-09,-1.428414962515e-09)
(1.259652625142e-03,1.259682213725e-03) (-4.159497439845e-01,0.000000000000e+00) (-1.805578229644e-02,-1.805574267800e-02) (-1.157370007515e+00,0.000000000000e+00) (-1.428456578452e-09,1.428414588965e-09) (1.417147509629e-09,0.000000000000e+00)
(-9.771130286489e-03,-9.771100793936e-03) (-1.094900091246e+00,0.000000000000e+00) (1.679599918853e-03,1.679560416061e-03) (8.106171273558e-01,0.000000000000e+00) (-1.428456283077e-09,1.428414962515e-09) (1.417146927015e-09,0.000000000000e+00)
(-1.103721771670e-09,0.000000000000e+00) (-1.109394671601e-09,-1.109362694177e-09) (-1.417148053652e-09,0.000000000000e+00) (-1.428456579193e-09,-1.428414590375e-09) (-7.929900020956e-01,0.000000000000e+00) (-5.659068868439e-02,5.659067608671e-02)
(-5.563390342022e-10,0.000000000000e+00) (-1.103717975597e-09,0.000000000000e+00) (-1.109395052813e-09,-1.109362081886e-09) (1.417148528001e-09,0.000000000000e+00) (1.428456236039e-09,1.428415005041e-09) (-4.152966155347e-01,0.000000000000e+00)
(-5.960410685548e-03,5.960398075592e-03) (-5.563390026505e-10,0.000000000000e+00) (-1.109394671601e-09,1.109362694177e-09) (1.103714409736e-09,0.000000000000e+00) (-1.428456579193e-09,1.428414590375e-09) (1.417147343336e-09,0.000000000000e+00)
(-5.659068868439e-02,-5.659067608671e-02) (-7.929900036338e-01,0.000000000000e+00) (5.563393474512e-10,0.000000000000e+00) (-1.109395052813e-09,1.109362081886e-09) (1.103717071435e-09,0.000000000000e+00) (1.428456236039e-09,-1.428415005041e-09)
(-1.417147426619e-09,0.000000000000e+00) (-5.960410685548e-03,-5.960398075592e-03) (-4.152966171227e-01,0.000000000000e+00) (5.563390573209e-10,0.000000000000e+00) (-5.563390325043e-10,0.000000000000e+00) (-7.929899958025e-01,0.000000000000e+00)
(-5.659068715897e-02,5.659067761213e-02) (-5.563390037131e-10,0.000000000000e+00) (-4.152966092416e-01,0.000000000000e+00) (-5.960409160130e-03,5.960399601017e-03) (5.563393491491e-10,0.000000000000e+00) (-5.659068715897e-02,-5.659067761213e-02)
(-7.929900099269e-01,0.000000000000e+00) (5.563390562583e-10,0.000000000000e+00) (-5.960409160130e-03,-5.960399601017e-03) (-4.152966234158e-01,0.000000000000e+00) (-1.005948197227e+00,0.000000000000e+00) (-8.822139488821e-03,8.822117336488e-03)
(-1.094900063871e+00,0.000000000000e+00) (-9.771130286489e-03,9.771100793936e-03) (-1.103717975597e-09,0.000000000000e+00) (-1.109395052813e-09,-1.109362081886e-09) (-2.007633384900e+00,0.000000000000e+00) (-4.362949233026e-02,4.362947020412e-02)
(4.159497166290e-01,0.000000000000e+00) (-1.259652726087e-03,1.259682112809e-03) (-1.103719043688e-09,0.000000000000e+00) (-1.109394720880e-09,-1.109362663299e-09) (-8.822139488821e-03,-8.822117336488e-03) (-1.005948217119e+00,0.000000000000e+00)
(-9.771130286489e-03,-9.771100793936e-03) (-1.094900091246e+00,0.000000000000e+00) (-1.109395052813e-09,1.109362081886e-09) (1.103717071435e-09,0.000000000000e+00) (-4.362949233026e-02,-4.362947020412e-02) (-2.007633404686e+00,0.000000000000e+00)
(-1.259652726087e-03,-1.259682112809e-03) (4.159497435759e-01,0.000000000000e+00) (-1.109394720880e-09,1.109362663299e-09) (1.103715812279e-09,0.000000000000e+00) (1.094900063890e+00,0.000000000000e+00) (9.771130281636e-03,-9.771100798884e-03)
(8.106170895977e-01,0.000000000000e+00) (1.679599918853e-03,-1.679560416061e-03) (1.417148528001e-09,0.000000000000e+00) (1.428456236039e-09,1.428415005041e-09) (4.159497166290e-01,0.000000000000e+00) (-1.259652726087e-03,1.259682112809e-03)
(-1.157369969757e+00,0.000000000000e+00) (-1.805578218067e-02,1.805574279352e-02) (1.417147670354e-09,0.000000000000e+00) (1.428457107906e-09,1.428413982774e-09) (9.771130281636e-03,9.771100798884e-03) (1.094900091226e+00,0.000000000000e+00)
(1.679599918853e-03,1.679560416061e-03) (8.106171273558e-01,0.000000000000e+00) (1.428456236039e-09,-1.428415005041e-09) (-1.417147426619e-09,0.000000000000e+00) (-1.259652726087e-03,-1.259682112809e-03) (4.159497435759e-01,0.000000000000e+00)
(-1.805578218067e-02,-1.805574279352e-02) (-1.157370007047e+00,0.000000000000e+00) (1.428457107906e-09,-1.428413982774e-09) (-1.417147726848e-09,0.000000000000e+00) (-1.103717922653e-09,0.000000000000e+00) (-1.109395077935e-09,-1.109362059317e-09)
(-1.417148743788e-09,0.000000000000e+00) (-1.428456283077e-09,-1.428414962515e-09) (-4.152966155347e-01,0.000000000000e+00) (-5.960410685548e-03,5.960398075592e-03) (-5.563390037131e-10,0.000000000000e+00) (-1.103718927573e-09,0.000000000000e+00)
(-1.109394720796e-09,-1.109362654618e-09) (1.417147693483e-09,0.000000000000e+00) (1.428457108364e-09,1.428413982235e-09) (-7.929900020457e-01,0.000000000000e+00) (-5.659068869637e-02,5.659067607414e-02) (-5.563389220589e-10,0.000000000000e+00)
(-1.109395077935e-09,1.109362059317e-09) (1.103717050219e-09,0.000000000000e+00) (-1.428456283077e-09,1.428414962515e-09) (1.417146927015e-09,0.000000000000e+00) (-5.960410685548e-03,-5.960398075592e-03) (-4.152966171227e-01,0.000000000000e+00)
(5.563390562583e-10,0.000000000000e+00) (-1.109394720796e-09,1.109362654618e-09) (1.103715928394e-09,0.000000000000e+00) (1.428457108364e-09,-1.428413982235e-09) (-1.417147703719e-09,0.000000000000e+00) (-5.659068869637e-02,-5.659067607414e-02)
(-7.929900036834e-01,0.000000000000e+00) (5.563391892780e-10,0.000000000000e+00) (-5.563390026505e-10,0.000000000000e+00) (-4.152966092416e-01,0.000000000000e+00) (-5.960409160130e-03,5.960399601017e-03) (-5.563389220892e-10,0.000000000000e+00)
(-7.929899957526e-01,0.000000000000e+00) (-5.659068717096e-02,5.659067759957e-02) (5.563390573209e-10,0.000000000000e+00) (-5.960409160130e-03,-5.960399601017e-03) (-4.152966234158e-01,0.000000000000e+00) (5.563391892477e-10,0.000000000000e+00)
(-5.659068717096e-02,-5.659067759957e-02) (-7.929900099765e-01,0.000000000000e+00)
# CSR column indices
0 1 2 3 4 5 8 9 10 11 12 13 0 1 2 3
4 5 8 9 10 11 12 13 0 1 2 3 4 5 8 9
10 11 12 13 0 1 2 3 4 5 8 9 10 11 12 13
0 1 2 3 4 5 6 8 9 10 11 12 13 14 0 1
2 3 4 5 7 8 9 10 11 12 13 15 4 6 7 12
14 15 5 6 7 13 14 15 0 1 2 3 4 5 8 9
10 11 12 13 0 1 2 3 4 5 8 9 10 11 12 13
0 1 2 3 4 5 8 9 10 11 12 13 0 1 2 3
4 5 8 9 10 11 12 13 0 1 2 3 4 5 6 8
9 10 11 12 13 14 0 1 2 3 4 5 7 8 9 10
11 12 13 15 4 6 7 12 14 15 5 6 7 13 14 15
# CSR row pointers
0 12 24 36 48 62 76 82 88 100 112 124 136 150 164 170
176

5 changes: 5 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_nsoc_hr/result.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
etotref -861.0910298473461
etotperatomref -430.5455149237
CompareHR_pass 0
CompareSR_pass 0
totaltimeref 2.77
44 changes: 44 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_nsoc_hr/sr_nao.csr.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--- Ionic Step 1 ---
# print S matrix in real space S(R)
1 # number of spin directions
1 # spin index
16 # number of localized basis
1 # number of Bravais lattice vector R

user_defined_lattice
10.5835
1 0 0
0 1 0
0 0 1
O
2
Direct
0.5 0.5 0.4424999999992
0.5 0.5 0.5575000000008

#----------------------------------------------------------------------#
# CSR Format #
# The outer loop corresponds to the number of Bravais lattice vectors. #
# The first line contains the index of the Bravais lattice vector #
# (Rx, Ry, Rz), followed by the number of non-zero elements. #
# The subsequent lines consist of three blocks of data, which are #
# values, column indices, row pointers. #
#----------------------------------------------------------------------#

0 0 0 40
# CSR values
(1.000000000000e+00,0.000000000000e+00) (3.122772551440e-01,0.000000000000e+00) (-3.769119232454e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (3.122772551440e-01,0.000000000000e+00) (-3.769119232454e-01,0.000000000000e+00)
(1.000000000000e+00,0.000000000000e+00) (3.769119232454e-01,0.000000000000e+00) (-2.556149750289e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (3.769119232454e-01,0.000000000000e+00) (-2.556149750289e-01,0.000000000000e+00)
(1.000000000000e+00,0.000000000000e+00) (2.212660810968e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (2.212660810968e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (2.212660810968e-01,0.000000000000e+00)
(1.000000000000e+00,0.000000000000e+00) (2.212660810968e-01,0.000000000000e+00) (3.122772551440e-01,0.000000000000e+00) (3.769119232454e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (3.122772551440e-01,0.000000000000e+00)
(3.769119232454e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (-3.769119232454e-01,0.000000000000e+00) (-2.556149750289e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (-3.769119232454e-01,0.000000000000e+00)
(-2.556149750289e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (2.212660810968e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (2.212660810968e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00)
(2.212660810968e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00) (2.212660810968e-01,0.000000000000e+00) (1.000000000000e+00,0.000000000000e+00)
# CSR column indices
0 8 10 1 9 11 2 8 10 3 9 11 4 12 5 13
6 14 7 15 0 2 8 1 3 9 0 2 10 1 3 11
4 12 5 13 6 14 7 15
# CSR row pointers
0 3 6 9 12 14 16 18 20 23 26 29 32 34 36 38
40

22 changes: 22 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_soc_hr/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
INPUT_PARAMETERS
suffix autotest
calculation scf
symmetry 0
pseudo_dir ../../PP_ORB
orbital_dir ../../PP_ORB
gamma_only 0
ecutwfc 20
scf_thr 1e-6
scf_nmax 50
noncolin 1
nspin 4
lspinorb 1
basis_type lcao
ks_solver scalapack_gvx
dft_functional pbe
smearing_method gauss
smearing_sigma 0.02
mixing_type pulay
mixing_beta 0.4
mixing_gg0 3.0
out_hsr 1 12
4 changes: 4 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_soc_hr/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
Gamma
1 1 1 0 0 0
8 changes: 8 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_soc_hr/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Self-consistent nspin=4 O2 H(R)/S(R) regression, with SOC.
Two O atoms separated by 2.3 bohr along z in a 20-bohr cubic cell.
Existing fully relativistic O PP and minimal 6-bohr 1s1p orbitals; PBE, 20 Ry, Gamma 1x1x1.
Both initial moments are (1/sqrt(2),1/sqrt(2),0) muB; no DeltaSpin constraint.
Full SCF reaches 1e-6 within 50 steps and retains a finite y magnetization.
Complete raw complex references cover the nspin=4 interatomic H(R) export fix.
The pre-fix build converges but fails the H comparison against the fixed-build reference.
Only R=0 is present. This tests the export convention, not material convergence or intercell Bloch phases.
22 changes: 22 additions & 0 deletions tests/03_NAO_multik/scf_nspin4_soc_hr/STRU
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ATOMIC_SPECIES
O 15.999 O_ONCV_PBE_FR-1.0.upf

NUMERICAL_ORBITAL
O_gga_6au_60Ry_1s1p.orb

LATTICE_CONSTANT
20.0

LATTICE_VECTORS
1 0 0
0 1 0
0 0 1

ATOMIC_POSITIONS
Direct

O
0.0
2
0.5 0.5 0.4425 0 0 0 mag 0.7071067811865475 0.7071067811865475 0
0.5 0.5 0.5575 0 0 0 mag 0.7071067811865475 0.7071067811865475 0
Loading
Loading