Пример #1
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()
Пример #2
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()
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
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
Пример #7
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)
Пример #8
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)
Пример #9
0
    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)

    beam = wolter_jap.trace_compound(beam)

    #b2 = beam.y
    #b3 = beam.z

    #beam.y = b3