Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
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()
Esempio n. 4
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()
Esempio n. 5
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()
Esempio n. 6
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()
Esempio n. 7
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()
Esempio n. 8
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()
Esempio n. 9
0
xmax = 0.0
xmin = -0.01
ymax = 0.300
ymin = -0.300
zmax = 0.01
zmin = 0.0
bound = BoundaryRectangle(xmax=xmax,
                          xmin=xmin,
                          ymax=ymax,
                          ymin=ymin,
                          zmax=zmax,
                          zmin=zmin)
montel = CompoundOpticalElement.initialize_as_montel_parabolic(
    p=0.351,
    q=1.,
    theta=theta,
    bound1=bound,
    bound2=bound,
    infinity_location='p')
par = Optical_element.initialize_as_surface_conic_paraboloid_from_focal_distances(
    0.351, 1., theta, 0.0, 'p', None, 1)

#velocity = Vector(beam.vx, beam.vy, beam.vz)
#velocity.rotation(-gamma, 'z')
#velocity.rotation(-alpha, 'x')
#beam.vx = velocity.x
#beam.vy = velocity.y
#beam.vz = velocity.z
#
#
#print(beam.vx, beam.vy, beam.vz)
Esempio n. 10
0
    Nn = 7

    for i in range(Nn):

        beam = beam1.duplicate()
        alpha = round(-0.03 + 0.01 * i, 3)
        print(alpha)

        f = h5py.File(date, 'a')
        f1 = f.create_group(str(alpha))

        montel = CompoundOpticalElement.initialize_as_montel_parabolic(
            p=0.351,
            q=1.,
            theta=theta(),
            bound1=bound,
            bound2=bound,
            angle_of_mismatch=alpha)
        beam = montel.trace_montel(beam, f1)

        f1["Number of rays"] = beam[2].N
        f1["x"] = beam[2].x
        f1["y"] = beam[2].y
        f1["z"] = beam[2].z
        f1["vx"] = beam[2].vx
        f1["vy"] = beam[2].vy
        f1["vz"] = beam[2].vz

        f.close()
Esempio n. 11
0
    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)

    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()

    print(beam.vx, beam.vy, beam.vz)

    plt.show()
Esempio n. 12
0
if main == "__main__":

    print(
        ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   example_wolter_1_microscope"
    )

    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)
Esempio n. 13
0
    Nn = 7

    for i in range(Nn):

        print("iteration %d" % i)

        beam = beam0.duplicate()
        alpha = (-0.03 + 0.01 * i) * np.pi / 180
        print(alpha)
        salpha[i] = str(round(-0.03 + 0.01 * i, 3))

        montel = CompoundOpticalElement.initialize_as_montel_parabolic(
            p=0.351,
            q=1.,
            theta_z=theta(),
            bound1=bound,
            bound2=bound,
            angle_of_mismatch=alpha,
            infinity_location='q')
        beam1, beam2, beam3 = montel.trace_montel(beam,
                                                  print_footprint=0,
                                                  mode=1)

        b[i] = beam3[2]

    plt.figure()
    plt.hist(b[0].vx * 1e6, bins=900, normed=1, histtype='step', color='b')
    plt.hist(b[1].vx * 1e6,
             bins=900,
             normed=1,
             histtype='step',
Esempio n. 14
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')

    beam03[2].plot_xz(0)

    print("No reflection = %d\nOne reflection = %d\nTwo reflection = %d" %
          (beam03[0].N, beam03[1].N, beam03[2].N))
Esempio n. 15
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_z=theta, bound1=bound1, bound2=bound2, distance_of_the_screen=q)
    beam1, beam2, beam03 = montel.trace_montel(beam)

    print(beam03[2].N/25000)

    plt.figure()
    plt.plot(beam03[0].x, beam03[0].z, 'ro', markersize=0.2)
    plt.plot(beam03[1].x, beam03[1].z, 'bo', markersize=0.2)
    plt.plot(beam03[2].x, beam03[2].z, 'go', markersize=0.2)
    plt.xlabel('x axis')
    plt.ylabel('z axis')
    plt.axis('equal')

    beam03[2].plot_xz(0)
    plt.title('final')
Esempio n. 16
0
    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()

    print("pollo")
    print(beam.x, beam.y, beam.z)

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

    print(beam.flag)

    print(beam.vx, beam.vy, beam.vz)
Esempio n. 17
0
        beam_1471)  ########### case of 1.471

    beam_04.plot_xz()
    plt.title('Final plot of an ideal lense with parameter = 0.4')
    beam_1471.plot_xz()
    plt.title('Final plot of an ideal lense with parameter = 1.471')

    plt.show()

if main == "__KirkPatrickBaez__":

    beam = beam()

    comp_oe1 = CompoundOpticalElement.initialize_as_kirkpatrick_baez_parabolic(
        p=0.4,
        q=0.3,
        separation=0.2,
        theta=88.281 * np.pi / 180,
        infinity_location='q')

    beam = comp_oe1.trace_compound(beam)

    beam_2_04 = beam.duplicate()
    beam_2_14 = beam.duplicate()

    comp_oe2_04 = CompoundOpticalElement.initialize_as_kirkpatrick_baez_parabolic(
        p=0.3, q=0.4, separation=0.2, theta=theta, infinity_location='p')
    comp_oe2_14 = CompoundOpticalElement.initialize_as_kirkpatrick_baez_parabolic(
        p=0.3, q=1.471, separation=0.2, theta=theta, infinity_location='p')

    beam_2_04 = comp_oe2_04.trace_compound(beam_2_04)
    beam_2_14 = comp_oe2_14.trace_compound(beam_2_14)
Esempio n. 18
0
    beam = beam()

    beam.x *= 1e6
    beam.z *= 1e6

    #beam.plot_xz(0)
    #beam.plot_xpzp(0)

    beam.x *= 1e-6
    beam.z *= 1e-6

    wolter_japanese = CompoundOpticalElement.wolter_1_for_microscope(
        p=13.4,
        q=0.3,
        q1=0.67041707,
        d=0.1082882,
        theta1=88.8 * np.pi / 180,
        theta2=89. * np.pi / 180)

    beam = wolter_japanese.trace_wolter_japanese(beam)

    wolter_japanese.oe[0].output_frame_wolter(beam)

    beam.x *= 1e6
    beam.z *= 1e6

    beam.plot_xz(0)
    beam.plot_xpzp(0)

    print(beam.vx, beam.vy, beam.vz)
Esempio n. 19
0
if __name__ == '__main__':

    if main == 'focalize':
        beam, bound = beam_source1()

        p = 0.4
        q = 1.
        theta = 88. * np.pi / 180

        beam.plot_xz(0)
        plt.title('Initial source dimension')

        montel = CompoundOpticalElement.initialize_as_montel_parabolic(
            p=p,
            q=q,
            theta=theta,
            infinity_location='p',
            bound1=bound,
            bound2=bound)

        beam = montel.trace_montel(beam, mode=mode)[2]

        beam.plot_xz()
        title = 'Beam dimension after montel of mode = ' + str(mode)
        plt.title(title)

    if main == 'collimate':
        beam, bound = beam_source2()

        p = 0.4
        q = 1.
Esempio n. 20
0
    beam1 = Beam.initialize_as_person()
    beam1.x *= 50.
    beam1.z *= 50.
    beam1.set_point(p, 0., p)
    beam1.plot_xz()
    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=0.001*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)

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

    print(beam.vx, beam.vy, beam.vz)


    print(np.arctan(beam.vz[0]/beam.vy[0]) * 180. / np.pi)
    print(wolter1.type)