Esempio n. 1
0
def test_some_rays_with_mirror():
    first_element = Lens(5, 16., [5., 1.], theta=30.)
    second_element = Aperture(4, [7., 2.])
    third_element = Mirror(8., [15., 3.], theta=160)
    fourth_element = ParabolicMirror(5., 8., [9., 10.])

    r = point_source_rays([0., 1.], angle=[-50, 50])

    r.store()
    r = first_element.trace(r)
    r.store()
    r = second_element.trace(r)
    r.store()
    r = third_element.trace(r)
    r.store()
    r = fourth_element.trace(r)
    r.store()
    r = propagate(r, 35)
    rays = r.traced_rays()

    raypy2d.elements.plot_blockers = False

    ax = plt.gca()
    ax.axis('equal')
    rays.plot(ax, color='orange')
    first_element.plot(ax)
    second_element.plot(ax)
    third_element.plot(ax)
    fourth_element.plot(ax)
    plt.show()
Esempio n. 2
0
def test_path_with_object():

    obj = Object(2.0, [-1., 0.], angle=[-10, 10], n=31)
    path = OpticalPath(obj)
    raypy2d.elements.plot_blockers = False

    path.append(Aperture(0.1, [8.0, 0], blocker_diameter=20))

    path.append(ParabolicMirror(32, 12., [40., 0], theta=175, flipped=True))
    path.append(DiffractionGrating(1.6, 10., interference=-1, theta=-10),
                distance=20.,
                theta=170.)
    path.append(Mirror(15., theta=205.8, flipped=False),
                distance=12,
                theta=129)

    path.append(Aperture(13.75, flipped=True, blocker_diameter=15),
                Lens(22.0, 13.75, [0.01, 0], flipped=False),
                Lens(6.2, 13.75, [0.02, 0], flipped=False),
                Sensor(3.68, [3.80, 0], flipped=True),
                distance=30.)

    ax = plt.gca()
    ax.axis('equal')
    path.plot(ax)

    cross, _, _ = path.rays.traced_rays().ray_crossings()
    cross = cross.reshape((-1, 2))
    cross = cross[~np.any(np.isnan(cross), axis=1)]

    ax.scatter(cross[:, 0], cross[:, 1])

    plt.show()
Esempio n. 3
0
def test_group_elements():

    path = OpticalPath(angle=[-5, 5], n=31)
    raypy2d.elements.plot_blockers = False

    path.append(Aperture(0.1, [8.0, 0], blocker_diameter=20))

    path.append(ParabolicMirror(32, 12., [40., 0], theta=175, flipped=True))
    path.append(DiffractionGrating(1.6, 10., interference=-1, theta=-10),
                distance=20.,
                theta=170.)
    path.append(Mirror(15., theta=205.8, flipped=False),
                distance=12,
                theta=129)

    path.append(Aperture(13.75, flipped=True, blocker_diameter=15),
                Lens(22.0, 13.75, [0.01, 0], flipped=False),
                Lens(6.2, 13.75, [0.02, 0], flipped=False),
                Mirror(3.68, [3.80, 0], flipped=True),
                distance=30.)

    ax = plt.gca()
    ax.axis('equal')
    path.plot(ax)
    plt.show()
Esempio n. 4
0
def test_some_rays():
    first_element = Aperture(5)
    second_element = Lens(5, 16., [5., 1.], theta=30., blocker_diameter=18.)
    third_element = Lens(10, 8., [10., 3.], theta=-15, blocker_diameter=10.)

    rays = []

    r = point_source_rays([-4., 1.], angle=[-50., 50], n=21)

    # r = np.array([[0., 1., 45.*np.pi/180.]])
    # r = first_element.to_global_frame_of_reference(r)
    rays.append(r.array.copy())
    r = first_element.trace(r)
    rays.append(r.array.copy())
    r = second_element.trace(r)
    rays.append(r.array.copy())
    r = third_element.trace(r)
    rays.append(r.array.copy())
    r = propagate(r, 35)
    rays.append(r.array.copy())
    rays = np.array(rays)

    ax = plt.gca()
    ax.axis('equal')
    ax.plot(rays[:, :, 0], rays[:, :, 1], color='red', linewidth=0.5)
    first_element.plot(ax)
    second_element.plot(ax)
    third_element.plot(ax)
    plt.show()
