Skip to content

Add RPA smooth coulomb cutoff for V_cut - #8212

Open
HGAQ wants to merge 5 commits into
deepmodeling:developfrom
HGAQ:feat/rpa-smooth-coulomb
Open

HGAQ wants to merge 5 commits into
deepmodeling:developfrom
HGAQ:feat/rpa-smooth-coulomb

Conversation

@HGAQ

@HGAQ HGAQ commented Oct 23, 2026

Copy link
Copy Markdown

Unit Tests and/or Case Tests for my changes
Commands run:

cmake -S publish_checks -B publish_checks/build
cmake --build publish_checks/build -j 2
ctest --test-dir publish_checks/build --output-on-failure

# Production executable checks
./build/abacus_std_para --version
./build/abacus_std_para -h rpa_cut_coulomb
./build/abacus_std_para --check-input

What's changed?
Adds an optional log-erfc smooth Coulomb cutoff to the post-SCF RPA export workflow. The existing hard spherical cutoff remains the default.

Three INPUT parameters control the kernel, radius convention, and smoothing width:

rpa_cut_coulomb log_erfc
rpa_cut_radius legacy
rpa_cut_width 1.091868692359

An independent inscribed radius option uses half the shortest nonzero Born–von Karman superlattice vector, including integer combinations of lattice vectors.

The implementation updates the truncated-Coulomb path, including RI fits that use this metric. Matching RI coefficients, cut Coulomb matrices, and screened interactions must therefore be regenerated together. The full-Coulomb kernel definition and downstream interpolation rules remain unchanged.

Governance Notes
INPUT/docs changes: Registered and validated the three new parameters. Regenerated docs/parameters.yaml and docs/advanced/input_files/input-main.md from the executable. Defaults preserve hard / legacy behavior.
Dependencies: Configuration is passed explicitly through the existing RI parameter structure; no additional global-variable references are introduced.
Header dependency: is required because std::array appears in the public shortest-vector function signature.
Build/test integration: Registered the new implementation and focused tests in the corresponding CMake files. The numerical helper passes a C++11 build.
Scope: Based on the production baseline c2fa3ac. Unrelated local interface changes and calculation outputs are excluded.

HGAQ added 3 commits October 23, 2026 12:50
Add a log-erfc radial cutoff and an independent BvK inscribed-radius
option. Preserve hard/legacy defaults and apply the smooth Fourier factor
through the post-SCF cut-Coulomb path, including RI fits using that metric.
Register and validate the three INPUT parameters, log the selected radius,
and document consistent downstream RI/Vcut/W use.

Regenerate parameters.yaml and input-main.md from the production executable;
add a usage guide and focused kernel/INPUT tests.

Validation:
- Fresh C++11 build of the kernel GoogleTests; CTest 1/1 passed (2 test cases).
- Production executable --version and -h rpa_cut_coulomb passed.
- Fresh --check-input: hard/legacy, smooth/legacy and smooth/inscribed
  accepted; invalid mode, radius and width rejected (6/6).
- All 11 changed source/build/test files byte-match the compiled production
  source copy. Full application build and Si W/BSE runs were performed in
  that production copy, which also has pre-existing local interface changes;
  a full application build of this isolated checkout was not repeated.
- git diff --cached --check passed; staged governance has no errors.
  Its sole header warning is required: std::array appears in the public
  shortest-vector function signature, so <array> must be included.
- New kernel/header/test files pass the repository quality scorer (3/3).

Based on production baseline c2fa3ac.
Unrelated local BSE/interface changes and numerical output are excluded.
…yout

Resolve generated-document modify/delete conflicts by following develop:
parameter YAML/Markdown are generated artifacts, not tracked sources.
Retain the three INPUT registrations and local documentation copies.

Move the smooth-kernel test into module_ri/unittests with the current
naming convention and register it alongside existing tests. Preserve all
upstream RI sources and add the helper to the legacy Makefile object list.
Adapt INPUT tests to TestParameters and the current check_item helper.
The numerical cutoff implementation is unchanged.

Validation on the merged tree:
- CMake configuration with MPI/LCAO/LibRI/Libxc and BUILD_TESTING=ON passed.
- Built MODULE_RI_smooth_cut_coulomb and MODULE_IO_read_item_serial.
- Both CTest targets passed.
- Syntax checks with current build flags passed for exx_info.cpp,
  conv_coulomb_pot_k.cpp, exx_lri_detail.cpp and read_inp_exx_dftu.cpp.
- INPUT test source syntax check passed; no conflict markers remain.
- git diff --check origin/develop passed.

No full application rebuild or new scientific calculations were performed.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

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.

