![]() |
QPMS
Electromagnetic multiple scattering library and toolkit.
|
Functions | |
| def | cart2sph (cart, axis=-1, allow2d=False) |
| def | sph2cart (sph, axis=-1) |
| def | sph_loccart2cart (loccart, sph, axis=-1) |
| def | sph_loccart_basis (sph, sphaxis=-1, cartaxis=None) |
| def | nelem2lMax (nelem) |
| def | lMax2nelem (lMax) |
| def | lpy (nmax, z) |
| def | lpy1 (nmax, z) |
| def | vswf_yr (pos_sph, lMax, J=1) |
| def | zJn (n, z, J=1) |
| def | π̃_zerolim (nmax) |
| def | π̃_pilim (nmax) |
| def | τ̃_zerolim (nmax) |
| def | τ̃_pilim (nmax) |
| def | get_π̃τ̃_y1 (θ, nmax) |
| def | vswf_yr1 (pos_sph, nmax, J=1) |
| def | zplane_pq_y (nmax, betap=0) |
| def | plane_pq_y (nmax, kdir_cart, E_cart) |
| def | ε_drude (ε_inf, ω_p, γ_p, ω) |
| def | mie_coefficients (a, nmax, k_i, k_e, μ_i=1, μ_e=1, J_ext=1, J_scat=3) |
| def | G_Mie_scat_precalc_cart_new (source_cart, dest_cart, RH, RV, a, nmax, k_i, k_e, μ_i=1, μ_e=1, J_ext=1, J_scat=3) |
| def | Grr_Delga (nmax, a, r, k, ε_m, ε_b) |
| def | G0_dip_1 (r_cart, k) |
| def | G0_analytical (r, k) |
| def | G0L_analytical (r, k) |
| def | G0T_analytical (r, k) |
| def | G0_sum_1_slow (source_cart, dest_cart, k, nmax) |
| def | loadWfile (fileName, lMax=None, fatForm=True, nparticles=2) |
| def | processWfiles_sameKs (freqfilenames, destfilename, nparticles=2, lMax=None, f='npz') |
| def | loadWfile_info (fileName, lMax=None, midk_halfwidth=None, freqlimits=None) |
| def | loadWfile_processed (fileName, lMax=None, fatForm=True, midk_halfwidth=None, midk_index=None, freqlimits=None, iteratechunk=None) |
Variables | |
| ň = np.newaxis | |
| eV = e | |
This file contains mostly legacy code, but is still kept for reference. Avoid using this.
| def qpms.qpms_p.G0_dip_1 | ( | r_cart, | |
| k | |||
| ) |
Free-space dyadic Green's function in terms of the spherical vector waves. FIXME
| def qpms.qpms_p.G_Mie_scat_precalc_cart_new | ( | source_cart, | |
| dest_cart, | |||
| RH, | |||
| RV, | |||
| a, | |||
| nmax, | |||
| k_i, | |||
| k_e, | |||
μ_i = 1, |
|||
μ_e = 1, |
|||
J_ext = 1, |
|||
J_scat = 3 |
|||
| ) |
Implementation according to Kristensson, page 50 My (Taylor's) basis functions are normalized to n*(n+1), whereas Kristensson's to 1 TODO: check possible -1 factors (cf. Kristensson's dagger notation)
| def qpms.qpms_p.get_π̃τ̃_y1 | ( | θ, | |
| nmax | |||
| ) |
(... TODO)
| def qpms.qpms_p.loadWfile | ( | fileName, | |
lMax = None, |
|||
fatForm = True, |
|||
nparticles = 2 |
|||
| ) |
Load the translation operator lattice sums generated by hexlattice_ewald.c fatForm has different indices (so that it can be easily multiplied with T-Matrix and twice the size.
| def qpms.qpms_p.loadWfile_info | ( | fileName, | |
lMax = None, |
|||
midk_halfwidth = None, |
|||
freqlimits = None |
|||
| ) |
Returns all the relevant data from the W file except for the W values themselves
| def qpms.qpms_p.loadWfile_processed | ( | fileName, | |
lMax = None, |
|||
fatForm = True, |
|||
midk_halfwidth = None, |
|||
midk_index = None, |
|||
freqlimits = None, |
|||
iteratechunk = None |
|||
| ) |
midk_halfwidth: int
if given, takes only the "middle" k-value by index nk//2 and midk_halfwidth values from both sides
midk_index: int
if given, midk_index is taken as the "middle" value instad of nk//2
freqlimit: pair of doubles;
if given, only the values from the given frequency range (in Hz) are returned to save RAM
N.B.: the frequencies in the processed file are expected to be sorted!
iteratechunk: positive int ; NI
if given, this works as a generator with only iteratechunk frequencies processed and returned at each iteration to save memory
| def qpms.qpms_p.lpy1 | ( | nmax, | |
| z | |||
| ) |
Associated legendre function and its derivatative at z in the 'y-indexing'.
(Without Condon-Shortley phase AFAIK.)
NOT THOROUGHLY TESTED
Parameters
----------
nmax: int
The maximum order to which the Legendre functions will be evaluated..
z: float
The point at which the Legendre functions are evaluated.
output: (P_y, dP_y) TODO
y-indexed legendre polynomials and their derivatives
| def qpms.qpms_p.mie_coefficients | ( | a, | |
| nmax, | |||
| k_i, | |||
| k_e, | |||
μ_i = 1, |
|||
μ_e = 1, |
|||
J_ext = 1, |
|||
J_scat = 3 |
|||
| ) |
FIXME test the magnetic case
TODO description
RH concerns the N ("electric") part, RV the M ("magnetic") part
#
Parameters
----------
a : float
Diameter of the sphere.
nmax : int
To which order (inc. nmax) to compute the coefficients.
ω : float
Frequency of the radiation
ε_i, ε_e, μ_i, μ_e : complex
Relative permittivities and permeabilities of the sphere (_i)
and the environment (_e)
MAGNETIC (μ_i, μ_e != 1) CASE UNTESTED AND PROBABLY BUGGY
J_ext, J_scat : 1, 2, 3, or 4 (must be different)
Specifies the species of the Bessel/Hankel functions in which
the external incoming (J_ext) and scattered (J_scat) fields
are represented. 1,2,3,4 correspond to j,y,h(1),h(2), respectively.
The returned coefficients are always with respect to the decomposition
of the "external incoming" wave.
Returns
-------
RV == a/p, RH == b/q, TV = d/p, TH = c/q
TODO
what does it return on index 0???
FIXME permeabilities
| def qpms.qpms_p.nelem2lMax | ( | nelem | ) |
Auxiliary inverse function to nelem(lMax) = (lMax + 2) * lMax. Returns 0 if it nelem does not come from positive integer lMax.
| def qpms.qpms_p.plane_pq_y | ( | nmax, | |
| kdir_cart, | |||
| E_cart | |||
| ) |
The plane wave expansion coefficients for any direction kdir_cart
and amplitude vector E_cart (which might be complex, depending on
the phase and polarisation state). If E_cart and kdir_cart are
not orthogonal, the result should correspond to the k-normal part
of E_cart.
The Taylor's convention on the expansion is used; therefore,
the electric field is expressed as
E(r) = E_cart * exp(1j * k ∙ r)
= -1j * ∑_y ( p_y * Ñ_y(|k| * r) + q_y * M̃_y(|k| * r))
(note the -1j factor).
Parameters
----------
nmax: int
The order of the expansion.
kdir_cart: (...,3)-shaped real array
The wave vector (its magnitude does not play a role).
E_cart: (...,3)-shaped complex array
Amplitude of the plane wave
Returns
-------
p_y, q_y:
The expansion coefficients for the electric (Ñ) and magnetic
(M̃) waves, respectively.
| def qpms.qpms_p.processWfiles_sameKs | ( | freqfilenames, | |
| destfilename, | |||
nparticles = 2, |
|||
lMax = None, |
|||
f = 'npz' |
|||
| ) |
Processes translation operator data in different files; each file is supposed to contain one frequency. The Ks in the different files are expected to be exactly the same and in the same order; the result is sorted by frequencies and saved to npz file; The representation is always "thin", i.e. the elements which are zero due to z-symmetry are skipped F is either 'npz' or 'd' 'npz' creates npz archive, 'd' creates a directory with individual npy files, where the W-matrix data are writen using memmap.
| def qpms.qpms_p.sph_loccart2cart | ( | loccart, | |
| sph, | |||
axis = -1 |
|||
| ) |
Transformation of vector specified in local orthogonal coordinates
(tangential to spherical coordinates – basis r̂,θ̂,φ̂) to global cartesian
coordinates (basis x̂,ŷ,ẑ)
SLOW FOR SMALL ARRAYS
Parameters
----------
loccart: ... TODO
the transformed vector in the local orthogonal coordinates
sph: ... TODO
the point (in spherical coordinates) at which the locally
orthogonal basis is evaluated
Returns
-------
output: ... TODO
The coordinates of the vector in global cartesian coordinates
| def qpms.qpms_p.sph_loccart_basis | ( | sph, | |
sphaxis = -1, |
|||
cartaxis = None |
|||
| ) |
Returns the local cartesian basis in terms of global cartesian basis. sphaxis refers to the original dimensions TODO doc
| def qpms.qpms_p.vswf_yr | ( | pos_sph, | |
| lMax, | |||
J = 1 |
|||
| ) |
Normalized vector spherical wavefunctions $\widetilde{M}_{mn}^{j}$,
$\widetilde{N}_{mn}^{j}$ as in [1, (2.40)].
Parameters
----------
pos_sph : np.array(dtype=float, shape=(someshape,3))
The positions where the spherical vector waves are to be
evaluated. The last axis corresponds to the individual
points (r,θ,φ). The radial coordinate r is dimensionless,
assuming that it has already been multiplied by the
wavenumber.
nmax : int
The maximum order to which the VSWFs are evaluated.
Returns
-------
output : np.array(dtype=complex, shape=(someshape,nmax*nmax + 2*nmax,3))
Spherical vector wave functions evaluated at pos_sph,
in the local basis (r̂,θ̂,φ̂). The last indices correspond
to m, n (in the ordering given by mnindex()), and basis
vector index, respectively.
[1] Jonathan M. Taylor. Optical Binding Phenomena: Observations and
Mechanisms.
| def qpms.qpms_p.vswf_yr1 | ( | pos_sph, | |
| nmax, | |||
J = 1 |
|||
| ) |
As vswf_yr, but evaluated only at single position (i.e. pos_sph has to have shape=(3))
| def qpms.qpms_p.zplane_pq_y | ( | nmax, | |
betap = 0 |
|||
| ) |
The z-propagating plane wave expansion coefficients as in [1, (1.12)] Taylor's normalization (... TODO)
| def qpms.qpms_p.π̃_pilim | ( | nmax | ) |
lim_{θ→ π+} π̃(cos θ)
| def qpms.qpms_p.π̃_zerolim | ( | nmax | ) |
lim_{θ→ 0-} π̃(cos θ)
| def qpms.qpms_p.τ̃_pilim | ( | nmax | ) |
lim_{θ→ π+} τ̃(cos θ)
| def qpms.qpms_p.τ̃_zerolim | ( | nmax | ) |
lim_{θ→ 0-} τ̃(cos θ)