Skip to content

Support optional smooth realspace cutoffs#183

Merged
awvwgk merged 5 commits into
mainfrom
copilot/support-smooth-cutoff
May 6, 2026
Merged

Support optional smooth realspace cutoffs#183
awvwgk merged 5 commits into
mainfrom
copilot/support-smooth-cutoff

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

Realspace cutoffs previously introduced hard step functions in dispersion energies, which can create discontinuities in energies, gradients, and stress tensors as interatomic distances cross cutoff boundaries. This adds optional smoothing widths for two- and three-body dispersion cutoffs while preserving existing hard-cutoff behavior by default.

  • Core dispersion

    • Added width2 and width3 to realspace_cutoff.
    • Applied smooth polynomial switching to two-body and ATM three-body dispersion contributions.
    • Included smooth cutoff derivative terms in gradients and virials.
    • Applied the same smoothing to pairwise dispersion representations across supported damping models.
  • Public APIs

    • Added C API entry point:
      dftd3_set_model_realspace_cutoff_smooth(error, model, disp2, disp3, cn, width2, width3);
    • Extended Python DispersionModel.set_realspace_cutoff with optional width2 and width3.
    • Exposed ASE calculator support through realspace_cutoff.
  • Documentation and coverage

    • Documented smooth cutoff widths in C, Fortran, and ASE-facing docs.
    • Added focused C, Fortran, and Python tests covering API exposure, gradient consistency, and pairwise energy consistency.

Example:

call get_dispersion( &
   mol, disp, param, &
   realspace_cutoff(disp2=60.0_wp, disp3=40.0_wp, cn=40.0_wp, &
                    width2=5.0_wp, width3=3.0_wp), &
   energy, gradient, sigma)
model.set_realspace_cutoff(
    disp2=60.0,
    disp3=40.0,
    cn=40.0,
    width2=5.0,
    width3=3.0,
)

Copilot AI linked an issue May 6, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 6, 2026 11:37
Agent-Logs-Url: https://github.com/dftd3/simple-dftd3/sessions/451aed03-f955-4b68-82a2-e99aeaa4173a

Co-authored-by: awvwgk <28669218+awvwgk@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dftd3/simple-dftd3/sessions/451aed03-f955-4b68-82a2-e99aeaa4173a

Co-authored-by: awvwgk <28669218+awvwgk@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement support for smooth cutoff in dispersion energy Support optional smooth realspace cutoffs May 6, 2026
Copilot finished work on behalf of awvwgk May 6, 2026 11:42
Copilot AI requested a review from awvwgk May 6, 2026 11:42
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 34.44444% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.75%. Comparing base (9cbf93b) to head (962512c).

Files with missing lines Patch % Lines
src/dftd3/damping.f90 0.00% 16 Missing ⚠️
src/dftd3/damping/cso.f90 12.50% 1 Missing and 6 partials ⚠️
src/dftd3/damping/mzero.f90 14.28% 0 Missing and 6 partials ⚠️
src/dftd3/damping/optimizedpower.f90 14.28% 0 Missing and 6 partials ⚠️
src/dftd3/damping/rational.f90 14.28% 0 Missing and 6 partials ⚠️
src/dftd3/damping/zero.f90 14.28% 0 Missing and 6 partials ⚠️
src/dftd3/api.f90 37.50% 2 Missing and 3 partials ⚠️
src/dftd3/damping/atm.f90 20.00% 0 Missing and 4 partials ⚠️
src/dftd3/cutoff.f90 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #183      +/-   ##
==========================================
- Coverage   65.99%   65.75%   -0.25%     
==========================================
  Files          34       35       +1     
  Lines        4844     4885      +41     
  Branches     1672     1689      +17     
==========================================
+ Hits         3197     3212      +15     
- Misses        691      713      +22     
- Partials      956      960       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@awvwgk awvwgk marked this pull request as ready for review May 6, 2026 13:10
@awvwgk awvwgk merged commit d188486 into main May 6, 2026
53 of 55 checks passed
@awvwgk awvwgk deleted the copilot/support-smooth-cutoff branch May 6, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support smooth cutoff

2 participants