Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 3
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()
Exemplo n.º 4
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
Exemplo n.º 5
0
def test_diffraction_grating():
    """
    test the diffraction of rays on a grating
    """
    path = OpticalPath(Object(1, theta=0))

    theta_diff = -30
    m_diff = 1

    path.append(DiffractionGrating(1.0, 15, origin=[10., 0], theta=theta_diff))

    theta_532 = np.arcsin(np.sin(-theta_diff / 180. * np.pi)
                          - m_diff * 532. / 1000. / path.elements[-1].grating) * 180 / np.pi \
                + theta_diff

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

    assert np.isclose(theta_532, -31.8337)
    assert np.isclose(theta_532_2, -31.8337)
Exemplo n.º 6
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()
Exemplo n.º 7
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()
Exemplo n.º 8
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