parkipy.ewald.stokes_comb¶
- parkipy.ewald.stokes_comb(trg, src, dens, normal, options)¶
Compute the combined Stokes single and double layer potential.
\[\boldsymbol{u}(\boldsymbol{x}_i) = \sum_{j=1}^{N} \sum_{p \in P} \left(\left( \frac{\boldsymbol{q}_j}{\lVert \boldsymbol{r}_{ij} \rVert} + \frac{\boldsymbol{r}_{ij}}{\lVert \boldsymbol{r}_{ij} \rVert^3} (\boldsymbol{r}_{ij} \cdot \boldsymbol{q}_j) \right) + \left( \epsilon_{jlm} \frac{\boldsymbol{r}_m}{\|\boldsymbol{r}_{ij}\|^3} \boldsymbol{q}_l \boldsymbol{n}_m \right) \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 values \(\boldsymbol{x}_i\) to compute the Stokes potential. Array should be shape
(3,nt)with the default ordering (i.e.,'C'ordering for cupy and'F'ordering for numpy.src (ndarray) – Array of source values \(\boldsymbol{y}_j\) of shape
(3, ns)with default ordering.dens (ndarray) – Array of density values of the source points of shape
(6,ns)with default ordering wheredens[:3]represent the single layer density \(\boldsymbol{q}_j\) anddens[3:]the double layer density \(\boldsymbol{q}_l\).normal (ndarray) – Array of normal vectors for the source points of shape
(3,ns)with default ordering.options (EwaldOptions) – Dataclass specifying Ewald parameters.
- Returns:
potential (ndarray) – Array containing the Ewald approximation for the Stokes potential at the target points \(\boldsymbol{u}(\boldsymbol{x}_i)\).
walltimes (dict, optional) – Dictionary containing the wall-time for each stage of the Ewald summation. Only returned if
options.return_walltime == True.params (SEParams, optional) –
SEParamsdataclass containing derived Ewald parameters for the Ewald summation run. Only returned ifoptions.return_params == True.
- Raises:
NotImplementedError – If
options.periodicityis not1or3.
Notes
Parameter selection based off [1].
References
Examples
>>> import parkipy >>> import numpy as np >>> trg = src = np.random.rand(3, 100000) >>> dens_sl = np.random.randn(3, 100000) >>> dens_dl = np.random.randn(3, 100000) >>> norms = np.random.randn(3, 100000) >>> dens = np.vstack((dens_sl, dens_dl)) # stack densities for ewald call >>> options = parkipy.ewald.EwaldOptions( ... box=[1,1,1], periodicity=1, tolerance=1e-4, ... execution_space="openmp", cell_size=224, return_walltime=True ... ) >>> pot, walltime = parkipy.ewald.stokes_comb(trg, src, dens, norms, options) >>> walltime {'p2p': {'args': 3.0994415283203125e-06, 'sort': 0.004508018493652344, 'kernel': 0.08536601066589355, 'tot': 0.08987712860107422}, 'p2g': {'args': 8.106231689453125e-06, 'sort': 0.002873659133911133, 'kernel': 0.06609272956848145, 'tot': 0.06897449493408203}, 'fft': {'tot': 0.05228924751281738}, 'cnv': {'tot': 0.025938749313354492}, 'ifft': {'tot': 0.010168075561523438}, 'g2p': {'args': 2.4318695068359375e-05, 'sort': 0.0019330978393554688, 'kernel': 0.0029044151306152344, 'adj': 0.0005638599395751953, 'tot': 0.005425691604614258}}