def example_montel_paraboloid(): print( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> example_montel_paraboloid") beam = Beam(25000) beam.set_circular_spot(1e-3) beam.set_flat_divergence(0.01, 0.01) beam.set_flat_divergence(1e-6, 1e-6) beam.flag *= 0 p = 5. q = 15. theta = 88. * np.pi / 180 xmax = 0. xmin = -0.4 ymax = 0.4 ymin = -0.4 zmax = 0.4 zmin = 0. bound1 = BoundaryRectangle(xmax, xmin, ymax, ymin, zmax, zmin) bound2 = BoundaryRectangle(xmax, xmin, ymax, ymin, zmax, zmin) montel = CompoundOpticalElement.initialize_as_montel_parabolic( p=p, q=q, theta=theta, bound1=bound1, bound2=bound2, distance_of_the_screen=q) beam03 = montel.trace_montel(beam) print(beam03[2].N / 25000) plt.figure() plt.plot(beam03[0].x, beam03[0].z, 'ro') plt.plot(beam03[1].x, beam03[1].z, 'bo') plt.plot(beam03[2].x, beam03[2].z, 'go') plt.xlabel('x axis') plt.ylabel('z axis') plt.axis('equal') beam03[2].plot_xz(0) print("No reflection = %d\nOne reflection = %d\nTwo reflection = %d" % (beam03[0].N, beam03[1].N, beam03[2].N)) print("dx = %f" % (max(beam03[2].x) - min(beam03[2].x))) plt.show()
def example_montel_elliptical(): print( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> example_montel_elliptical") beam = Beam(25000) beam.set_flat_divergence(25 * 1e-6, 25 * 1e-6) beam.set_rectangular_spot(xmax=25 * 1e-6, xmin=-25 * 1e-6, zmax=5 * 1e-6, zmin=-5 * 1e-6) beam.set_gaussian_divergence(25 * 1e-4, 25 * 1e-4) beam.flag *= 0 p = 5. q = 15. #theta = np.pi/2 - 0.15 theta = 85. * np.pi / 180 xmax = 0. xmin = -0.3 ymax = 0.1 ymin = -0.1 zmax = 0.3 zmin = 0. bound1 = BoundaryRectangle(xmax, xmin, ymax, ymin, zmax, zmin) bound2 = BoundaryRectangle(xmax, xmin, ymax, ymin, zmax, zmin) montel = CompoundOpticalElement.initialize_as_montel_ellipsoid( p=p, q=q, theta=theta, bound1=bound1, bound2=bound2) beam03 = montel.trace_montel(beam) print(beam03[2].N / 25000) plt.figure() plt.plot(beam03[0].x, beam03[0].z, 'ro') plt.plot(beam03[1].x, beam03[1].z, 'bo') plt.plot(beam03[2].x, beam03[2].z, 'go') plt.xlabel('x axis') plt.ylabel('z axis') plt.axis('equal') beam03[2].plot_xz(0) print("No reflection = %d\nOne reflection = %d\nTwo reflection = %d" % (beam03[0].N, beam03[1].N, beam03[2].N)) plt.show()
def test_rectangular_shape(self): beam = Beam(round(1e5)) plane_mirror = Optical_element.initialize_as_surface_conic_plane( p=10., q=0., theta=0.) beam.set_flat_divergence(0.02, 0.1) xmax = 0.01 xmin = -0.0008 ymax = 1. ymin = -0.29 bound = BoundaryRectangle(xmax=xmax, xmin=xmin, ymax=ymax, ymin=ymin) plane_mirror.set_bound(bound) beam = plane_mirror.trace_optical_element(beam) beam.plot_xz() beam.plot_good_xz() indices = np.where(beam.flag > 0) assert_almost_equal(max(beam.x[indices]) - xmax, 0., 2) assert_almost_equal(-min(beam.x[indices]) + xmin, 0., 2) assert_almost_equal(max(beam.z[indices]) + ymin, 0., 2) assert_almost_equal(-min(beam.z[indices]) - ymax, 0., 2) print(max(beam.x[indices]), min(beam.x[indices]), max(beam.y[indices]), min(beam.y[indices])) if do_plot is True: plt.show()
def example_kirk_patrick_baez(): print( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> example_kirk_patrick_baez" ) beam = Beam.initialize_as_person() beam.set_flat_divergence(1e-12, 1e-12) beam.x = beam.x * 1e-3 beam.z = beam.z * 1e-3 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) plt.title('Kirk Patrick Baez') indices = np.where(beam.flag > 0) beam.retrace(50.) beam.plot_good_xz() print(kirk_patrick_baez.info()) print("Number of good rays: %f" % (beam.number_of_good_rays())) # beam.histogram() if do_plot: plt.show()
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()
def beam_source2(): beam = Beam(25000) #beam.set_circular_spot(r=1e-4) #beam.set_rectangular_spot(xmax=1e-4, xmin=-1e-4, zmax=1e-4, zmin=1e-4) #beam.set_gaussian_spot(dx=1e-4, dz=1e-4) #beam.set_flat_divergence(dx=25e-6, dz=25e-6) beam.set_gaussian_divergence(25e-6, 25e-6) #beam.set_divergences_collimated() xmax = 0. xmin = -100. ymax = 0.3 ymin = -0.4 zmax = 100. zmin = 0. bound = BoundaryRectangle(xmax=xmax, xmin=xmin, ymax=ymax, ymin=ymin, zmax=zmax, zmin=zmin) return beam, bound
beam = Beam.initialize_from_shadow_beam(shadow3_beam) if do_plot: beam.plot_xz(0, title="source size") beam.plot_xpzp(0, title="source divergences") xmax = 0. xmin = -100. ymax = 0.3 ymin = -0.4 zmax = 100. zmin = 0. bound = BoundaryRectangle(xmax=xmax, xmin=xmin, ymax=ymax, ymin=ymin, zmax=zmax, zmin=zmin) montel_1 = CompoundOpticalElement.initialize_as_montel_ellipsoid( p=0.4, q=0.3, theta_z=theta, bound1=bound, bound2=bound, fp=0.4, fq=10000000.) print(montel_1.info()) #TODO force geometrical p and q beam_n, beam_m, beam_1 = montel_1.trace_montel(beam,
beam.flag *= 0 p = 5. q = 15. #theta = np.pi/2 - 0.15 theta = 85. * np.pi / 180 xmax = 0. xmin = -0.3 ymax = 0.1 ymin = -0.1 zmax = 0.3 zmin = 0. bound1 = BoundaryRectangle(xmax, xmin, ymax, ymin, zmax, zmin) bound2 = BoundaryRectangle(xmax, xmin, ymax, ymin, zmax, zmin) montel = CompoundOpticalElement.initialize_as_montel_ellipsoid( p=p, q=q, theta_z=theta, bound1=bound1, bound2=bound2) beam1, beam2, beam03 = montel.trace_montel(beam) #print(beam03[2].N/25000) plt.figure() plt.plot(beam03[0].x, beam03[0].z, 'r.', markersize=0.2) plt.plot(beam03[1].x, beam03[1].z, 'b.', markersize=0.2) plt.plot(beam03[2].x, beam03[2].z, 'g.', markersize=0.2) plt.xlabel('x axis') plt.ylabel('z axis') plt.axis('equal')