def test_compound_wolter2_with_hole(): p = 0. #beam1 = Beam.initialize_as_person(10000) beam1 = Beam(100000) beam1.set_circular_spot(1.) #beam1.set_rectangular_spot(5 / 2 * 1e-5, -5 / 2 * 1e-5, 5 / 2 * 1e-5, -5 / 2 * 1e-5) beam1.x *= 10. beam1.z *= 10. beam1.set_point(p, 0., p) op_ax = Beam(1) op_ax.set_point(p, 0., p) beam = op_ax.merge(beam1) beam.set_divergences_collimated() beam.plot_xz(0) p = 20000. q = 30. z0 = 5. focal = 2 * z0 + q wolter2 = CompoundOpticalElement.initialiaze_as_wolter_2(p1=p, q1=q, z0=z0) #oe1 = Optical_element.initialize_as_surface_conic_paraboloid_from_focal_distances(p=p, q=0., theta=0., alpha=0., infinity_location="p", focal=focal) #oe2 = Optical_element.initialize_my_hyperboloid(p=0., q=-q, theta=90*np.pi/180, alpha=0., wolter=2, z0=z0, distance_of_focalization=focal) #oe1.rotation_to_the_optical_element(beam) #oe1.translation_to_the_optical_element(beam) #[beam, t] = oe1.intersection_with_optical_element(beam) #oe1.output_direction_from_optical_element(beam) #[beam, t] = oe2.intersection_with_optical_element(beam) #oe2. output_direction_from_optical_element(beam) #oe2.theta = 0. #oe2.rotation_to_the_screen(beam) #oe2.translation_to_the_screen(beam) #oe2.intersection_with_the_screen(beam) beam = wolter2.trace_compound(beam) beam.plot_xz() print("mean(beam.x)=%f, mean(beam.y)=%f, mean(beam.z)=%f" % (np.mean(beam.x), np.mean(beam.y), np.mean(beam.z))) beam.retrace(10.) beam.plot_xz() plt.show()
def test_ideal_lens_collimated_beam(): print( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> test_ideal_lens_collimated_beam") beam = Beam() beam.set_circular_spot(20 * 1e-9) beam.set_divergences_collimated() beam.plot_xz() p = 1. q = 5. lens = Optical_element.ideal_lens(p, q, q, q) beam = lens.trace_optical_element(beam) beam.plot_xz() if do_plot: plt.show() assert_almost_equal(np.abs(beam.x).mean(), 0.0, 4) assert_almost_equal(np.abs(beam.z).mean(), 0.0, 4)
#prova = Optical_element.initialize_as_surface_conic_paraboloid_from_focal_distances(p,q,theta,alpha,"p") #print(prova.ccc_object.get_coefficients()) # #beam=prova.trace_Wolter_2(beam) # #print(np.mean(beam.z)) #beam.plot_xy() #beam.plot_xz() #plt.show() beam1=Beam() beam1.set_divergences_collimated() beam1.set_point(0.+100,0.,20.+100) beam1.set_circular_spot(5.) beam2=Beam() beam2.set_divergences_collimated() beam2.set_point(0.+100,0.,0.+100) beam2.set_rectangular_spot(20.,-20.,15.,10.) beam=beam1.merge(beam2) beam3=Beam() beam3.set_divergences_collimated() beam3.set_point(0.+100,0.,0.+100) beam3.set_rectangular_spot(5.,-5.,10.,-40.) beam=beam.merge(beam3)
oe0.write("end.00") beam.write("begin.dat") return beam if main == "__main__": varx = np.zeros(100) varz = np.zeros(100) qqq = np.zeros(100) #for i in range (0, 1): beam = Beam(25000) beam.set_circular_spot(1e-3) beam.set_divergences_collimated() 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), 0) #beam = Beam() #beam.set_flat_divergence(0.01,0.01)