parkipy.ewald.stokes_sl

parkipy.ewald.stokes_sl(trg, src, dens, options)

Compute the Stokes single-layer potential.

\[\boldsymbol{u}(\boldsymbol{x}_i) = \sum_{j=1}^{N} \sum_{p \in P} \left( \frac{\boldsymbol{q}_j}{\lVert \boldsymbol{r}_{ij} \rVert} + \frac{\boldsymbol{r}_{ij} (\boldsymbol{r}_{ij} \cdot \boldsymbol{q}_j)} {\lVert \boldsymbol{r}_{ij} \rVert^3} \right),\]

where \(\boldsymbol{r}_{ij} = \boldsymbol{x}_i - \boldsymbol{y}_j\) and \(P\) is the specified periodicity.

Warning

Currently only supported for \(P=1,3\).

Parameters:
  • trg (ndarray) – Array of target positions \(\boldsymbol{x}_i\) at which to evaluate the potential. Shape (3, nt) with default array ordering ('C' for cupy, 'F' for numpy).

  • src (ndarray) – Array of source positions \(\boldsymbol{y}_j\) of shape (3, ns) with default array ordering.

  • dens (ndarray) – Single-layer density \(\boldsymbol{q}_j\) at each source point. Shape (3, ns) with default array ordering.

  • options (EwaldOptions) – Dataclass specifying Ewald parameters.

Returns:

  • potential (ndarray) – Ewald approximation of the Stokes single-layer potential at the target points \(\boldsymbol{u}(\boldsymbol{x}_i)\), shape (3, nt).

  • walltimes (dict, optional) – Wall-clock time for each stage of the Ewald summation ('p2p', 'p2g', 'fft', 'cnv', 'ifft', 'g2p'). Only returned if options.return_walltime == True.

  • params (SEParams, optional) – SEParams dataclass containing the derived Ewald parameters used for this call. Only returned if options.return_params == True.

Raises:

NotImplementedError – If options.periodicity is not 1 or 3.

Notes

Parameter selection based off [1].

References

Examples

>>> import parkipy
>>> import numpy as np
>>> nt = ns = 10000
>>> trg = src = np.random.rand(3, nt)
>>> dens = np.random.randn(3, ns)
>>> options = parkipy.ewald.EwaldOptions(
...     box=[1, 1, 1], periodicity=3, tolerance=1e-4,
...     execution_space="openmp", cell_size=224, return_walltime=True,
... )
>>> pot, walltime = parkipy.ewald.stokes_sl(trg, src, dens, options)