示例#1
0
    def test_duplicate(self):
        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> test_duplicate")
        b1=Beam()
        b2=b1.duplicate()

        assert_almost_equal(b1.x, b2.x ,9)
        assert_almost_equal(b1.y, b2.y ,9)
        assert_almost_equal(b1.z, b2.z ,9)
        assert_almost_equal(b1.vx,b2.vx,9)
        assert_almost_equal(b1.vy,b2.vy,9)
        assert_almost_equal(b1.vz,b2.vz,9)
示例#2
0
    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()
示例#3
0
    def test_person(self):
        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> test_person")

        beam = Beam.initialize_as_person()

        if do_plot:
            beam.plot_xz()
            plt.show()
示例#4
0
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
示例#5
0
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
示例#6
0
def example_wolter3():
    print(
        ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   example_wolter3"
    )

    p = 50.
    beam1 = Beam.initialize_as_person()
    beam1.set_point(p, 0., p)
    #beam1.set_rectangular_spot(5 / 2 * 1e-5, -5 / 2 * 1e-5, 5 / 2 * 1e-5, -5 / 2 * 1e-5)

    op_ax = Beam(1)
    op_ax.set_point(p, 0., p)

    beam = op_ax.merge(beam1)
    beam.set_divergences_collimated()

    beam.plot_xz()

    distance_between_the_foci = 10.

    wolter3 = CompoundOpticalElement.initialize_as_wolter_3(
        20., 5., distance_between_the_foci)

    print(wolter3.oe[0].ccc_object.get_coefficients())
    print(wolter3.oe[1].ccc_object.get_coefficients())

    #beam = wolter3.trace_wolter3(beam, z0)
    beam = wolter3.trace_compound(beam)

    beam.plot_xz()

    beam.retrace(0.1)
    beam.plot_xz()

    plt.show()
示例#7
0
    def test_ideal_lens_collimated_beam(self):
        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.initialiaze_as_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)
示例#8
0
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()
示例#9
0
    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()
示例#10
0
    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)
示例#11
0
def import_beam(string=None):

    n = np.ones(1)
    f[string + '/Number of rays'].read_direct(n)

    beam = Beam(int(n[0]))

    if string is not None:

        f[string + '/x'].read_direct(beam.x)
        f[string + '/y'].read_direct(beam.y)
        f[string + '/z'].read_direct(beam.z)
        f[string + '/vx'].read_direct(beam.vx)
        f[string + '/vy'].read_direct(beam.vy)
        f[string + '/vz'].read_direct(beam.vz)

    return beam
示例#12
0
    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)
示例#13
0
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()
示例#14
0
    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)
示例#15
0
    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)
示例#16
0
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()
示例#17
0
    def test_ideal_lens_with_trace_optical_element(self):
        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  test_ideal_lens_with_trace_optical_element"
        )

        beam = Beam()
        beam.set_flat_divergence(0.05, 0.005)

        p = 1.
        q = 5.

        lens = Optical_element.initialiaze_as_ideal_lens(p, 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)
示例#18
0
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
示例#19
0
def example_wolter2_good_rays():
    print(
        ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   example_wolter2_good_rays"
    )

    p = 100.  ##### if p=100 the trace_good_ray goes crazy
    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 *= 100.
    beam1.z *= 100.
    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)

    beam = wolter2.trace_good_rays(beam)

    beam.plot_good_xz()

    beam.retrace(10.)
    beam.plot_good_xz()
    plt.title("test_wolter2_good_rays")

    print(beam.flag)

    if do_plot:
        plt.show()
示例#20
0
def example_optimezed_wolter1_good_rays():
    print(
        ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   example_optimezed_wolter1_good_rays"
    )

    p = 100.
    beam1 = Beam.initialize_as_person()
    beam1.x *= 50.
    beam1.z *= 50.
    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()

    p = 1e12
    R = 100.
    theta = 1e-3 * np.pi / 180

    wolter1 = CompoundOpticalElement.initialiaze_as_wolter_1_with_two_parameters(
        p1=p, R=R, theta=theta)

    beam = wolter1.trace_good_rays(beam)
    beam.plot_good_xz()

    indices = np.where(beam.flag >= 0)

    assert_almost_equal(beam.x[indices], 0., 8)
    assert_almost_equal(beam.z[indices], 0., 8)

    beam.retrace(100.)
    beam.plot_good_xz()
    plt.title("optimezed_wolter1_good_rays")

    if do_plot:
        plt.show()
