Reduce Ewald summation work with pair-specific image bounds - #1388
Open
antoine-levitt wants to merge 2 commits into
Open
antoine-levitt wants to merge 2 commits into
antoine-levitt wants to merge 2 commits into
Conversation
antoine-levitt
marked this pull request as draft
September 25, 2026 14:13
Collaborator
Member
Author
Can you do it? Otherwise I can take a look but it might take a while |
abussy
marked this pull request as ready for review
September 28, 2026 09:16
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cf #1387. I haven't checked any of it, but the basic idea appears right.
AI slop follows.
Ewald setup evaluates every atom pair over a global box of periodic images, including many whose screened interaction is negligible. Bound the images separately for each pair and apply the real- and reciprocal-space spherical cutoffs before evaluating the expensive terms. This addresses the bottleneck discussed in #1387.
The real-space loop now updates Cartesian separations incrementally and converts accumulated Cartesian forces to reduced coordinates once per atom. It also uses the analytical radial derivative and accumulates energy per atom to reduce roundoff. The default η and full ordered pair sum are unchanged. Complex phonon displacements are included in the image bounds; their derivatives still use the complex-analytic distance.
This also fixes the ordinary
energy_forces_ewaldwrapper silently discarding the supplied η.CPU timings
216 Al ions in a 6×6×6 FCC primitive supercell, lattice parameter 4.05 Å, Julia 1.12.4, Alder Lake CPU. This is a representative system; #1387 does not provide its complete benchmark input.
Compilation is excluded. Float64 timings are minima of three warmed calls. The strain timings are the measured sum of six one-partial Dual calls, matching the Ewald work in
compute_stresses_cart; they do not include the rest of stress evaluation. Ewald runs on the CPU even in GPU calculations. No GPU benchmark was run.benchmark/ewald.jlincludes the reproducer and instructions for comparing the implementations.Validation
energy_forces_ewaldtest items pass: existing reference energies, η independence and forwarding, periodic shifts, forces, strain derivatives, and a nonzero-q complex phonon response checked against finite differences.Targeted test command in the persistent test environment: