pystella/fourier/rayleigh.py
def generate_WKB(self, queue, random=True,
                     field_ps=lambda wk: 1/2/wk,
                     norm=1, omega_k=lambda kmag: kmag,
                     hubble=0., window=lambda kmag: 1.):
        """
        Generate a 3-D array of Fourier modes with a given power spectrum and
        random phases, along with that of its time derivative
        according to the WKB approximation (for Klein-Gordon fields in
        conformal FLRW spacetime).

        Arguments match those of :meth:`generate`, with the following
        exceptions/additions:

        :arg field_ps: A :class:`~collections.abc.Callable` returning the desired
            power spectrum of the field as a function of :math:`\\omega(k)``.
            Defaults to the Bunch-Davies vacuum, ``lambda wk: 1/2/wk``,
            where ``wk=omega_k(kmag)``.

        :arg omega_k: A :class:`~collections.abc.Callable` defining the
            dispersion relation of the field.
            Defaults to ``lambda kmag: kmag``.

        :arg hubble: The value of the (conformal) Hubble parameter to use in
            generating modes for the field's time derivative.
            Only used when ``WKB=True``.
            Defaults to ``0``.

        :returns: A tuple ``(fk, dfk)`` containing the generated Fourier modes
            of the field and its time derivative.
        """

        amplitude_sq = norm / self.volume
        kshape = self.kmags.shape

        rands = self.rng.uniform(queue, (4,)+kshape, self.rdtype)
        if not random:
            rands[0] = rands[2] = np.exp(-1)

        wk = omega_k(self.kmags)
        f_power = (amplitude_sq * window(self.kmags)**2
                   * self._ps_wrapper(field_ps, wk, self.kmags))

        evt, out = self.wkb_knl(queue, rands=rands, hubble=hubble,
                                wk=wk, f_power=f_power, out_host=True)

        fk = self._post_process(out["fk"])
        dfk = self._post_process(out["dfk"])

        return fk, dfk

        Generate a 3-D array of Fourier modes with a given power spectrum and
        random phases, along with that of its time derivative
        according to the WKB approximation (for Klein-Gordon fields in
        conformal FLRW spacetime).

        Arguments match those of :meth:`generate`, with the following
        exceptions/additions:

        :arg field_ps: A :class:`~collections.abc.Callable` returning the desired
            power spectrum of the field as a function of :math:`\\omega(k)``.
            Defaults to the Bunch-Davies vacuum, ``lambda wk: 1/2/wk``,
            where ``wk=omega_k(kmag)``.

        :arg omega_k: A :class:`~collections.abc.Callable` defining the
            dispersion relation of the field.
            Defaults to ``lambda kmag: kmag``.

        :arg hubble: The value of the (conformal) Hubble parameter to use in
            generating modes for the field's time derivative.
            Only used when ``WKB=True``.
            Defaults to ``0``.

        :returns: A tuple ``(fk, dfk)`` containing the generated Fourier modes
            of the field and its time derivative.
        
Generate a 3-D array of Fourier modes with a given power spectrum and
random phases, along with that of its time derivative
according to the WKB approximation (for Klein-Gordon fields in
conformal FLRW spacetime).

Arguments match those of :meth:`generate`, with the following
exceptions/additions.
Generate a 3 - D array of Fourier modes with a given power spectrum and random phases along with that of its time derivative according to the WKB approximation ( for Klein - Gordon fields in conformal FLRW spacetime ) . Arguments match those of : meth : ` generate ` with the following exceptions / additions .
def generate_WKB(self, queue, random=True,
                     field_ps=lambda wk: 1/2/wk,
                     norm=1, omega_k=lambda kmag: kmag,
                     hubble=0., window=lambda kmag: 1.):
        amplitude_sq = norm / self.volume
        kshape = self.kmags.shape
        rands = self.rng.uniform(queue, (4,)+kshape, self.rdtype)
        if not random:
            rands[0] = rands[2] = np.exp(-1)
        wk = omega_k(self.kmags)
        f_power = (amplitude_sq * window(self.kmags)**2
                   * self._ps_wrapper(field_ps, wk, self.kmags))
        evt, out = self.wkb_knl(queue, rands=rands, hubble=hubble,
                                wk=wk, f_power=f_power, out_host=True)
        fk = self._post_process(out["fk"])
        dfk = self._post_process(out["dfk"])
        return fk, dfk
def generate_WKB ( self , queue , random = True , field_ps = lambda wk : 1 / 2 / wk , norm = 1 , omega_k = lambda kmag : kmag , hubble = 0. , window = lambda kmag : 1. ) : amplitude_sq = norm / self . volume kshape = self . kmags . shape rands = self . rng . uniform ( queue , ( 4 , ) + kshape , self . rdtype ) if not random : rands [ 0 ] = rands [ 2 ] = np . exp ( - 1 ) wk = omega_k ( self . kmags ) f_power = ( amplitude_sq * window ( self . kmags ) ** 2 * self . _ps_wrapper ( field_ps , wk , self . kmags ) ) evt , out = self . wkb_knl ( queue , rands = rands , hubble = hubble , wk = wk , f_power = f_power , out_host = True ) fk = self . _post_process ( out [ "fk" ] ) dfk = self . _post_process ( out [ "dfk" ] ) return fk , dfk
Generate a 3-D array of Fourier modes with a given power spectrum and
random phases, along with that of its time derivative
according to the WKB approximation (for Klein-Gordon fields in
conformal FLRW spacetime).
Generate a 3 - D array of Fourier modes with a given power spectrum and random phases along with that of its time derivative according to the WKB approximation ( for Klein - Gordon fields in conformal FLRW spacetime ) .
"""
        Generate a 3-D array of Fourier modes with a given power spectrum and
        random phases, along with that of its time derivative
        according to the WKB approximation (for Klein-Gordon fields in
        conformal FLRW spacetime).

        Arguments match those of :meth:`generate`, with the following
        exceptions/additions:

        :arg field_ps: A :class:`~collections.abc.Callable` returning the desired
            power spectrum of the field as a function of :math:`\\omega(k)``.
            Defaults to the Bunch-Davies vacuum, ``lambda wk: 1/2/wk``,
            where ``wk=omega_k(kmag)``.

        :arg omega_k: A :class:`~collections.abc.Callable` defining the
            dispersion relation of the field.
            Defaults to ``lambda kmag: kmag``.

        :arg hubble: The value of the (conformal) Hubble parameter to use in
            generating modes for the field's time derivative.
            Only used when ``WKB=True``.
            Defaults to ``0``.

        :returns: A tuple ``(fk, dfk)`` containing the generated Fourier modes
            of the field and its time derivative.
        """
A tuple ``(fk, dfk)`` containing the generated Fourier modes
of the field and its time derivative.
A tuple ` ` ( fk dfk ) ` ` containing the generated Fourier modes of the field and its time derivative .
self
queue
random
field_ps
A :class:`~collections.abc.Callable` returning the desired
power spectrum of the field as a function of :math:`\\omega(k)``.
Defaults to the Bunch-Davies vacuum, ``lambda wk: 1/2/wk``,
where ``wk=omega_k(kmag)``.
A : class : ` ~collections . abc . Callable ` returning the desired power spectrum of the field as a function of : math : ` \\ omega ( k ) ` ` . Defaults to the Bunch - Davies vacuum ` ` lambda wk : 1 / 2 / wk ` ` where ` ` wk = omega_k ( kmag ) ` ` .
norm
omega_k
A :class:`~collections.abc.Callable` defining the
dispersion relation of the field.
Defaults to ``lambda kmag: kmag``.
A : class : ` ~collections . abc . Callable ` defining the dispersion relation of the field . Defaults to ` ` lambda kmag : kmag ` ` .
hubble
The value of the (conformal) Hubble parameter to use in
generating modes for the field's time derivative.
Only used when ``WKB=True``.
The value of the ( conformal ) Hubble parameter to use in generating modes for the field ' s time derivative . Only used when ` ` WKB = True ` ` .
window