xnn.common.models.pme.least_squares_moduli#

xnn.common.models.pme.least_squares_moduli(size, order, dtype, device, n_alias=50)[source]#

|b(m)|^2 of the least-squares spline fit along one mesh axis.

The particle-mesh sum replaces exp(2 pi i m u / K) by b(m) sum_k M_p(u - k) exp(2 pi i m k / K). The Euler exponential spline (bspline_moduli()) chooses b(m) to make the two equal at the mesh points; here b(m) minimises the mean squared difference over u. With s_j = |sinc(m / K + j)|^p the amplitudes of the spline sum at the aliased frequencies m + j K, that is |b(m)|^2 = s_0^2 / (sum_j s_j^2)^2. Both choices agree at m = 0 and as the mesh is refined; at a coarse mesh the least-squares one leaves a far smaller mean self-interaction error in the energies. For an odd order on an even mesh the Nyquist frequency, where the spline sum of an odd order vanishes at the mesh points, carries no weight.

Parameters:
  • size (int) – Mesh points K along the axis.

  • order (int) – Spline order p.

  • dtype (dtype) – Of the returned tensor.

  • device (device) – Of the returned tensor.

  • n_alias (int, optional) – Aliases |j| <= n_alias in the sums.

Returns:

|b(m)|^2, shape (K,), in FFT order.

Return type:

Tensor