Static review of bf59ad2e2a5ab508e7b6a559254463aa01e5c977 after independent assessments. The inline notes cover INPUT validation, supported kernel scope, and two nonblocking follow-ups. Independent scalar checks found no confirmed Fourier-formula or shortest-vector defect. No product build or ABACUS/MPI execution was performed; CI diagnostics were unavailable.

item.description = "Post-SCF cut-Coulomb kernel: hard preserves Spencer truncation; log_erfc uses erfc(log(r/Rc)/log(rpa_cut_width))/2r. Applies to compressed and uncompressed cut exports; full Coulomb is unchanged. Forces and stresses for log_erfc are not validated.";
item.default_value = "hard";
item.unit = "";
read_sync_string(input.rpa_cut_coulomb);

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.

Please declare both enum choices with item.domain.set_choices. A valueless rpa_cut_coulomb or rpa_cut_radius line followed by another INPUT item reaches unchecked str_values[0] before these callbacks, while extra tokens are silently ignored. The callbacks also run only on rank 0 after broadcasts; the width bounds can use the common set_rule path while retaining its existing numeric scalar parsing. Parser-level tests should cover the original token sequences.

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.

Addressed in 73d698b649bb0bd91f6638fd0ccbee6490ae3e02: the enum choices and width rule now validate original tokens before the readers, with shared error propagation before parameter broadcasts. Static reinspection also covered the new parser assertions; no product or MPI tests were run in this review.

