Kvectors¶
- torchpme.lib.get_ns_mesh(cell: Tensor, mesh_spacing: float)[source]¶
Computes the mesh size given a target mesh spacing and cell getting the closest powers of 2 to help with FFT.
- torchpme.lib.generate_kvectors_for_mesh(cell: Tensor, ns: Tensor) Tensor [source]¶
Compute all reciprocal space vectors for Fourier space sums.
This variant is used in combination with mesh based calculators using the fast fourier transform (FFT) algorithm.
- Parameters:
cell (Tensor) – torch.tensor of shape
(3, 3)
, wherecell[i]
is the i-th basis vector of the unit cellns (Tensor) – torch.tensor of shape
(3,)
and dtype intns = [nx, ny, nz]
contains the number of mesh points in the x-, y- and z-direction, respectively. For faster performance during the Fast Fourier Transform (FFT) it is recommended to use values of nx, ny and nz that are powers of 2.
- Returns:
torch.tensor of shape
(nx, ny, nz, 3)
containing all reciprocal space vectors that will be used in the (FFT-based) mesh calculators. Note thatk_vectors[0,0,0] = [0,0,0]
always is the zero vector.- Return type:
See also
generate_kvectors_for_ewald()
for a function to be used for Ewald calculators.
- torchpme.lib.generate_kvectors_for_ewald(cell: Tensor, ns: Tensor) Tensor [source]¶
Compute all reciprocal space vectors for Fourier space sums.
This variant is used with the Ewald calculator, in which the sum over the reciprocal space vectors is performed explicitly rather than using the fast Fourier transform (FFT) algorithm.
The main difference with
generate_kvectors_for_mesh()
is the shape of the output tensor (see documentation on return) and the fact that the full set of reciprocal space vectors is returned, rather than the FFT-optimized set that roughly contains only half of the vectors.- Parameters:
- Returns:
torch.tensor of shape
(n, 3)
containing all reciprocal space vectors that will be used in the Ewald calculator. Note thatk_vectors[0] = [0,0,0]
always is the zero vector.- Return type:
See also
generate_kvectors_for_mesh()
for a function to be used with mesh based calculators like PME.