Skip to content

Feature: rVV10 nonlocal correlation implemented natively (replaces #8140) - #8520

Open
CleverPhysician wants to merge 8 commits into
deepmodeling:developfrom
CleverPhysician:rvv10-native
Open

CleverPhysician wants to merge 8 commits into
deepmodeling:developfrom
CleverPhysician:rvv10-native

Conversation

@CleverPhysician

@CleverPhysician CleverPhysician commented Dec 4, 2026 •

Copy link
Copy Markdown

This PR adds the rVV10 nonlocal correlation (vdw_method rvv10) as a native implementation. It replaces #8140, which evaluated rVV10 through libvdwxc: no external library and no tabulated data file are needed.

Linked Issue

Replaces #8140.

What's changed?

  • New option vdw_method rvv10 with parameters rvv10_b (default 6.3) and rvv10_c (default 0.0093). Energy, potential, forces and stress are available for PW and LCAO. DFPT and LR-TDDFT forces are rejected at input.
  • module_vdw/rvv10_kernel.cpp: Román-Pérez–Soler interpolation of the kernel on 38 q points. The kernel table is generated at start-up (0.12 s) from a closed-form radial transform; the convolution runs on the density FFT grid.
  • module_vdw/nonlocal_xc.cpp: adds the rVV10 potential to every XC evaluator and its stress to stress_gga.
  • Docs: input parameters in docs/advanced/scf/advanced.md, references in docs/CITATIONS.md.

Unit Tests and/or Case Tests for my changes

  • MODULE_HAMILT_nonlocal_xcTest on 1, 2 and 4 ranks and 2 ranks × 2 threads: potential and stress against finite differences, distributed against serial, nspin 1/2/4.
  • Integration cases 215_PW_rvv10_GaAs, 216_PW_rvv10_graphite and relax_cell_rvv10.
  • Accuracy: 38 → 128 q points changes energies by less than 0.002 meV/atom. Against QE 7.2, S22 binding energies agree within 0.015 kcal/mol; for graphite and MoS₂ the interlayer spacing is the same and the binding energy is 0.12 % and 0.23 % deeper, which matches the error of a 20-point q table (Sabatini et al. 2013 use 20 points).
  • Wall time is within 10 % of the libvdwxc version.

Governance Exception

  • Rule: new compile definitions (AGENTS rule 20).
  • Reason: __RVV10 is always on; the focused XC unit tests in module_xc/test and module_surchem/test do not link the plane-wave library, so they switch it off and use empty hooks.
  • Scope: the feature definition list and those two test directories.
  • User or maintenance risk: none; production builds always compile rVV10.
  • Why the normal rule cannot be followed now: otherwise those tests would have to link the plane-wave basis.
  • Follow-up cleanup plan: none needed.
  • Requested approver: a maintainer

@mohanchen mohanchen added the Feature Discussed The features will be discussed first but will not be implemented soon label Dec 5, 2026
deepmodeling#8140 added rVV10 through libvdwxc; the maintainers decided against taking
the extra dependency, so the correction moves into ABACUS itself. This commit
carries over everything that is independent of the library -- the INPUT
parameters, the hooks in every XC evaluator and in stress_gga, the adapter
that forms the total density and its gradient, the unit tests and the three
Autotest cases -- and replaces the library call by the interface of the
native kernel in rvv10_kernel.h. The slab exchange is gone: the native
kernel works on the plane distribution of the ABACUS grid.

rvv10_kernel.cpp is not part of this commit yet.
The nonlocal correlation is evaluated with the Roman-Perez--Soler expansion:
the density is projected on a logarithmic mesh of the local variable q with a
cardinal cubic-spline basis, each channel is convolved with the tabulated
reduced kernel in reciprocal space, and the result is contracted back. The
kernel table is built from the published analytic kernel at run time, so no
generated data file enters the repository and the build takes no new
dependency.

Every formula carries the section of the reference note it comes from. The
table exploits that the rVV10 denominator factorizes as 2 (1+q R^2)(1+q' R^2)
(1+((q+q')/2) R^2) and that the product of the three reciprocals is the
triangular-weight average of (1+Q R^2)^-3 over [q, q'], so one accurate
radial transform serves every node pair.

The unit tests replace the former external-library reference by an analytic
single-mode benchmark and a parameter-and-total-density check; the five
contract tests (potential and stress against finite differences, every XC
path, distributed against complete grid, left-handed cell) are unchanged.
The native kernel removed the preprocessor guard of the former optional
dependency, so every target that compiles an XC evaluator had to resolve
vdw::add_rvv10. The focused tests in module_xc/test and module_surchem/test
construct a PW_Basis by hand and link neither the plane-wave basis nor
module_base, so linking the correction there would pull its whole closure
into tests that do not exercise it. The hooks become empty inline functions
without __RVV10, which the production build always defines and those two
test directories switch off.
The reduced radial transform has an elementary closed form,
  int_0^inf u^2 j0(z u) (1+u^2)^-3 du = pi (1+z) exp(-z) / 16,
obtained by differentiating int_0^inf u sin(a u)/(u^2+s) du = pi/2 exp(-a sqrt(s))
twice with respect to s. Use it instead of a Simpson quadrature, which removes the
radial cutoff, the radial grid size and both tail tapers.

Set the q lattice from a convergence scan on graphite and MoS2: 56 geometric nodes
on [1e-3, 3] bohr^-2 stay within 0.007 meV/atom of 128 nodes. The upper end keeps
q_c = 3 bohr^-2 (Obata et al., JPSJ 84, 024715, Table I); the lower end leaves
room for larger b, since q scales as 1/b at fixed density.
…tice

- Every channel is a real field: transform the channels on a gamma-only
  PW_Basis built from the density basis (same FFT grid, cutoff and real-space
  planes, rebuilt when the cell or the pool changes), real-to-complex. Plane
  waves off the kept plane count twice in the sums. Where the half sphere would
  leave a process without plane waves, the density basis itself is used.
- Multiply each |G| shell by the kernel matrix with BlasConnector::gemm_cm on
  the (Re, Im) rows of a channel-major block, instead of a scalar pair loop.
- Locate each density point on the q lattice once; evaluate the cardinal
  splines as Hermite cubics from the knot slopes of CubicSpline::build.
- Build the kernel table once per process (it depends on the lattice only),
  one radial curve per node pair, so the lattice need not be geometric.
- q lattice: ratio 1.157 on [5e-3, 0.3] bohr^-2, widening outwards to 1e-3 and
  q_c = 3; 38 nodes give the accuracy of the previous 56.
- Regenerate the three rVV10 references.

With the previous 56-node lattice the restructured code reproduces the previous
total energies to 1e-11 eV (graphite, MoS2, S22 ammonia and benzene dimers).
PW_Basis_Big hands out z planes in blocks of bz, so the half-sphere
basis must use the same bx/by/bz; otherwise its real-space planes differ
from the caller's and rVV10 silently falls back to the full sphere (the
LCAO case). The half sphere is now always a PW_Basis_Big, with blocks of
one for a plain PW_Basis (which distributes planes the same way), held
as one static object that is set up again when the key changes; the
block sizes are part of that key. The checks are split into small
functions.

A new unit test forces the full-sphere path and checks that energy,
potential coefficients and stress agree with the half-sphere path to
rounding.
The references were generated with cg, the PW default before deepmodeling#8507.
With dav_subspace the two-atom spin-polarized GaAs case reaches a different
SCF solution, so both cases keep cg like the other pinned 01_PW cases.

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

Feature Discussed The features will be discussed first but will not be implemented soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants