Skip to content

Fix missing last term in B-spline factor for structure factor - #8210

Open
Cstandardlib wants to merge 2 commits into
deepmodeling:developfrom
Cstandardlib:fix-nbspline
Open

Cstandardlib wants to merge 2 commits into
deepmodeling:developfrom
Cstandardlib:fix-nbspline

Conversation

@Cstandardlib

@Cstandardlib Cstandardlib commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fix missing last term in B-spline deconvolution factor for structure factor (nbspline).

Summary

Fix an error in the B-spline correction coefficients used by Structure_Factor::bsplinecoef.

The previous denominator sum omitted the last nonzero integer sample of the Cardinal B-spline.
This gives incorrect structure factors when nbspline is enabled, with a particularly large error at low orders.
For nbspline = 2, the zero-frequency structure factor is multiplied by 8, which also scales the integrated
atomic-superposition initial density before any subsequent normalization.

Linked Issue

Fix #8092

Unit Tests and/or Case Tests for my changes

  • Commands run:
  • Result summary:
  • Checks not run, with reason:

What's changed?

  • Example: brief summary of the user-visible or developer-facing change.

Governance Notes

  • INPUT/docs changes:
  • Core module impact:
  • Exceptions requested:

… by (1-1/N!)^-3

The denominator loop in Structure_Factor::bsplinecoef missed the last integer-point sample M_{N+1}(N) = 1/N! of the Cardinal B-spline, so the G=0 deconvolution factor was 1/(1-1/N!) per direction instead of 1, and S(G=0) -- the integrated electron number -- was scaled by (1-1/N!)^-3 (8x at nbspline=2). The method is exact at G=0 at any order by partition of unity, so this was an off-by-one implementation error, not low-order interpolation error.

Add a unit test asserting b(0)=1 for norder = 2,4,6,10,20 and a low-order OFDFT integration case 35_OF_LPS_bspline; regenerate references of the six existing nbspline=10 cases (energies shift by ~1e-4 eV, the intended behavior change).
@Cstandardlib Cstandardlib changed the title Fix missing last term in structure factor (nbspline) Fix missing last term in B-spline factor for structure factor Oct 25, 2026
@Cstandardlib
Cstandardlib marked this pull request as ready for review October 25, 2026 17:09

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] nbspline gives wrong structure factors at low orders:

1 participant