Esempio n. 5
0
def test_plot_lens():
    """
    test the plot function of the lens
    """
    ax = plt.gca()
    ax.axis('equal')
    a = Lens(focal_length=10., diameter=5., origin=[1., 3.], theta=20.34, blocker_diameter=10.)
    a.plot(ax)
    plt.show()
Esempio n. 6
0
def test_diffraction_grating():
    path = OpticalPath()

    path.append(Lens(3, 16., [5., 1.], theta=30.))
    path.append(Lens(10, 16., [8., 3.], theta=15.))
    path.append(DiffractionGrating(1.6, 16., [10, 3.], theta=15.))
    path.propagate(25)

    ax = plt.gca()
    ax.axis('equal')
    path.plot(ax)
    plt.show()
Esempio n. 7
0
def test_imaging_path_with_object():
    obj = Object(2.0, theta=15.)
    path = OpticalPath(obj)

    path.append(Lens(3, 16., [5., 1.], theta=30.))
    path.append(Lens(10, 16., [8., 3.], theta=15.))
    path.propagate(20)

    ax = plt.gca()
    ax.axis('equal')
    path.plot(ax)
    plt.show()
Esempio n. 8
0
def test_imaging_path():
    path = OpticalPath()

    path.append(Lens(5, 16., [5., 1.], theta=30.))
    path.append(Aperture(4, [7., 2.]))
    path.append(ParabolicMirror(5., 8., [15., 3.], theta=155))
    path.append(ParabolicMirror(5., 8., [9., 15.], theta=-45))
    path.propagate(15)

    ax = plt.gca()
    ax.axis('equal')
    path.plot(ax)
    plt.show()
Esempio n. 9
0
def test_max_aperture():
    first_element = Aperture(5)
    second_element = Lens(5, 16., [5., 1.], theta=30., blocker_diameter=18.)
    third_element = Lens(10, 8., [10., 3.], theta=-15, blocker_diameter=10.)

    raypy2d.elements.plot_blockers = False

    ax = plt.gca()
    ax.axis('equal')
    first_element.plot(ax)
    second_element.plot(ax)
    third_element.plot(ax)
    plotting.plot_maximal_aperture(ax, first_element, second_element)
    plotting.plot_maximal_aperture(ax, second_element, third_element)
    plt.show()
Esempio n. 10
0
def path_with_parabolic_mirrors():
    NA = 0.22
    alpha = np.arcsin(NA) / np.pi * 180.

    path = OpticalPath(Object(0.3, [0., 0.], angle=[alpha, -alpha], n=31))

    pm = ParabolicMirror(30, 20, theta=-45 + 180, flipped=False)
    pm.mirroring = False
    path.append(pm, distance=20)
    # path.append(Mirror(10, theta=-45, flipped=True), distance=30)
    theta_0 = 2 * -path.elements[-1].theta
    path.elements

    # path.append(Aperture(1, [6.0, 0], blocker_diameter=20))

    pm = ParabolicMirror(30, 20., theta=152, flipped=True)
    path.append(pm, distance=30, theta=theta_0)
    # path.append(Mirror(20., [50., 0], theta=165, flipped=True))
    # path.append(DiffractionGrating(1.6, 20., interference=-1, theta=-10), distance=15., theta=130.)

    theta_0 = 2 * path.elements[-1].theta - (180 + theta_0)
    theta_diff = 5
    m_diff = 1

    path.append(DiffractionGrating(1.0,
                                   20.,
                                   interference=m_diff,
                                   theta=theta_diff),
                distance=17.,
                theta=theta_0)

    theta_532 = path.elements[-1].diffraction_angle_for(532., theta_diff)

    # path.append(Mirror(20., flipped=True, theta=30), distance=20., theta=105)
    alpha = 0
    vec = np.array(
        [np.cos(alpha / 180. * np.pi),
         np.sin(alpha / 180. * np.pi)])
    path.append(
        Aperture(13.75, theta=alpha, blocker_diameter=28),
        Lens(15.0, 13.75, vec * 4, theta=alpha, flipped=False),
        # Lens(12.0, 11, vec*20, theta=alpha, flipped=False),
        Sensor(5.58, 19.68 * vec, theta=alpha, flipped=True),
        distance=10.,
        theta=theta_0 + theta_532)

    return path
