diff --git a/source/module_lr/utils/lr_util_hcontainer.cpp b/source/module_lr/utils/lr_util_hcontainer.cpp index e2ac23be30..d04952e615 100644 --- a/source/module_lr/utils/lr_util_hcontainer.cpp +++ b/source/module_lr/utils/lr_util_hcontainer.cpp @@ -14,18 +14,21 @@ namespace LR_Util auto dr_real = DMR_real.get_DMR_vector()[is]; assert(dr != nullptr); assert(dr_real != nullptr); - for (int ia = 0;ia < nat;ia++) + for (int ia = 0;ia < nat;ia++) { for (int ja = 0;ja < nat;ja++) { auto ap = dr->find_pair(ia, ja); auto ap_real = dr_real->find_pair(ia, ja); for (int iR = 0;iR < ap->get_R_size();++iR) { + // R index may be different between the two HContainers, find by R value instead of R-index + auto dR = ap->get_R_index(iR); auto ptr = ap->get_HR_values(iR).get_pointer(); - auto ptr_real = ap_real->get_HR_values(iR).get_pointer(); - for (int i = 0;i < ap->get_size();++i) ptr_real[i] = (get_imag ? ptr[i].imag() : ptr[i].real()); + auto ptr_real = ap_real->get_HR_values(dR.x, dR.y, dR.z).get_pointer(); + for (int i = 0;i < ap->get_size();++i) { ptr_real[i] = (get_imag ? ptr[i].imag() : ptr[i].real()); } } } + } } } @@ -35,17 +38,20 @@ namespace LR_Util const char& type) { bool get_imag = (type == 'I' || type == 'i'); - for (int ia = 0;ia < nat;ia++) + for (int ia = 0;ia < nat;ia++) { for (int ja = 0;ja < nat;ja++) { auto ap = HR.find_pair(ia, ja); auto ap_real = HR_real.find_pair(ia, ja); for (int iR = 0;iR < ap->get_R_size();++iR) { + // R index may be different between the two HContainers, find by R value instead of R-index + auto dR = ap->get_R_index(iR); auto ptr = ap->get_HR_values(iR).get_pointer(); - auto ptr_real = ap_real->get_HR_values(iR).get_pointer(); - for (int i = 0;i < ap->get_size();++i) get_imag ? ptr[i].imag(ptr_real[i]) : ptr[i].real(ptr_real[i]); + auto ptr_real = ap_real->get_HR_values(dR.x, dR.y, dR.z).get_pointer(); + for (int i = 0;i < ap->get_size();++i) { get_imag ? ptr[i].imag(ptr_real[i]) : ptr[i].real(ptr_real[i]); } } } + } } } \ No newline at end of file diff --git a/tests/integrate/291_NO_KP_LR/result.ref b/tests/integrate/291_NO_KP_LR/result.ref index 3c5a8347b0..20d8ed5d51 100644 --- a/tests/integrate/291_NO_KP_LR/result.ref +++ b/tests/integrate/291_NO_KP_LR/result.ref @@ -1 +1 @@ -totexcitationenergyref 0.784963 \ No newline at end of file +totexcitationenergyref 0.784471 \ No newline at end of file