Skip to content

Commit 8d6e593

Browse files
Fix R-index mismatch in lr_util_hcontainer (#5456)
* fix the R-index mismatch in lr_util_hcontainer * change the test ref * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 2f15c55 commit 8d6e593

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

source/module_lr/utils/lr_util_hcontainer.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ namespace LR_Util
1414
auto dr_real = DMR_real.get_DMR_vector()[is];
1515
assert(dr != nullptr);
1616
assert(dr_real != nullptr);
17-
for (int ia = 0;ia < nat;ia++)
17+
for (int ia = 0;ia < nat;ia++) {
1818
for (int ja = 0;ja < nat;ja++)
1919
{
2020
auto ap = dr->find_pair(ia, ja);
2121
auto ap_real = dr_real->find_pair(ia, ja);
2222
for (int iR = 0;iR < ap->get_R_size();++iR)
2323
{
24+
// R index may be different between the two HContainers, find by R value instead of R-index
25+
auto dR = ap->get_R_index(iR);
2426
auto ptr = ap->get_HR_values(iR).get_pointer();
25-
auto ptr_real = ap_real->get_HR_values(iR).get_pointer();
26-
for (int i = 0;i < ap->get_size();++i) ptr_real[i] = (get_imag ? ptr[i].imag() : ptr[i].real());
27+
auto ptr_real = ap_real->get_HR_values(dR.x, dR.y, dR.z).get_pointer();
28+
for (int i = 0;i < ap->get_size();++i) { ptr_real[i] = (get_imag ? ptr[i].imag() : ptr[i].real()); }
2729
}
2830
}
31+
}
2932
}
3033
}
3134

@@ -35,17 +38,20 @@ namespace LR_Util
3538
const char& type)
3639
{
3740
bool get_imag = (type == 'I' || type == 'i');
38-
for (int ia = 0;ia < nat;ia++)
41+
for (int ia = 0;ia < nat;ia++) {
3942
for (int ja = 0;ja < nat;ja++)
4043
{
4144
auto ap = HR.find_pair(ia, ja);
4245
auto ap_real = HR_real.find_pair(ia, ja);
4346
for (int iR = 0;iR < ap->get_R_size();++iR)
4447
{
48+
// R index may be different between the two HContainers, find by R value instead of R-index
49+
auto dR = ap->get_R_index(iR);
4550
auto ptr = ap->get_HR_values(iR).get_pointer();
46-
auto ptr_real = ap_real->get_HR_values(iR).get_pointer();
47-
for (int i = 0;i < ap->get_size();++i) get_imag ? ptr[i].imag(ptr_real[i]) : ptr[i].real(ptr_real[i]);
51+
auto ptr_real = ap_real->get_HR_values(dR.x, dR.y, dR.z).get_pointer();
52+
for (int i = 0;i < ap->get_size();++i) { get_imag ? ptr[i].imag(ptr_real[i]) : ptr[i].real(ptr_real[i]); }
4853
}
4954
}
55+
}
5056
}
5157
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
totexcitationenergyref 0.784963
1+
totexcitationenergyref 0.784471

0 commit comments

Comments
 (0)