Skip to content

Stabilize RI RPA/EXX and Ewald EXX method merge on develop#7019

Open
AroundPeking wants to merge 17 commits intodeepmodeling:developfrom
AroundPeking:pr_merge_develop
Open

Stabilize RI RPA/EXX and Ewald EXX method merge on develop#7019
AroundPeking wants to merge 17 commits intodeepmodeling:developfrom
AroundPeking:pr_merge_develop

Conversation

@AroundPeking
Copy link

Summary

This PR consolidates the RI RPA/EXX merge work onto current develop and resolves the main regressions found during validation.

Main changes

  • integrate the RI/RPA post-SCF workflow with current develop
  • restore RI Coulomb-related input handling and output behavior
  • restore sparse matrix output precision needed by downstream tools
  • fix nspin=2 RI / overlap-matrix output inconsistencies
  • fix TRS symmetry-index handling in symrot_k output to avoid symmetry-related crashes
  • keep the merged behavior consistent with pre-merge ABACUS results for the checked LibRPA workflows

Validation

Checked against the regression cases discussed during debugging, including:

  • SOC + RPA/SCF workflow
  • Coulomb cut / mat output consistency
  • nspin=2 LibRPA-related workflow consistency
  • symmetry-enabled EXX/RI run that previously crashed in print_symrot_info_k()

Notes

  • This branch is intentionally squashed to make review easier.
  • The previous detailed development history is preserved locally in a backup branch if needed.

AroundPeking added 12 commits March 12, 2026 11:24
- integrate the RI/RPA post-SCF workflow with develop

- restore Coulomb/input-output handling and sparse matrix precision

- fix nspin=2 and TRS symmetry output regressions
The default was accidentally changed to "none", causing all tests
without explicit latname to fail at STRU parsing with
"do not use LATTICE_VECTORS along with explicit specification of lattice type".
The previous merge accidentally changed exx_singularity_correction
reset logic (lc_pbe etc from "spencer" to "massidda") and removed
metadata, causing 08_EXX integration tests to fail. Restore the
develop version and append new RI parameters (shrink_abfs_pca_thr,
shrink_lu_inv_thr, exx_coul_moment, exx_rotate_abfs,
exx_multip_moments_threshold, out_unshrinked_v).
The removal of filter_empty_orbs calls caused empty orbital shells to be
retained in lcaos and abfs vectors, altering RI exchange integrals for
all EXX calculations including standard HF used by LR-TDDFT.
The PR removed the filter_empty_orbs function from Construct_Orbs and
inlined its logic into change_orbs() for lcaos. The previous commit
incorrectly called the now-deleted function. This commit inlines the
same filtering logic directly for abfs to restore the empty orbital
shell removal without depending on the deleted function.
…formula

- Restore LRI_CV, Matrix_Orbs11/21/22, exx_abfs-construct_orbs,
  exx_opt_orb, ABFs_Construct-PCA to develop versions to minimize diff
- Fix spencer Rcut: use get_nkstot_full() without /nspin0 division
  (nkstot_full already excludes spin doubling)
- Fix shared_ptr<ORB_gaunt_table> usage in Exx_LRI, RPA_LRI
- Fix ewald_Vq compilation errors
- Fix exx_opt_orb-print.cpp to match develop API
The spencer Rcut formula was corrected to not divide by nspin0
(get_nkstot_full() already excludes spin doubling), which changes
the excitation energy result from 6.050430 to 2.574437.
The previous ref (2.574437) was from fisherd which lacks LibXC,
producing different results. Use CI environment's actual value.
@mohanchen
Copy link
Collaborator

Thanks for your PR, which extends the functionality of ABACUS. I noticed you have introduced several new input parameters. I would suggest adding corresponding unit or integration tests to ensure your results are not affected by future refactoring work from others in ABACUS.

@mohanchen mohanchen added Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes Input&Output Suitable for coders without knowing too many DFT details labels Mar 13, 2026
@AroundPeking
Copy link
Author

Thanks for your PR, which extends the functionality of ABACUS. I noticed you have introduced several new input parameters. I would suggest adding corresponding unit or integration tests to ensure your results are not affected by future refactoring work from others in ABACUS.

Done.

I added integration coverage for the new RPA-related workflow to reduce the risk of future refactoring changing these outputs silently.

The PR now includes:

  • 56_GO_RPA_OUTPUT: a molecular gamma-point RPA case comparing Cs_data_*, coulomb_cut_*, and coulomb_mat_*
  • 57_KP_RPA_SHRINK: a k-point shrink RPA case (1x1x2) comparing Cs_data_*, Cs_shrinked_data_*, coulomb_cut_*, coulomb_mat_*, and shrink_sinvS_*

One follow-up fix was also needed for CI: these RPA files are now compared by absolute value, because the ABF / shrink basis eigenvectors have an arbitrary overall sign, which can flip the sign of Cs_*-type outputs without affecting the physical results when the generated file set is used consistently.

