Exemplo n.º 1
0
def riccati_psi_xi(x, nstop):
    '''
    Calculate Riccati-Bessel functions psi and xi for real argument.

    Parameters
    ----------
    x : float
        Argument
    nstop : int
        Maximum order to calculate to

    Returns
    -------
    ndarray(2, nstop)
        psi and xi

    Notes
    -----
    Uses upwards recursion.
    '''
    if np.imag(x) != 0.:
        raise TypeError('Cannot handle complex arguments.')
    psin = riccati_jn(nstop, x)
    # construct riccati hankel function of 1st kind by linear
    # combination of RB's based on j_n and y_n
    # scipy sign on y_n consistent with B/H
    xin = psin[0] + 1j*riccati_yn(nstop, x)[0]
    rbh = array([psin[0], xin])
    return rbh
Exemplo n.º 2
0
    def radial_sp(self,
                  radial,
                  theta,
                  phi,
                  radius=None,
                  M=2,
                  mu=1,
                  musp=1,
                  small=False):
        if not small or radius is None:
            max_it = self.max_it(radial)
        else:
            max_it = self.max_it(radius)

        riccati_terms = riccati_jn(max_it, M * self.wave_number * radial)[0]
        legendre_terms = lpmn(max_it, max_it, np.cos(theta))[0]
        nm_func = lambda n, m: n * (n + 1)
        pre_mul = self.e0 / np.power(radial, 2) / M**2 / self.wave_number
        mies = mie_cns(max_it, self.wave_number, radius, M, mu, musp)

        return self.component(radial,
                              theta,
                              phi,
                              riccati_terms,
                              legendre_terms,
                              pre_mul,
                              nm_func,
                              max_it,
                              mies=mies)
Exemplo n.º 3
0
    def phi_te_sp(self,
                  radial,
                  theta,
                  phi,
                  radius=None,
                  M=2,
                  mu=1,
                  musp=1,
                  small=False):
        if not small or radius is None:
            max_it = self.max_it(radial)
        else:
            max_it = self.max_it(radius)

        riccati_terms = riccati_jn(max_it, M * self.wave_number * radial)[0]
        legendre_terms = ltaumn(max_it, max_it, theta)
        nm_func = lambda n, m: 1
        pre_mul = 1j * self.e0 / radial / M**2 * musp / mu
        mies = mie_dns(max_it, self.wave_number, radius, M, mu, musp)

        return self.component(radial,
                              theta,
                              phi,
                              riccati_terms,
                              legendre_terms,
                              pre_mul,
                              nm_func,
                              max_it,
                              mies=mies,
                              mode="te")
Exemplo n.º 4
0
def riccati_psi_xi(x, nstop):
    '''
    Calculate Riccati-Bessel functions psi and xi for real argument.

    Parameters
    ----------
    x : float
        Argument
    nstop : int
        Maximum order to calculate to

    Returns
    -------
    ndarray(2, nstop)
        psi and xi

    Notes
    -----
    Uses upwards recursion.
    '''
    if np.imag(x) != 0.:
        raise TypeError('Cannot handle complex arguments.')
    psin = riccati_jn(nstop, x)
    # construct riccati hankel function of 1st kind by linear
    # combination of RB's based on j_n and y_n
    # scipy sign on y_n consistent with B/H
    xin = psin[0] + 1j * riccati_yn(nstop, x)[0]
    rbh = array([psin[0], xin])
    return rbh
Exemplo n.º 5
0
def riccati_psi_xi(x, nstop):
    if np.imag(x) != 0.:
        raise TypeError('Cannot handle complex arguments.')
    psin = riccati_jn(nstop, x)
    # construct riccati hankel function of 1st kind by linear
    # combination of RB's based on j_n and y_n
    # scipy sign on y_n consistent with B/H
    xin = psin[0] + 1j * riccati_yn(nstop, x)[0]
    rbh = array([psin[0], xin])
    return rbh
Exemplo n.º 6
0
def riccati_psi_xi(x, nstop):
    if np.imag(x) != 0.:
        raise TypeError('Cannot handle complex arguments.')
    psin = riccati_jn(nstop, x)
    # construct riccati hankel function of 1st kind by linear
    # combination of RB's based on j_n and y_n
    # scipy sign on y_n consistent with B/H
    xin = psin[0] + 1j*riccati_yn(nstop, x)[0]
    rbh = array([psin[0], xin])
    return rbh
Exemplo n.º 7
0
def b_n(x, m, n):
    return np.array([
        (riccati_jn(n, m * x)[0][-1] * riccati_jn(n, x)[1][-1] -
         m * riccati_jn(n, x)[0][-1] * riccati_jn(n, m * x)[1][-1]) /
        (riccati_jn(n, m * x)[0][-1] * riccati_yn(n, x)[1][-1] -
         m * riccati_jn(n, m * x)[1][-1] * riccati_yn(n, x)[0][-1])
        for x, m in zip(x, m)
    ])