示例#21
0
    def apply_specular_reflections(self, beam, name_file, print_footprint):

        # This is the core of the tracing algoritm

        # This first part compute the travelling time before the two mirror and the image plane
        # and so divide the beam in three:
        # beam1: are the rays that wil first hit oe1
        # beam2: are the rays that will first hit oe2
        # beam3: are the rays that doesn't hit any mirror

        origin = self.time_comparison(beam, elements=[1, 2, 3])
        indices = np.where(origin == 1)
        beam1 = beam.part_of_beam(indices)
        indices = np.where(origin == 2)
        beam2 = beam.part_of_beam(indices)
        indices = np.where(origin == 3)
        beam3 = beam.part_of_beam(indices)

        origin0 = origin.copy()

        if beam3.N != 0:
            [beam3, t] = self.oe[2].intersection_with_optical_element(beam3)

        beam1_list = [beam1.duplicate(), Beam(), Beam()]
        beam2_list = [beam2.duplicate(), Beam(), Beam()]
        beam3_list = [beam3.duplicate(), Beam(), Beam()]

        # This second part compute calculate the travel time of the ray, after the first reflection,
        # to reach the others elements, and put the rays in those beam
        # beam1_list: are the rays that hit oe1
        # beam2_list: are the rays that hit oe2
        # beam3_list: are the rays that reach the image plane

        origin1 = [1, 2]
        origin2 = [1, 2]

        for i in range(0, 2):

            if beam1_list[i].N != 0:
                [beam1_list[i],
                 t] = self.oe[0].intersection_with_optical_element(
                     beam1_list[i])
                self.oe[0].output_direction_from_optical_element(beam1_list[i])

                origin = self.time_comparison(beam1_list[i], [2, 3])
                origin1[i] = origin
                indices = np.where(origin == 2)
                beam2_list[i + 1] = beam1_list[i].part_of_beam(indices)
                indices = np.where(origin == 3)
                beam03 = beam1_list[i].part_of_beam(indices)
            else:
                beam2_list[i + 1] = Beam(0)
                beam03 = Beam(0)

            if beam2_list[i].N != 0:
                [beam2_list[i],
                 t] = self.oe[1].intersection_with_optical_element(
                     beam2_list[i])
                self.oe[1].output_direction_from_optical_element(beam2_list[i])

                origin = self.time_comparison(beam2_list[i], [1, 3])
                origin2[i] = origin
                indices = np.where(origin == 1)
                beam1_list[i + 1] = beam2_list[i].part_of_beam(indices)
                indices = np.where(origin == 3)
                beam003 = beam2_list[i].part_of_beam(indices)
            else:
                beam1_list[i + 1] = Beam(0)
                beam003 = Beam(0)

            beam3_list[i + 1] = beam03.merge(beam003)

        print("Resuming")
        print(beam1_list[0].N, beam1_list[1].N, beam1_list[2].N)
        print(beam2_list[0].N, beam2_list[1].N, beam2_list[2].N)
        print(beam3_list[0].N, beam3_list[1].N, beam3_list[2].N)

        self.print_file_montel(beam_1=beam1_list,
                               beam_2=beam2_list,
                               beam_3=beam3_list,
                               origin0=origin0,
                               origin1=origin1,
                               origin2=origin2,
                               name_file=name_file,
                               print_footprint=print_footprint)

        return beam1_list, beam2_list, beam3_list
示例#22
0
    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()
