A reference implementation for Ewald summation, which calculates the electrostatic energy of a periodic system.
- Support for charges and dipoles.
- Support for sheared volumes.
- Tin foil boundary conditions.
- Errors can be controlled to order
$10^{-12}$ .
Calculate the Madelung constant for NaCl using its primitive cell.
import Ewalder
latvecs = [[1,1,0], [1,0,1], [0,1,1]]
pos = [[0,0,0], [1,1,1]]
charges = [1, -1]
sys = Ewalder.System(; latvecs, pos)
E = Ewalder.energy(sys; charges)
@assert E ≈ -1.74756459
For more explanation, see the package documentation.
Usage examples are contained in Ewalder/test
.