Esempio n. 11
0
def test_imaging_path_with_diffraction_grating():

    raypy2d.elements.plot_blockers = False

    obj = Object(2.0, n=5)
    path = OpticalPath(obj)

    path.append(Lens(3, 16., [3., 0]))
    path.append(DiffractionGrating(1.6, 16., [8, 0.]))
    # path.append(Lens(5, 16., [10.,0]))
    path.append(ParabolicMirror(16., 35., [20, 5.5], theta=160., flipped=True))

    # path.append(Lens(3, 16., [15, 1.], theta=10.))
    path.propagate(-5)

    ax = plt.gca()
    ax.axis('equal')
    path.plot(ax)
    plt.show()
Esempio n. 12
0
def test_sensor_image():

    path = OpticalPath(Object(2.0, [-8., 0.], angle=-10, n=181))
    # raypy2d.elements.plot_blockers = False

    # path.append(Aperture(1, [6.0, 0], blocker_diameter=20))
    path.append(Aperture(0.2, [0.0, 0], blocker_diameter=20))

    path.append(ParabolicMirror(40, 20., [32., 0], theta=154.5, flipped=True))
    # path.append(Mirror(20., [50., 0], theta=165, flipped=True))
    # path.append(DiffractionGrating(1.6, 20., interference=-1, theta=-10), distance=15., theta=130.)
    path.append(DiffractionGrating(1.0, 20., interference=-1, theta=0),
                distance=15.,
                theta=126)
    # path.append(Aperture(13.75, blocker_diameter=15), distance=10., theta=109.5)
    alpha = -0
    vec = np.array(
        [np.cos(alpha / 180. * np.pi),
         np.sin(alpha / 180. * np.pi)])
    sin_alpha = np.cos(alpha / 180. * np.pi)
    path.append(Aperture(13.75, theta=alpha, blocker_diameter=28),
                Lens(12.0, 13.75, vec * 20, theta=alpha, flipped=False),
                Sensor(5.58, 29.68 * vec, theta=alpha, flipped=True),
                distance=13.,
                theta=90)

    # path.propagate(-10)

    ax = plt.gca()
    ax.axis('equal')
    path.plot(ax)

    # cross = path.rays.traced_rays().ray_crossings()
    # cross = cross.reshape((-1, 2))
    # cross = cross[~np.any(np.isnan(cross), axis=1)]

    # ax.scatter(cross[:, 0], cross[:, 1])

    #plot_sensor_img(path, axs[0], only_wavelength=True)

    plt.show()
Esempio n. 13
0
def demo_path():
    from raypy2d.elements import Aperture, ParabolicMirror, DiffractionGrating, Lens, Sensor
    from raypy2d.paths import Object, OpticalPath

    path = OpticalPath(Object(2.0, [-8., 0.], angle=[-20, 20], n=181))

    # path.append(Aperture(1, [6.0, 0], blocker_diameter=20))
    path.append(Aperture(0.2, [0.0, 0], blocker_diameter=20))

    path.append(ParabolicMirror(40, 20., [32., 0], theta=155, flipped=True))
    # path.append(Mirror(20., [50., 0], theta=165, flipped=True))
    # path.append(DiffractionGrating(1.6, 20., interference=-1, theta=-10), distance=15., theta=130.)
    path.append(DiffractionGrating(1.0, 20., interference=1, theta=-10), distance=20., theta=133)
    # path.append(Mirror(20., flipped=True, theta=30), distance=20., theta=105)
    alpha = -5
    vec = np.array([np.cos(alpha / 180. * np.pi), np.sin(alpha / 180. * np.pi)])
    sin_alpha = np.cos(alpha / 180. * np.pi)
    path.append(Aperture(13.75, theta=alpha, blocker_diameter=28),
                Lens(28.0, 13.75, vec * 4, theta=alpha, flipped=False),
                # Lens(12.0, 11, vec*20, theta=alpha, flipped=False),
                Sensor(5.58, 30 * vec, theta=alpha, flipped=True), distance=13., theta=85)

    return path