def test_spherical_mirror(self): print(">>>>>>>>>>>>>>> test_spherical_mirror") shadow_beam = run_shadow_source() beam1=Beam() beam1.initialize_from_arrays( shadow_beam.getshonecol(1), shadow_beam.getshonecol(2), shadow_beam.getshonecol(3), shadow_beam.getshonecol(4), shadow_beam.getshonecol(5), shadow_beam.getshonecol(6), shadow_beam.getshonecol(10), ) #beam1 = Beam(5000) #beam1.set_point(0, 0, 0) #beam1.set_flat_divergence(5e-3, 5e-2) p=2. q=1. theta=41*np.pi/180 shadow_beam = run_shadow_source() spherical_mirror=Optical_element.initialize_as_surface_conic_sphere_from_focal_distances(p,q, theta) beam1=spherical_mirror.trace_optical_element(beam1) if do_plot: beam1.plot_xz() beam1.plot_xpzp() plt.title("Spherical mirror with p=2, q=1, theta=41") plt.show() shadow_beam = run_shadow_spherical_mirror(shadow_beam) assert_almost_equal(beam1.x, shadow_beam.getshonecol(1), 8) assert_almost_equal(beam1.y, shadow_beam.getshonecol(2), 8) assert_almost_equal(beam1.z, shadow_beam.getshonecol(3), 8)
def beam(): shadow_beam = shadow_source() beam = Beam(25000) beam.initialize_from_arrays( shadow_beam.getshonecol(1), shadow_beam.getshonecol(2), shadow_beam.getshonecol(3), shadow_beam.getshonecol(4), shadow_beam.getshonecol(5), shadow_beam.getshonecol(6), shadow_beam.getshonecol(10), ) beam.flag *= 0. beam.x *= 1e-2 beam.z *= 1e-2 return beam
def test_ellipsoidal_mirror(self): print(">>>>>>>>>>>>>>> test_ellipsoidal_mirror") #beam1=Beam(5000) #beam1.set_point(0,0,0) #beam1.set_flat_divergence(5e-3,5e-2) shadow_beam = run_shadow_source() beam1=Beam() beam1.initialize_from_arrays( shadow_beam.getshonecol(1), shadow_beam.getshonecol(2), shadow_beam.getshonecol(3), shadow_beam.getshonecol(4), shadow_beam.getshonecol(5), shadow_beam.getshonecol(6), shadow_beam.getshonecol(10), ) p=20. q=10. theta=50*np.pi/180 spherical_mirror=Optical_element.initialize_as_surface_conic_ellipsoid_from_focal_distances(p,q,theta) beam1=spherical_mirror.trace_optical_element(beam1) if do_plot: beam1.plot_xz() beam1.plot_xpzp() plt.title("Ellipsoidal mirror with p=20, q=10, theta=50") plt.show() shadow_beam = run_shadow_elliptical_mirror(beam1) assert_almost_equal(beam1.vx, shadow_beam.getshonecol(4), 1) assert_almost_equal(beam1.vy, shadow_beam.getshonecol(5), 1) assert_almost_equal(beam1.vz, shadow_beam.getshonecol(6), 1)
def beam(): shadow_beam = shadow_source() beam = Beam(25000) beam.initialize_from_arrays( shadow_beam.getshonecol(1), shadow_beam.getshonecol(2), shadow_beam.getshonecol(3), shadow_beam.getshonecol(4), shadow_beam.getshonecol(5), shadow_beam.getshonecol(6), shadow_beam.getshonecol(10), ) beam.flag *= 0. beam.plot_xz(0) plt.title('starting beam') return beam
def test_paraboloid_mirror(self): print(">>>>>>>>>>>>>>> test_paraboloid_mirror") #beam1=Beam(5000) #beam1.set_point(0,0,0) #beam1.set_flat_divergence(5e-3,5e-2) shadow_beam = run_shadow_source() beam1=Beam() beam1.initialize_from_arrays( shadow_beam.getshonecol(1), shadow_beam.getshonecol(2), shadow_beam.getshonecol(3), shadow_beam.getshonecol(4), shadow_beam.getshonecol(5), shadow_beam.getshonecol(6), shadow_beam.getshonecol(10), ) p=10. q=20. theta=72*np.pi/180 alpha=0*np.pi/180 spherical_mirror=Optical_element.initialize_as_surface_conic_paraboloid_from_focal_distances(p,q,theta,alpha) beam1=spherical_mirror.trace_optical_element(beam1) if do_plot: beam1.plot_xz() beam1.plot_xpzp() plt.title("Paraboloid mirror with p=10, q=20, theta=72") print(spherical_mirror.ccc_object.get_coefficients()) plt.show() shadow_beam = run_shadow_parabolic_mirror(shadow_beam) assert_almost_equal(beam1.x, shadow_beam.getshonecol(1), 7) assert_almost_equal(beam1.y, shadow_beam.getshonecol(2), 7) assert_almost_equal(beam1.z, shadow_beam.getshonecol(3), 7)
def test_kirk_patrick_baez(self): shadow_beam = shadow_source() beam = Beam() beam.initialize_from_arrays( shadow_beam.getshonecol(1), shadow_beam.getshonecol(2), shadow_beam.getshonecol(3), shadow_beam.getshonecol(4), shadow_beam.getshonecol(5), shadow_beam.getshonecol(6), shadow_beam.getshonecol(10), ) bound1 = BoundaryRectangle(xmax=2.5, xmin=-2.5, ymax=2.5, ymin=-2.5) bound2 = BoundaryRectangle(xmax=1., xmin=-1., ymax=1., ymin=-1.) kirk_patrick_baez = CompoundOpticalElement.initialize_as_kirkpatrick_baez(p=10., q=5., separation=4., theta=89*np.pi/180, bound1=bound1, bound2=bound2) beam = kirk_patrick_baez.trace_compound(beam) beam.plot_good_xz(0) indices = np.where(beam.flag>0) assert_almost_equal(beam.x[indices], 0., 4) assert_almost_equal(beam.z[indices], 0., 4) beam.retrace(50.) beam.plot_good_xz() print(kirk_patrick_baez.info()) if do_plot: plt.show()