// tags, so the full-Coulomb/ground-state exchange kernel is unchanged.
if (inp.rpa)
{
for (auto& cut_family : exx_info.info_ri.coulomb_param)

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.

With rpa=true, dft_functional=hse and default exchange parameters, this map contains only Erfc, so rpa_cut_coulomb=log_erfc and rpa_cut_radius=inscribed are silently ignored here. Please reject or explicitly diagnose these unsupported requests and document the Fock-only scope, with a configuration-level regression. The existing HSE kernel convention can remain unchanged.

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.

Addressed in 73d698b649bb0bd91f6638fd0ccbee6490ae3e02: initialization now rejects nondefault kernel/radius requests on an Erfc-only map, and the INPUT descriptions state the Fock-only scope. This was checked by static source tracing; the new configuration test's LibRI-disabled registration issue is tracked separately. No runtime validation was performed.

EXPECT_DOUBLE_EQ(Conv_Coulomb_Pot_K::log_erfc_cut_factor(0.0, 32.0, cut_width), 0.0);
EXPECT_NEAR(Conv_Coulomb_Pot_K::log_erfc_cut_factor(0.2, 32.0, 1.00000001),
1.0 - std::cos(6.4), 1.e-13);
for (int cut_index = 1; cut_index <= 100; ++cut_index)

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.

Non-blocking: please add independent finite-width Fourier reference values, including the maximum allowed width and an oscillatory case. The [0,2] bounds also hold for an aliased positive quadrature, so they do not protect the ordinary finite-width shape. The current scalar comparisons found no formula defect; this regression coverage can follow after merge.

for (size_t cut_ik = 0; cut_ik < psik2_ccp.size(); ++cut_ik)
{
psik2_ccp[cut_ik] += cut_alpha * ModuleBase::FOUR_PI * orbs.get_psif()[cut_ik]
* log_erfc_cut_factor(orbs.get_k_radial()[cut_ik], cut_radius, cut_width);

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.

Non-blocking: please consider tabulating the cutoff factor once per distinct momentum grid, radius and width within this conversion, then reusing it across auxiliary orbitals. The factor is independent of the orbital amplitude, but the recursive conversion repeats its 128-or-more-panel quadrature at nonzero momentum on shared grids. A local table avoids global mutable state, and this can follow after merge if current performance is acceptable.

@HGAQ HGAQ changed the title Feat/rpa smooth coulomb Add RPA smooth coulomb cutoff for V_cut Oct 23, 2026
… kernels

Declare cutoff mode/radius choices and width bounds through the shared
INPUT domain validator. Missing values, extra tokens, invalid choices and
non-finite/out-of-range widths now fail before reader callbacks/broadcasts.

Reject non-default cutoff requests for RPA configurations without a Fock
component, including default HSE. Preserve existing Erfc kernel behavior
and document the Fock-only scope in the INPUT metadata.

Add parser-level regressions for the original malformed token sequences
and configuration coverage for default HSE, rejected HSE cutoff requests,
and accepted PBE cutoff settings. Numerical kernels and caching are unchanged.

Validation: MODULE_IO_input_domain_reader, MODULE_IO_read_item_serial and
MODULE_HAMILT_RpaCutoffConfig all passed (3/3 CTest targets). Staged diff
whitespace and governance checks reported no errors. Generated YAML and
Markdown were checked locally for enum choices, width bounds and scope;
they remain untracked build artifacts under current develop policy.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

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.

Incremental static review of 73d698b649bb0bd91f6638fd0ccbee6490ae3e02 after independent assessments. The previous INPUT-domain and Erfc-only handling concerns are addressed; the new inline note covers a LibRI-disabled test path. The two earlier nonblocking follow-ups remain unchanged. No product build or MPI tests were run; CI diagnostics were unavailable, and production tail/export convergence and legacy-v0 arbitrary k-point support remain unverified.

AddTest(
TARGET MODULE_HAMILT_RpaCutoffConfig
LIBS parameter base device
SOURCES test_exx_info.cpp ../exx_info.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.

Please gate this target or its PBE section on ENABLE_LIBRI. The parent test directory is enabled with MPI and Libxc alone, while LibRI defaults OFF; without __EXX, init_exx_info skips RI initialization for PBE and the new test then calls .at(Fock) on an empty map at test_exx_info.cpp:37. This is a statically identified failing test path in that configuration; please retain coverage for both feature settings.

@AroundPeking

Copy link
Copy Markdown

log_erfc needs a larger rpa_ccp_rmesh_times

The smooth switch f(r) = ½·erfc[ln(r/Rc)/ln w] is not compactly supported at Rc: it equals erfc(t)/2 at r = Rc·w^t, so with the default width (w^8 ≈ 2.0) the potential only becomes negligible around 1.5–2 Rc, whereas the hard Spencer cutoff is exactly zero beyond Rc. Both the ccp radial window and the V(R) cell range scale with rpa_ccp_rmesh_times, so this cutoff needs a correspondingly larger value — roughly 1.5–2× what was sufficient for the hard cutoff (e.g. 15–20 if 10 was only just enough), especially for converged k-meshes where Rc ≈ 0.5–0.62 × supercell length. Too small a value silently truncates the smooth tail and reintroduces a hard edge at the box boundary. exx_ccp_rmesh_times does not need to change.

@mohanchen mohanchen added EXX/lr-TDDFT/RPA/BSE/GW Related to beyond DFT methods Refactor Refactor ABACUS codes Tests/Examples Issues/PR related to unit tests and integrate tests labels Oct 25, 2026
@Critsium-xy

Copy link
Copy Markdown
Collaborator

@ABACUS-PR-BOT Please solve this conflict

@HGAQ

HGAQ commented Oct 27, 2026

Copy link
Copy Markdown
Author

log_erfc needs a larger rpa_ccp_rmesh_times

The smooth switch f(r) = ½·erfc[ln(r/Rc)/ln w] is not compactly supported at Rc: it equals erfc(t)/2 at r = Rc·w^t, so with the default width (w^8 ≈ 2.0) the potential only becomes negligible around 1.5–2 Rc, whereas the hard Spencer cutoff is exactly zero beyond Rc. Both the ccp radial window and the V(R) cell range scale with rpa_ccp_rmesh_times, so this cutoff needs a correspondingly larger value — roughly 1.5–2× what was sufficient for the hard cutoff (e.g. 15–20 if 10 was only just enough), especially for converged k-meshes where Rc ≈ 0.5–0.62 × supercell length. Too small a value silently truncates the smooth tail and reintroduces a hard edge at the box boundary. exx_ccp_rmesh_times does not need to change.

Hi Huangjing,

It is true that the smoothed Coulomb interaction is nonzero at $R_{c}$. However, $R_{c}$ is actually follows the definition of hard cutoff, rather than its numerical boundary. This follows the modified Spencer–Alavi scheme in Ren et al., Phys. Rev. Materials 5, 013807 (2021), Sec. III B, Eq. (34).

I agree that the numerical window must accommodate the tail. For our current Si calculations, however, rpa_ccp_rmesh_times=10 already gives a radial window of approximately 80 Bohr. Even after allowing for the 8-Bohr auxiliary-basis radius, this covers nearly 2$R_{c}$ for $9\times9\times9$ k-point.

@ABACUS-PR-BOT

Copy link
Copy Markdown
Collaborator

Resolved the develop merge conflict in 2430c4713c770b1607868fe38419b83773b8de0e by retaining both sets of INPUT tests unchanged. The four focused IO suites and eight MPI INPUT-error cases passed on CPU (12/12). Full RPA numerical validation was not rerun; CI status remains unverified because the configured checks connector is unavailable.

@HGAQ

HGAQ commented Oct 27, 2026

Copy link
Copy Markdown
Author

Find out the error which occurs in #7794

This branch has not been deployed

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

Labels

EXX/lr-TDDFT/RPA/BSE/GW Related to beyond DFT methods Refactor Refactor ABACUS codes Tests/Examples Issues/PR related to unit tests and integrate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants