Esempio n. 1
0
def test_tmatrix_spheroid_is_sphere(material, atol):
    """tmatrix of spheroid with aspect ratio 1 is equal to tmatrix of sphere"""
    sphere   = miepy.sphere([0,0,0], radius, material)
    spheroid = miepy.spheroid([0,0,0], radius, radius, material, tmatrix_lmax=4)

    T1 = sphere.compute_tmatrix(lmax, wavelength, eps_b)
    T2 = spheroid.compute_tmatrix(lmax, wavelength, eps_b)

    print(np.max(np.abs(T1-T2)))
    assert np.allclose(T1, T2, rtol=0, atol=atol)
Esempio n. 2
0
def test_tmatrix_sphere_is_sphere(material, atol):
    """tmatrix method with spheres should be equivalent to sphere cluster"""

    position = [[-300*nm, 0, 0], [300*nm, 0, 0]]

    spheres = miepy.sphere_cluster(position=position,
                                   radius=radius,
                                   material=material,
                                   source=source,
                                   wavelength=wavelength,
                                   lmax=lmax,
                                   medium=medium)

    particles = [miepy.sphere(pos, radius, material) for pos in position]

    cluster = miepy.cluster(particles=particles,
                            source=source,
                            wavelength=wavelength,
                            lmax=lmax,
                            medium=medium)

    print(np.max(np.abs(spheres.p_inc - cluster.p_inc)))
    assert np.allclose(spheres.p_inc, cluster.p_inc, rtol=0, atol=atol)
Esempio n. 3
0
    T = -np.einsum('aibj,bjck->aick', Q11, np.linalg.tensorinv(Q31))

    return T


nm = 1e-9

lmax = 4

wavelength = 600 * nm
radius = 60 * nm
eps = 4

material = miepy.constant_material(eps)
sphere = miepy.sphere([0, 0, 0], radius, material)
T = sphere.compute_tmatrix(lmax, wavelength, 1)
# print(T[0,:,0,0])

theta = np.linspace(0, np.pi, 80)
phi = np.linspace(0, 2 * np.pi, 80)
THETA, PHI = np.meshgrid(theta, phi, indexing='ij')
rhat, that, phat = miepy.coordinates.sph_basis_vectors(THETA, PHI)
dS = rhat * np.sin(THETA) * radius**2

# T = get_tmatrix(radius, dS, eps, 1, wavelength, lmax)
# print(T[0,:,0,0])


def ellipsoid_dS(a, b, c, theta, phi):
    rad = 1 / np.sqrt(
Esempio n. 4
0
import matplotlib.pyplot as plt
from miepy.materials import material
from miepy import sphere

#wavelength from 400nm to 1000nm
wav = np.linspace(300,1100,1000)

#create a material with n = 3.7 (eps = n^2) at all wavelengths
eps = 1.7**2*np.ones(1000)
mu = 1*np.ones(1000)
dielectric = material(wav,eps,mu)     #material object

#calculate scattering coefficients
rad = 20       # 100 nm radius
Nmax = 1       # Use up to 10 multipoles
m = sphere(Nmax, dielectric, rad)

E_func = m.E_field(999)
H_func = m.H_field(999)

E = -1*E_func(R,THETA,PHI)
H = -H_func(R,THETA,PHI)

E = 

E = np.squeeze(E)
Ex = E[0]*np.sin(THETA)*np.cos(PHI) + E[1]*np.cos(THETA)*np.cos(PHI) - E[2]*np.sin(PHI)
Ey = E[0]*np.sin(THETA)*np.sin(PHI) + E[1]*np.cos(THETA)*np.sin(PHI) + E[2]*np.cos(PHI)
Ez = E[0]*np.cos(THETA) - E[1]*np.sin(THETA)

H = np.squeeze(H)
Esempio n. 5
0
import matplotlib.pyplot as plt
from miepy.materials import material
from miepy import sphere

#wavelength from 400nm to 1000nm
wav = np.linspace(400, 1000, 1000)

#create a material with n = 3.7 (eps = n^2) at all wavelengths
eps = 3.7**2 * np.ones(1000)
mu = 1 * np.ones(1000)
dielectric = material(wav, eps, mu)  #material object

#calculate scattering coefficients
rad = 100  # 100 nm radius
Nmax = 10  # Use up to 10 multipoles
m = sphere(Nmax, dielectric, rad)  #scattering object

# Figure 1: Scattering and Absorption
plt.figure(1)
plt.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
C, A = m.scattering()  # Returns scat,absorp arrays
plt.plot(m.wav, C, label="Scattering", linewidth=2)
plt.plot(m.wav, A, label="Absorption", linewidth=2)
plt.legend()
plt.xlabel("Wavelength (nm)")
plt.ylabel("Scattering Intensity")

# Figure 2: Scattering per multipole
plt.figure(2)
plt.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
plt.plot(m.wav, C, label="Total", linewidth=2)  #plot total scattering