Ejemplo n.º 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()
Ejemplo 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()
Ejemplo 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()
Ejemplo n.º 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)
Ejemplo n.º 5
0
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
    zmax = 0.3
Ejemplo n.º 6
0
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
    zmax =  0.4
Ejemplo n.º 7
0
#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
bound = BoundaryRectangle(xmax=xmax,
                          xmin=xmin,