Pseudovectorised version of qpms_p.vswf_yr()

Former-commit-id: 00f32b599dc087369fa99eb1bf9207d9901897c2
This commit is contained in:
Marek Nečada 2017-07-20 17:03:18 +03:00
parent e0b1b3af55
commit 46c67a548e
2 changed files with 12 additions and 11 deletions

View File

@ -7,4 +7,6 @@ LMAXVAR - besides to int, the function should support an iterable for the lMax a
VECTORIZE - add support to process more than one element at once, in general. VECTORIZE - add support to process more than one element at once, in general.
TRUEVECTORIZE - remove inner python loops to speed things up
FEATURE - non-urgent general feature to implement FEATURE - non-urgent general feature to implement

View File

@ -217,7 +217,7 @@ def lpy(nmax, z):
dP_y[mn_n_y[mn_minus_mask]] = dpmn_minus[mn_minus_mask] dP_y[mn_n_y[mn_minus_mask]] = dpmn_minus[mn_minus_mask]
return (P_y, dP_y) return (P_y, dP_y)
def vswf_yr(pos_sph,nmax,J=1): def vswf_yr(pos_sph,lMax,J=1):
""" """
Normalized vector spherical wavefunctions $\widetilde{M}_{mn}^{j}$, Normalized vector spherical wavefunctions $\widetilde{M}_{mn}^{j}$,
$\widetilde{N}_{mn}^{j}$ as in [1, (2.40)]. $\widetilde{N}_{mn}^{j}$ as in [1, (2.40)].
@ -247,16 +247,14 @@ def vswf_yr(pos_sph,nmax,J=1):
[1] Jonathan M. Taylor. Optical Binding Phenomena: Observations and [1] Jonathan M. Taylor. Optical Binding Phenomena: Observations and
Mechanisms. Mechanisms.
""" """
#mi, ni = mnindex(nmax) # TODO TRUEVECTORIZE
#nelems = nmax*nmax + 2*nmax pos_sph = np.array(pos_sph, copy = False)
## TODO Remove these two lines in production: nelem = (lMax + 2) * lMax
#if(len(mi) != nelems): M_y = np.empty(pos_sph.shape[:-1] + (nelem,3), dtype = np.complex_)
# raise ValueError("This is very wrong.") N_y = np.empty(pos_sph.shape[:-1] + (nelem,3), dtype = np.complex_)
## Pre-calculate the associated Legendre function for i in np.ndindex(pos_sph.shape[:-1]):
#Prmn, dPrmn = lpmn(nmax,nmax,) M_y[i], N_y[i] = vswf_yr1(pos_sph[i], lMax, J) # non-vectorised function
## Normalized funs π̃, τ̃ return (M_y, N_y)
#π̃ =
pass
from scipy.special import sph_jn, sph_yn from scipy.special import sph_jn, sph_yn
#@jit #@jit
@ -477,6 +475,7 @@ def plane_pq_y(nmax, kdir_cart, E_cart):
The expansion coefficients for the electric (Ñ) and magnetic The expansion coefficients for the electric (Ñ) and magnetic
(M̃) waves, respectively. (M̃) waves, respectively.
""" """
# TODO TRUEVECTORIZE
if np.iscomplexobj(kdir_cart): if np.iscomplexobj(kdir_cart):
warnings.warn("The direction vector for the plane wave coefficients should be real. I am discarding the imaginary part now.") warnings.warn("The direction vector for the plane wave coefficients should be real. I am discarding the imaginary part now.")
kdir_cart = kdir_cart.real kdir_cart = kdir_cart.real