def scatcoeffs(m, x, nstop): # see B/H eqn 4.88 # implement criterion used by BHMIE plus a couple more orders to # be safe nmx = int(array([nstop, np.round_(np.absolute(m*x))]).max()) + 20 Dnmx = mie_specfuncs.log_der_1(m*x, nmx, nstop) n = np.arange(nstop+1) psi, xi = mie_specfuncs.riccati_psi_xi(x, nstop) psishift = np.concatenate((np.zeros(1), psi))[0:nstop+1] xishift = np.concatenate((np.zeros(1), xi))[0:nstop+1] an = ( (Dnmx/m + n/x)*psi - psishift ) / ( (Dnmx/m + n/x)*xi - xishift ) bn = ( (Dnmx*m + n/x)*psi - psishift ) / ( (Dnmx*m + n/x)*xi - xishift ) return array([an[1:nstop+1], bn[1:nstop+1]]) # output begins at n=1
def scatcoeffs(m, x, nstop): # see B/H eqn 4.88 # implement criterion used by BHMIE plus a couple more orders to # be safe nmx = int(array([nstop, np.round_(np.absolute(m * x))]).max()) + 20 Dnmx = mie_specfuncs.log_der_1(m * x, nmx, nstop) n = np.arange(nstop + 1) psi, xi = mie_specfuncs.riccati_psi_xi(x, nstop) psishift = np.concatenate((np.zeros(1), psi))[0:nstop + 1] xishift = np.concatenate((np.zeros(1), xi))[0:nstop + 1] an = ((Dnmx / m + n / x) * psi - psishift) / ( (Dnmx / m + n / x) * xi - xishift) bn = ((Dnmx * m + n / x) * psi - psishift) / ( (Dnmx * m + n / x) * xi - xishift) return array([an[1:nstop + 1], bn[1:nstop + 1]]) # output begins at n=1
def internal_coeffs(m, x, n_max): ''' Calculate internal Mie coefficients c_n and d_n given relative index, size parameter, and maximum order of expansion. Follow Bohren & Huffman's convention. Note that van de Hulst and Kerker have different conventions (labeling of c_n and d_n and factors of m) for their internal coefficients. ''' ratio = mie_specfuncs.R_psi(x, m * x, n_max) D1x, D3x = mie_specfuncs.log_der_13(x, n_max) D1mx = mie_specfuncs.log_der_1(m * x, n_max + 15, n_max) cl = m * ratio * (D3x - D1x) / (D3x - m * D1mx) dl = m * ratio * (D3x - D1x) / (m * D3x - D1mx) return array([cl[1:], dl[1:]]) # start from l = 1