def test_interface_z_translation(s1, s2, rtol): """ Moving the source and particle is identical to moving the interface (cross-section comparison) """ interface = miepy.interface(miepy.constant_material(index=1.7)) cluster = miepy.sphere_cluster(position=[0, 0, -zpos], radius=radius, material=material, medium=medium, lmax=2, source=s1, interface=interface, wavelength=wavelength) C1 = np.array(cluster.cross_sections()) interface = miepy.interface(miepy.constant_material(index=1.7), z=zpos) cluster = miepy.sphere_cluster(position=[0, 0, 0], radius=radius, material=material, medium=medium, lmax=2, source=s2, interface=interface, wavelength=wavelength) C2 = np.array(cluster.cross_sections()) assert np.allclose(C1, C2, atol=0, rtol=rtol)
def test_index_matched_interface(source, rtol): """ An interface that is index-matched with the medium is identical to not having an interface (cross-section comparison) """ interface = miepy.interface(medium, z=zpos) cluster = miepy.sphere_cluster(position=[0, 0, 0], radius=radius, material=material, medium=medium, lmax=2, source=source, interface=interface, wavelength=wavelength) C1 = np.array(cluster.cross_sections()) cluster = miepy.sphere_cluster(position=[0, 0, 0], radius=radius, material=material, medium=medium, lmax=2, source=source, wavelength=wavelength) C2 = np.array(cluster.cross_sections()) assert np.allclose(C1, C2, atol=0, rtol=1e-15)
sphere_dielectric = miepy.constant_material( sphere_index**2 ) background_dielectric = miepy.constant_material( 1.46**2 ) interface_dielectric = miepy.materials.vacuum() # two_layers = smuthi.layers.LayerSystem( thicknesses=[0, 0], refractive_indices=[ 1.0, 1.46 ] ) # smuthi_plane_wave = smuthi.initial_field.PlaneWave( # vacuum_wavelength=probe_wavelength_nm, # polar_angle=np.pi,#np.pi,#4*np.pi/5, # from top # azimuthal_angle=0, # polarization=1 ) # 0=TE 1=TM plane_wave = miepy.sources.plane_wave( [ 1, 0 ] ) air_interface = miepy.interface( interface_dielectric, z=( ( device_height_nm + sphere_z_global_offset_nm ) * nm ) ) lmax = 2#3 focal_x_nm = np.linspace( x_bounds_nm[ 0 ], x_bounds_nm[ 1 ], focal_x_points ) focal_y_nm = np.linspace( y_bounds_nm[ 0 ], y_bounds_nm[ 1 ], focal_y_points ) focal_z_nm = sphere_z_global_offset_nm + device_height_nm + focal_length_nm def gen_random_cluster( sphere_probability ): x_start_nm = x_bounds_nm[ 0 ] + sphere_radius_nm y_start_nm = y_bounds_nm[ 0 ] + sphere_radius_nm x_end_nm = x_bounds_nm[ 1 ] - sphere_radius_nm y_end_nm = y_bounds_nm[ 1 ] - sphere_radius_nm
m = self.get_relative_index(wavelength, medium) theta_t = self.transmission_angle(theta, wavelength, medium) t_parallel = 2 * np.cos(theta) / (m * np.cos(theta) + np.cos(theta_t)) t_perp = 2 * np.cos(theta) / (np.cos(theta) + m * np.cos(theta_t)) return t_parallel, t_perp if __name__ == '__main__': n1 = 1 n2 = 500 + 2j wavelength = 1 k1 = n1 * 2 * np.pi / wavelength k2 = n2 * 2 * np.pi / wavelength medium = miepy.constant_material(index=n1) interface = miepy.interface(material=miepy.constant_material(index=n2)) incident = miepy.sources.plane_wave([1, 0], 0) reflected = interface.reflected_plane_wave(incident, wavelength, medium) transmitted = interface.transmitted_plane_wave(incident, wavelength, medium) x = np.linspace(-3, 3, 300) z = np.linspace(-3, 3, 300) X, Z = np.meshgrid(x, z) Y = np.zeros_like(X) E = np.zeros((3, ) + X.shape, dtype=complex) idx = Z < 0 E[:, idx] += incident.E_field(X[idx], Y[idx], Z[idx], k1)