sbt#

Spherical Bessel Transform.

The code is adapted from PySBT. It is not differentiable.

PySBT can be found: QijingZheng/pySBT.git

jrystal.sbt.batched_sbt(r_grid: Float[Array, 'ngrid'], f_grid: Float[Array, 'nbatch ngrid'], l: int | List[int], kmax: float = 100, norm: bool = False) Tuple[source]#

batched spherical bessel transform for multiple functions.

sbt: g(k) = int_0^infty f(r) j_l(r) r^2 dr

Parameters:
  • r_grid (Float[Array, "ngrid"]) – the r grid corresponding to the function.

  • f_grid (Float[Array, "nbatch ngrid"]) – a batch of the function values.

  • l (Union[int, List[int]]) – Angular momentum. If l is a list, the length must be the same as the number of batches.

  • kmax (float, optional) – Maximum k value. Defaults to 100.

  • norm (bool, optional) – Whether to normalize the output. Defaults to False.

Returns:

A tuple of (k_grid, batched_transformed_f_grid). k_grid is a 1d-array, and batched_transformed_f_grid is BxN shaped, where B is the number of batches and N is the number of grid point.

Return type:

Tuple

class jrystal.sbt.pyNumSBT(rr, kmax: float = 500, lmax: int = 10)[source]#

Numerically perform spherical Bessel transform (SBT) in \(O(Nln(N))\) time based on the algorithm proposed by J. Talman.

Talman, J. Computer Physics Communications 2009, 180, 332-338.

For a function “f(r)” defined numerically on a LOGARITHMIC radial grid “r”, the SBT for the function gives

\[g(k) = \sqrt{2\over\pi} \int_0^\infty j_l(kr) f(r) r^2 dr (c1)\]

and the inverse SBT (iSBT) gives

\[f(r) = \sqrt{2\over\pi} \int_0^\infty j_l(kr) g(k) k^2 dk (c2)\]
run(ff, l: int = 0, direction: int = 1, norm: bool = False, np_in: int = 0, return_rr: bool = False, include_zero: bool = False)[source]#

Perform SBT or inverse-SBT.

Input parapeters:

ff: the function defined on the logarithmic radial grid l: the “l” as in the underscript of “j_l(kr)” of Eq. (c1) and (c2) direction: 1 for forward SBT and -1 for inverse SBT norm: whether to multiply the prefactor sqrt{2overpi} in Eq. (c1) and

(c2). If False, then subsequent applicaton of SBT and iSBT will yield the original data scaled by a factor of 2/pi.

np_in: the asymptotic bahavior of ff when r -> 0

ff(r o 0) pprox r^{np_in + l}

include_zero: the SBT does not include the k = 0, i.e.

self.kk.min() != 0, term by default.

run_int(ff, l: int = 0, direction: int = 1, norm: bool = False, return_rr: bool = False, include_zero: bool = False)[source]#

Perform SBT or inverse-SBT by numerically integrating Eq. (c1) and (c2). Input parapeters: ff: the function defined on the logarithmic radial grid l: the “l” as in the underscript of “j_l(kr)” of Eq. (c1) and (c2) direction: 1 for forward SBT and -1 for inverse SBT norm: whether to multiply the prefactor sqrt{2overpi} in Eq. (c1) and (c2). If False, then subsequent applicaton of SBT and iSBT will yield the original data scaled by a factor of 2/pi. include_zero: the SBT does not include the k = 0, i.e. self.kk.min() != 0, term by default.

sbt_init(rr, kmax: float)[source]#

Initialize the real-space grid (rr) and momentum-space grid (kk).

\[\rho = \ln(rr) \kappa = \ln(kk)\]

The algorithm by Talman requries

\[\Delta\kappa = \Delta\rho\]
sbt_mltb(lmax_in: int)[source]#

construct the M_l(t) table according to Eq. (15), (16) and (24) of Talman paper.

Note that Talman paper use Stirling’s approximaton to evaluate the Gamma function, whereas I just call scipy.special.gamma here.

jrystal.sbt.sbt(r_grid: Float[Array, 'num_r'], f_grid: Float[Array, 'num_r'], l: int = 0, kmax: float = 100, norm: bool = False) Tuple[Float[Array, 'num_r'], Float[Array, 'num_r']][source]#

Spherical Bessel Transform.

..math::

g(k) = int_0^infty f(r) j_l(r) r^2 dr

Warning

This function is a wrapper of pysbt. It is not differentiable.

Parameters:
  • r_grid (Float[Array, "num_r"]) – the r grid corresponding to the function.

  • f_grid (Float[Array, "num_r"]) – the function values.

  • l (int, optional) – Angular momentum. Defaults to 0.

  • kmax (float, optional) – Maximum k value. Defaults to 100.

  • norm (bool, optional) – Whether to normalize the output. Defaults to False.

Returns:

A tuple of (k_grid,

transformed_f_grid). k_grid is a 1d-array, and transformed_f_grid is the transformed function values.

Return type:

Tuple[Float[Array, “num_r”], Float[Array, “num_r”]]