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) ])
def phi_te_s(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_yn(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.e0 / radial mies = mie_bns(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")
def radial_s(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) if radial <= radius: return 0 riccati_terms = riccati_yn(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.e0 / self.wave_number / np.power(radial, 2) mies = mie_ans(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)
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
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
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
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
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
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
def eps(rho): jn = riccati_jn(n, rho)[0] yn = riccati_yn(n, rho)[0] hn = jn + 1j * yn return hn
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
def d_riccati_bessel_y(degree, argument): """ Derivative of Riccati-Bessel function of second kind """ return special.riccati_yn(degree, float(argument))[1]
def riccati_bessel_y(degree, argument): """ Riccati-Bessel function of second kind """ return special.riccati_yn(degree, float(argument))[0]