def test_gaussian_beam(self): print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> test_gaussian_beam") beam=Beam(5000) beam.set_point(1.,1.,1.) beam.set_gaussian_divergence(0.05,0.0005) print(np.mean(beam.vx)) print(np.mean(beam.vz)) assert_almost_equal(np.mean(beam.vx),0.0,1) assert_almost_equal(np.mean(beam.vz),0.0,1)
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 example_wolter_1_microscope(): print( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> example_wolter_1_microscope" ) p = 13.4 q = 0.300 d = 0.1082882 q1 = 0.67041707 theta1 = 88.8 * np.pi / 180 theta2 = 89. * np.pi / 180 wolter_jap = CompoundOpticalElement.wolter_for_japanese(p=p, q=q, d=d, q1=q1, theta1=theta1, theta2=theta2) beam = Beam() beam.set_gaussian_divergence(5 * 1e-5, 0.00025) beam.set_rectangular_spot(xmax=200 * 1e-6, xmin=-200 * 1e-6, zmax=10 * 1e-6, zmin=-10 * 1e-6) beam.plot_xz(0) plt.title('wolter microscope') beam.plot_xpzp(0) wolter_jap.trace_wolter_japanese(beam) b2 = beam.y b3 = beam.z beam.y = b3 beam.z = b2 beam.plot_xz(0) beam.histogram() 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
v = Vector(xp, yp - f, 0.) v.normalization() t = Vector(xp / p, -1, 0.) t.normalization() print((np.arccos(v.dot(t))) * 180. / np.pi) return np.arccos(v.dot(t)) if main == "__Moretti_1__": beam1 = Beam(1e6) #beam1.set_gaussian_spot(1 / (2 * np.sqrt(2 * np.log(2))) * 1e-6, 1 / (2 * np.sqrt(2 * np.log(2))) * 1e-6) #beam1.set_rectangular_spot(xmax=0.5e-6, xmin=-0.5e-6, zmax=0.5e-6, zmin=-0.5e-6) beam1.set_gaussian_divergence(25. / (2 * np.sqrt(2 * np.log(2))) * 1e-6, 25. / (2 * np.sqrt(2 * np.log(2))) * 1e-6) xmax = 0.01 xmin = -0.01 ymax = 0.150 ymin = -0.150 zmax = 0.1 zmin = -0.1 bound = BoundaryRectangle(xmax=xmax, xmin=xmin, ymax=ymax, ymin=ymin, zmax=zmax, zmin=zmin) dvx = [Beam(), Beam(), Beam(), Beam(), Beam()]
p = 13.4 q = 0.300 d = 1. #0.1082882 q1 = 5. #0.67041707 theta1 = 88.8 * np.pi / 180 theta2 = 88.8 * np.pi / 180 wolter_jap = CompoundOpticalElement.wolter_1_for_microscope(p=p, q=q, d=d, q1=q1, theta1=theta1, theta2=theta2) beam = Beam() beam.set_gaussian_divergence(5 * 1e-5, 0.00025) beam.set_rectangular_spot(xmax=200 * 1e-6, xmin=-200 * 1e-6, zmax=10 * 1e-6, zmin=-10 * 1e-6) #beam.set_divergences_collimated() beam.plot_xz(0) plt.title('wolter microscope') beam.plot_xpzp(0) op_axis = Beam(1) op_axis.set_point(0., 0., 0.) op_axis.set_divergences_collimated() beam = op_axis.merge(beam)
import matplotlib.pyplot as plt from monwes.CompoundOpticalElement import CompoundOpticalElement from monwes.Vector import Vector do_plot = True main = "__main__" if main == "__main__": print( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> example_montel_elliptical") beam = Beam(1e5) 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.
#print(np.arctan(vrot.x/np.sqrt(vrot.y**2+vrot.z**2))*180/np.pi, np.arctan(vrot.z/np.sqrt(vrot.x**2+vrot.y**2))*180/np.pi) # # #vector = Vector(0., 1., 0.) #vector.rotation(-theta_grazing, 'z') #x = Vector(0., 0., 1.) #n = x.vector_product(vector) #vrot = vector.rodrigues_formula(n, -theta_grazing) #print(vrot.info()) # #print(np.arctan(vrot.x/vrot.y)*180/np.pi, np.arctan(vrot.z/vrot.y)*180/np.pi) #print(np.arctan(vrot.x/np.sqrt(vrot.y**2+vrot.z**2))*180/np.pi, np.arctan(vrot.z/np.sqrt(vrot.x**2+vrot.y**2))*180/np.pi) # beam = Beam(25000) beam.set_gaussian_divergence(10.6 * 1e-6, 10.6 * 1e-6) #beam.set_rectangular_spot(xmax=0.5e-4, xmin=-0.5e-4, zmax=0.5e-4, zmin=-0.5e-4) #beam.set_circular_spot(1e-4) beam.plot_xpzp(0) op_axis = Beam(1) op_axis.set_point(0., 0., 0.) op_axis.set_divergences_collimated() beam = op_axis.merge(beam) theta = 88. * np.pi / 180 theta_grazing = np.pi / 2 - theta xmax = 0. xmin = -100. ymax = 0.3