Exemplo n.º 8
0
    def simple_Qext(self, m, x):
        max_n = self.get_num_iters(m, x)
        all_psi, all_psi_derivs = riccati_jn(max_n, x)

        jn = spherical_jn(range(max_n + 1), m*x)
        all_mx_vals = m * x * jn
        all_mx_derivs = jn + m * x * spherical_jn(range(max_n + 1), m * x, derivative=True)
        all_D = all_mx_derivs/all_mx_vals

        all_xi = all_psi - 1j * riccati_yn(max_n, x)[0]

        all_n = np.arange(1, max_n+1)

        all_a = ((all_D[1:]/m + all_n/x)*all_psi[1:] - all_psi[0:-1])/((all_D[1:]/m + all_n/x)*all_xi[1:] - all_xi[0:-1])
        all_b = ((m*all_D[1:] + all_n/x)*all_psi[1:] - all_psi[0:-1])/((m*all_D[1:] + all_n/x)*all_xi[1:] - all_xi[0:-1])

        all_terms = 2.0/x**2 * (2*all_n + 1) * (all_a + all_b).real
        Qext = np.sum(all_terms[~np.isnan(all_terms)])
        return Qext
Exemplo n.º 9
0
    def _radial_i(self, radial, theta, phi, radius=None, mode="TM"):
        if radius is None:
            max_it = self.max_it(radial)
        else:
            max_it = self.max_it(radius)

        riccati_terms = riccati_jn(max_it, self.wave_number * radial)[0]
        legendre_terms = lpmn(max_it, max_it, np.cos(theta))[0]
        nm_func = lambda n, m: n * (n + 1)
        pre_mul = self.f0 / self.wave_number / np.power(radial, 2)

        return self.component(radial,
                              theta,
                              phi,
                              riccati_terms,
                              legendre_terms,
                              pre_mul,
                              nm_func,
                              max_it,
                              mode=mode)
Exemplo n.º 10
0
def riccati_psi_xi(x, nstop):
    """
    Construct riccati hankel function of 1st kind by linear combination of
    RB's based on j_n and y_n
    """
    if np.imag(x) != 0.:
        # if x is complex, calculate spherical bessel functions and compute the
        # complex riccati-bessel solutions
        nstop_array = np.arange(0, nstop + 1)
        psin = spherical_jn(nstop_array, x) * x
        xin = psin + 1j * spherical_yn(nstop_array, x) * x
        rbh = array([psin, xin])
    else:
        x = x.real
        psin = riccati_jn(nstop, x)
        # scipy sign on y_n consistent with B/H
        xin = psin[0] + 1j * riccati_yn(nstop, x)[0]
        rbh = array([psin[0], xin])

    return rbh
Exemplo n.º 11
0
    def _phi_ty_i(self, radial, theta, phi, radius=None, mode="TE"):
        if radius is None:
            max_it = self.max_it(radial)
        else:
            max_it = self.max_it(radius)

        riccati_terms = riccati_jn(max_it, self.wave_number * radial)[0]
        legendre_terms = ltaumn(max_it, max_it, theta)
        nm_func = lambda n, m: 1
        pre_mul = 1j * self.f0 / radial

        return self.component(radial,
                              theta,
                              phi,
                              riccati_terms,
                              legendre_terms,
                              pre_mul,
                              nm_func,
                              max_it,
                              mode=mode)
Exemplo n.º 12
0
def radial_electric_i_tm(radial, theta, phi,
                              wave_number_k, degrees=[-1, 1],
                              bscs={}):
    """ Computes the radial component of incident electric field in TM mode.
    """
    result = 0
    n = 1

    max_it = get_max_it(radial, wave_number_k)
    riccati_term = riccati_jn(n, wave_number_k * radial)[0]

    while n <= max_it:
        for m in degrees:
            if n >= m:
                increment = plane_wave_coefficient(n, wave_number_k) \
                          * bscs[(n, m)] \
                          * riccati_term[n - 1] \
                          * legendre_p(n, abs(m), np.cos(theta)) \
                          * np.exp(1j * m * phi)
                result += increment
        n += 1

    return result / wave_number_k / radial ** 2
Exemplo n.º 13
0
 def eps(rho):
     jn = riccati_jn(n, rho)[0]
     yn = riccati_yn(n, rho)[0]
     hn = jn + 1j * yn
     return hn
Exemplo n.º 14
0
 def dpsi(rho):
     _, outp = riccati_jn(n, rho)
     return outp
Exemplo n.º 15
0
 def psi(rho):
     outp, _ = riccati_jn(n, rho)
     return outp
Exemplo n.º 16
0
 def deps(rho):
     d_jn = riccati_jn(n, rho)[1]
     d_yn = riccati_yn(n, rho)[1]
     d_hn = d_jn + 1j * d_yn
     return d_hn
Exemplo n.º 17
0
def _riccati_bessel_j(degree, argument):
    """ Riccati-Bessel function of first kind and derivative
    """
    return special.riccati_jn(degree, float(argument))
Exemplo n.º 18
0
def riccati_bessel_j(degree, argument):
    """ Riccati-Bessel function of first kind
    """
    return special.riccati_jn(degree, float(argument))[0]
Exemplo n.º 19
0
def d_riccati_bessel_j(degree, argument):
    """ Derivative of Riccati-Bessel function of first kind
    """
    return special.riccati_jn(degree, float(argument))[1]