示例#23
0
    yp = 0.350885
    m = xp / p

    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__":

    beam0 = Beam()
    beam0.set_gaussian_divergence(25. / (2 * np.sqrt(2 * np.log(2))) * 1e-6,
                                  25. / (2 * np.sqrt(2 * np.log(2))) * 1e-6)
    beam0.set_rectangular_spot(xmax=1e-6, xmin=-1e-6, zmax=1e-6, zmin=-1e-6)

    xmax = 0.0
    xmin = -0.1
    ymax = 0.150
    ymin = -0.150
    zmax = 0.1
    zmin = -0.0

    bound = BoundaryRectangle(xmax=xmax,
                              xmin=xmin,
                              ymax=ymax,
                              ymin=ymin,
示例#24
0
from monwes.Beam import Beam
from monwes.Shape import BoundaryRectangle
import numpy as np
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
示例#25
0
from monwes.Beam import Beam
from monwes.Shape import BoundaryRectangle
import numpy as np
import matplotlib.pyplot as plt
from monwes.CompoundOpticalElement import CompoundOpticalElement

do_plot = True
main = "__main__"


if main == "__main__":

    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.plot_xz(0)

    beam.flag *= 0

    p = 5.
    q = 15.
    theta = 88.*np.pi/180

    xmax = 0.
    xmin = -0.4
    ymax =  0.4
    ymin = -0.4
示例#26
0
import numpy as np
import matplotlib.pyplot as plt
from monwes.CompoundOpticalElement import CompoundOpticalElement

do_plot = True
main = "__main__"

if main == "__main__":

    print(
        ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   example_wolter3"
    )

    p = 50.
    q = 5.
    beam1 = Beam.initialize_as_person()
    beam1.set_point(p, 0., p)
    #beam1.set_rectangular_spot(5 / 2 * 1e-5, -5 / 2 * 1e-5, 5 / 2 * 1e-5, -5 / 2 * 1e-5)

    op_ax = Beam(1)
    op_ax.set_point(p, 0., p)

    beam = op_ax.merge(beam1)
    beam.set_divergences_collimated()

    beam.plot_xz()

    distance_between_the_foci = 10.

    wolter3 = CompoundOpticalElement.initialize_as_wolter_3(
        p, q, distance_between_the_foci)
示例#27
0
    yp = 0.350885
    m = xp / p

    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,
示例#28
0
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()
示例#29
0
    beam_2_04 = oe2_04.trace_optical_element(beam_2_04)
    beam_2_14 = oe2_14.trace_optical_element(beam_2_14)

    beam_2_04.plot_xz()
    plt.title('Final plot of a paraboloid mirrors with parameter = 0.4')
    beam_2_14.plot_xz()
    plt.title('Final plot of a paraboloid mirrors with parameter = 1.471')

    plt.show()

if main == "__montel__ellipsoidal__":

    do_plot = False

    shadow3_beam = shadow_source()
    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,
示例#30
0
#y = Vector(0., 1., 0.)
#y.z = - np.tan(theta_grazing) / np.sqrt(2 + (np.tan(theta_grazing))**2)
#y.x =  np.tan(theta_grazing) / np.sqrt(2 + (np.tan(theta_grazing))**2)
#y.y =  1 / np.sqrt(2 + np.tan(theta_grazing)**2)
#y.normalization()
#print(y.x, y.y, y.z)
#print(np.arctan(y.x/y.y)*180/np.pi, np.arctan(y.z/y.y)*180/np.pi)
#
#alpha = -np.arctan(y.z/y.y)
#y.rotation(alpha, 'x')
#gamma = np.arctan(y.x/y.y)
#y.rotation(gamma, 'z')
#
#print(y.x, y.y, y.z)

beam = Beam()
beam.set_rectangular_spot(xmax=0.5e-3, xmin=-0.5e-3, zmax=0.5e-3, zmin=-0.5e-3)
beam.set_flat_divergence(500 * 1e-6, 800 * 1e-6)
beam.set_divergences_collimated()

op_axis = Beam(1)
op_axis.set_point(0., 0., 0.)
op_axis.set_divergences_collimated()
beam = op_axis.merge(beam)

xmax = 0.0
xmin = -0.01
ymax = 0.300
ymin = -0.300
zmax = 0.01
zmin = 0.0