def test_ellipsoid_equal_spheroid_z_oriented(): """An (rx, ry, rz) ellipsoid should equal a z-oriented (rxy, rz) spheroid""" e = miepy.spheroid([0, 0, 0], rx, rz, material) T1 = e.compute_tmatrix(lmax, wavelength, 1.0) e = miepy.ellipsoid([0, 0, 0], rx, ry, rz, material) T2 = e.compute_tmatrix(lmax, wavelength, 1.0) assert np.allclose(T1, T2, atol=2e-5)
def test_ellipsoid_equal_spheroid_y_oriented(): """An (rx, rz, ry) ellipsoid should equal a y-oriented (rxy, rz) spheroid""" q = miepy.quaternion.from_spherical_coords(np.pi / 2, np.pi / 2) e = miepy.spheroid([0, 0, 0], rx, rz, material, orientation=q) T1 = e.compute_tmatrix(lmax, wavelength, 1.0) e = miepy.ellipsoid([0, 0, 0], rx, rz, ry, material) T2 = e.compute_tmatrix(lmax, wavelength, 1.0) assert np.allclose(T1, T2, atol=5e-5)
def gmt_sim(): wavelengths = np.linspace(400 * nm, 1000 * nm, 100) eps = meep_ext.get_eps(material)(wavelengths) Au = miepy.data_material(wavelengths, eps) Au = miepy.constant_material(3.5**2) C, A, E = [np.zeros_like(wavelengths) for i in range(3)] particles = [] # orientation = miepy.quaternion.from_spherical_coords(theta[i], phi[i]) particles.append( miepy.ellipsoid([0, 0, 0], rx, ry, rz, material=Au, orientation=q)) for i, wavelength in enumerate(tqdm(wavelengths)): sol = miepy.cluster(particles=particles, source=miepy.sources.plane_wave([1, 0]), wavelength=wavelength, lmax=3) C[i], A[i], E[i] = sol.cross_sections() return dict(wavelengths=wavelengths, C=C, A=A, E=E)
1 / a**2) rhat, that, phat = miepy.coordinates.sph_basis_vectors(theta, phi) sigma = (rhat - 1 / rad * dr_theta * that - 1 / rad * dr_phi * phat) * rad**2 * np.sin(theta) return rad, sigma rad, dS = ellipsoid_dS(1 * radius, 1.3 * radius, 1.6 * radius, THETA, PHI) T = get_tmatrix(rad, dS, eps, 1, wavelength, lmax) print(T[1, :, 0, 0]) T1 = np.copy(T) spheroid = miepy.spheroid([0, 0, 0], radius, 1.3 * radius, material) spheroid = miepy.ellipsoid([0, 0, 0], radius, 1.3 * radius, 1.6 * radius, material) T = spheroid.compute_tmatrix(lmax, wavelength, 1) print(T[1, :, 0, 0]) T2 = np.copy(T) import matplotlib.pyplot as plt rmax = lmax * (lmax + 2) T1 = np.reshape(T1, [2 * rmax, 2 * rmax]) T2 = np.reshape(T2, [2 * rmax, 2 * rmax]) y = np.abs(T1 - T2) y /= np.max(y) plt.pcolormesh(y, vmax=.1) plt.gca().set_aspect('equal') plt.colorbar()