gpe.gpu.bases
=============

.. py:module:: gpe.gpu.bases

.. autoapi-nested-parse::

   Updated bases with GPU support.



Classes
-------

.. autoapisummary::

   gpe.gpu.bases.PeriodicBasisGPU
   gpe.gpu.bases.SphericalBasis
   gpe.gpu.bases.CylindricalBasis


Module Contents
---------------

.. py:class:: PeriodicBasisGPU(Nxyz, Lxyz, symmetric_lattice=False, axes=None, smoothing_cutoff=0.8, memoization_GB=0.5, _test=False, **_kw)

   Bases: :py:obj:`mmfutils.math.bases.PeriodicBasis`


   dim-dimensional periodic bases.

   :param Nxyz: Number of lattice points in basis.
   :type Nxyz: (Nx, Ny, ...)
   :param Lxyz: Size of each dimension (length of box and radius)
   :type Lxyz: (Lx, Ly, ...)
   :param symmetric_lattice: If True, then shift the lattice so that it is symmetric about
                             the origin.  The default is to ensure that there is a lattice
                             point at the origin which will make the lattice asymmetric for
                             even Nxyz.
   :type symmetric_lattice: bool
   :param axes: Axes in array y which correspond to the x, y, ... axes here.
                This is required for cases where y has additional dimensions.
                The default is the last dim axes (best for performance).
   :type axes: (int, int, ...)
   :param smoothing_cutoff: Fraction of maximum momentum used in the function smooth().  The current
                            implementation is a spherically symmetric truncation in momentum space.  A
                            smoothing_cutoff of 0.5 is suitable for the TGPE as is 2/3 if the density is
                            additionally truncated at each step.  (For details, see
                            https://doi.org/10.1103%2Fphysreve.83.066311)
   :type smoothing_cutoff: float
   :param memoization_GB: Memoization threshold.  If memoizing factors like the momentum and smoothing
                          factor would exceed this threshold, then memoization is disabled.
   :type memoization_GB: float


   .. py:attribute:: xp


   .. py:attribute:: _fft


.. py:class:: SphericalBasis(N, R)

   Bases: :py:obj:`mmfutils.math.bases.SphericalBasis`


   1-dimensional basis for radial problems.

   We represent exactly `N` positive abscissa, excluding the origin and use
   the discrete sine transform.  We represent the square-root of the
   wavefunctions here so that a factor of `r` is required to convert these
   into the radial functions.  Unlike the DVR techniques, this approach allows
   us to compute the Coulomb interaction for example.


   .. py:attribute:: xp


   .. py:method:: init()

      Initialize Object.



   .. py:method:: laplacian(y, factor=None, factors=None, exp=False)

      Return the laplacian of `y` times `factor` or the
      exponential of this.

      :param factor: Additional factor(s) (mostly used with `exp=True`).  The
                     implementation must be careful to allow the factor to
                     broadcast across the components.
      :type factor: float | None
      :param factors: Tuple of scale factors for each dimension.  Allows for independent scaling
                      of each direction (used in expanding reference frames).
      :type factors: [float] | None
      :param exp: If `True`, then compute the exponential of the laplacian.
                  This is used for split evolvers.
      :type exp: bool



   .. py:method:: coulomb_kernel(k, factors=None)

      Form for the truncated Coulomb kernel.



   .. py:method:: convolve_coulomb(y, form_factors=(), factors=None)

      Modified Coulomb convolution to include form-factors (if provided).

      This version implemented a 3D spherically symmetric convolution.



   .. py:method:: convolve(y, C=None, Ck=None, factors=None)

      Return the periodic convolution `int(C(x-r)*y(r),r)`.

      Note: this is the 3D convolution.



.. py:class:: CylindricalBasis(Nxr, Lxr, axes=(-2, -1), symmetric_x=True, **_kw)

   Bases: :py:obj:`mmfutils.math.bases.CylindricalBasis`


   2D basis for Cylindrical coordinates via a DVR basis.

   This represents 3-dimensional problems with axial symmetry, but only has
   two dimensions (x, r).

   :param Nxr: Number of lattice points in basis.
   :type Nxr: (Nx, Nr)
   :param Lxr: Size of each dimension (length of box and radius)
   :type Lxr: (L, R)
   :param axes: Axes in array y which correspond to the x and r axes here.
                This is required for cases where y has additional dimensions.
                The default is the last two axes (best for performance).
   :type axes: (int, int)


   .. py:attribute:: xp


   .. py:method:: init()

      Initialize Object.



   .. py:method:: apply_exp_K(y, factor, factors=None, kx2=None, **_kw)

      Return `exp(K*factor)*y` or return precomputed data if
      `K_data` is `None`.



   .. py:method:: apply_K(y, factors=None, kx2=None, **_kw)

      Return `K*y` where `K = k**2/2`



   .. py:method:: fft(x)

      Perform the fft along the x axes



   .. py:method:: ifft(x)

      Perform the fft along the x axes



   .. py:method:: integrate1(n)

      Return the integral of n over y and z.



   .. py:method:: integrate2(n, y=None, Nz=100)

      Return the integral of n over z (line-of-sight integral) at y.

      This is an Abel transform, and is used to compute the 1D
      line-of-sight integral as would be seen by a photographic
      image through an axial cloud.

      :param n: (Nx, Nr) array of the function to be integrated tabulated
                on the abscissa.  Note: the extrapolation assumes that `n =
                abs(psi)**2` where `psi` is well represented in the basis.
      :type n: array
      :param y: Ny points at which the resulting integral should be
                returned.  If not provided, then the function will be
                tabulated at the radial abscissa.
      :type y: array, None
      :param Nz: Number of points to use in z integral.
      :type Nz: int



