Skip to content

Conversation

@GardevoirX
Copy link
Contributor

@GardevoirX GardevoirX commented Jul 21, 2025

Fixes the error formula of Ewald used in tuning. The fixed formula is tested with systems of crystal cells repeated 8 times on each dimension.

No difference in the actual accuracy is observed.
acc

The Ewald calculation time is a bit longer with the fixed formula.
ewald_calc

Contributor (creator of pull-request) checklist

  • Tests updated (for new features and bugfixes)?
  • Documentation updated (for new features)?
  • Issue referenced (for PRs that solve an issue)?

Reviewer checklist

  • CHANGELOG updated with public API or any other important changes?

📚 Documentation preview 📚: https://torch-pme--198.org.readthedocs.build/en/198/

@GardevoirX GardevoirX requested a review from PicoCentauri July 21, 2025 06:37
@GardevoirX GardevoirX linked an issue Jul 21, 2025 that may be closed by this pull request
Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs should also be updated with the change.

Comment on lines 177 to 178
/ torch.sqrt(2 * torch.pi**2 * self.volume / lr_wavelength)
* torch.exp(-2 * torch.pi**2 * smearing**2 / lr_wavelength**2)
Copy link
Contributor

@PicoCentauri PicoCentauri Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this change is correct? I think units still don't match because smearing and the lr_wavelength should cancel. I just re-derived the equation and I got

$$ ΔF_\mathrm{LR} = \frac{Q^2}{\sqrt{N}} \sqrt{\frac{h}{V}} \frac{1}{π\sigma} \mathrm{exp} \left(-\frac{2 π^2 \sigma^2}{h^2}\right) $$

maybe check it again.

I think we should also give the conversion between our convention and the other usual one somewhere in the docs:

$$ α = \frac{1}{\sqrt{2}Σ} K = \frac{2π}{h} $$

where α is the inverse width of Gaussian charge cloud and $K$ is the Fourier space cutoff in inverse units of length.

Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @GardevoirX!

@PicoCentauri PicoCentauri merged commit 1f61266 into main Jul 21, 2025
13 checks passed
@PicoCentauri PicoCentauri deleted the ewald-error branch July 21, 2025 18:56
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.

review kspace error in Ewald tuner

3 participants