The test additions were added in commit 173490d30, and the absolute-value comparison fix was added in commit 79c17dde6.

@mohanchen
Copy link
Collaborator

I have some suggestions on the output format of the integration test files in this PR:
The current output format of reference files are not user-friendly. Please add some comment lines starting with # to explain what the data means, so users can understand the content directly by opening the file.
It is not good to print only one number per line. I suggest outputting 6–8 numbers per line for better readability.
The output filenames have redundant words like data, which can be removed. Also, the file index should start from 1 instead of 0.
Some integration test examples produce too many lines (over 10k lines, even >50k lines) and too many files. We should simplify and compress the output properly while keeping the test valid.
These changes will make the test output cleaner, smaller, and easier to check.

@mohanchen
Copy link
Collaborator

mohanchen commented Mar 15, 2026

For example, this is the file for DOS:

image

@mohanchen
Copy link
Collaborator

This is the file for eigenvalues and occupations:

image

@mohanchen
Copy link
Collaborator

This file is for Mulliken charge:

image

@AroundPeking
Copy link
Author

I have some suggestions on the output format of the integration test files in this PR: The current output format of reference files are not user-friendly. Please add some comment lines starting with # to explain what the data means, so users can understand the content directly by opening the file. It is not good to print only one number per line. I suggest outputting 6–8 numbers per line for better readability. The output filenames have redundant words like data, which can be removed. Also, the file index should start from 1 instead of 0. Some integration test examples produce too many lines (over 10k lines, even >50k lines) and too many files. We should simplify and compress the output properly while keeping the test valid. These changes will make the test output cleaner, smaller, and easier to check.

Thanks for the suggestions.

For the output format / filename cleanup: I agree this can be improved, but I did not change it in this PR. These RPA output files are part of the current interface used by LibRPA, and the naming/layout is also kept consistent with the existing FHI-aims-style workflow. Changing filenames, indices, or file formatting here would require coordinated downstream changes and is broader than the functional scope of this PR. I would prefer to handle that cleanup in a follow-up PR.

For the integration test size issue, I updated the solid shrink RPA test in this PR. The previous case produced very large reference files, so I replaced it with a much smaller two-atom H 1x1x2 solid case while still checking the same set of RPA-related outputs:

  • Cs_data_*
  • Cs_shrinked_data_*
  • coulomb_cut_*
  • coulomb_mat_*
  • shrink_sinvS_*

This keeps the file coverage unchanged but reduces the reference size substantially (from about 224k lines total to 128 lines total).

Copy link
Collaborator

Choose a reason for hiding this comment

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

this file is strange, you delete 562 lines and add exactly 562 lines, could you double check why?

Copy link
Author

Choose a reason for hiding this comment

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

You are right — these were no-op line-ending / formatting changes from the merge, not real code changes.

I checked the whole PR for the same issue.

Besides the two LRI_CV_Tools files, there was one more no-op formatting / line-ending change in source/source_lcao/module_ri/Inverse_Matrix.h. I removed that as well in commit c33c8d7e1.

I then re-checked the full PR diff against develop, and there are no remaining whitespace-only / line-ending-only file changes.

@mohanchen
Copy link
Collaborator

I have some suggestions on the output format of the integration test files in this PR: The current output format of reference files are not user-friendly. Please add some comment lines starting with # to explain what the data means, so users can understand the content directly by opening the file. It is not good to print only one number per line. I suggest outputting 6–8 numbers per line for better readability. The output filenames have redundant words like data, which can be removed. Also, the file index should start from 1 instead of 0. Some integration test examples produce too many lines (over 10k lines, even >50k lines) and too many files. We should simplify and compress the output properly while keeping the test valid. These changes will make the test output cleaner, smaller, and easier to check.

Thanks for the suggestions.

For the output format / filename cleanup: I agree this can be improved, but I did not change it in this PR. These RPA output files are part of the current interface used by LibRPA, and the naming/layout is also kept consistent with the existing FHI-aims-style workflow. Changing filenames, indices, or file formatting here would require coordinated downstream changes and is broader than the functional scope of this PR. I would prefer to handle that cleanup in a follow-up PR.

For the integration test size issue, I updated the solid shrink RPA test in this PR. The previous case produced very large reference files, so I replaced it with a much smaller two-atom H 1x1x2 solid case while still checking the same set of RPA-related outputs:

  • Cs_data_*
  • Cs_shrinked_data_*
  • coulomb_cut_*
  • coulomb_mat_*
  • shrink_sinvS_*

This keeps the file coverage unchanged but reduces the reference size substantially (from about 224k lines total to 128 lines total).

OK, that sounds reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Features Needed The features are indeed needed, and developers should have sophisticated knowledge Input&Output Suitable for coders without knowing too many DFT details Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants