def zx_plot(n, rmax, m):
    """Creates a z-x plot of a bundle of rays propogated through "s".
    
       Parameters
       ----------
       n:    integer_type
             The number of concentric circles of rays within the
             distribution.
       rmax: float_type
             The maximum radius of the distribution of rays.
       m:    integer_type
             The rate at which the number of rays per concentric circle
             increases.
    """
    bundle = rt.bundle(n, rmax, m)
    fig = plt.figure()
    ax = Axes3D(fig)
    for ray in bundle:
        "Loop that plots the z-x positions of the parallel rays."
        s.propagate_ray(ray)
        p.propagate_ray(ray)
        x = []
        y = []
        z = []
        for position in ray.positions:
            x.append(position[0])  # Appends all x positions to the list "x".
            y.append(position[1])  # Appends all y positions to the list "y".
            z.append(position[2])  # Appends all z positions to the list "z".
        ax.plot(xs=z, ys=y, zs=x)
def xypositions(n, rmax, m):
    """Creates a list of the x-y positions of the rays incident on the output
       plane.
       
       Parameters
       ----------
       n:    integer_type
             The number of concentric circles of rays within the
             distribution.
       rmax: float_type
             The maximum radius of the distribution of rays.
       m:    integer_type
             The rate at which the number of rays per concentric circle
             increases.
    """
    positions = []
    bundle = rt.bundle(n, rmax, m)
    for ray in bundle:
        s.propagate_ray(ray)
        p.propagate_ray(ray)
        x = []
        y = []
        x.append(ray.positions[-1][0])  # Appends the last x position to "x".
        y.append(ray.positions[-1][1])  # Appends the last y position to "y".
        positions.append([x[0], y[0]])  # Creates a list of x-y coordinates.
    return positions
def spotdiagram(n, rmax, m):
    """Plots the spot diagram of the rays incident on the output
       plane.
       
       Parameters
       ----------
       n:    integer_type
             The number of concentric circles of rays within the
             distribution.
       rmax: float_type
             The maximum radius of the distribution of rays.
       m:    integer_type
             The rate at which the number of rays per concentric circle
             increases.
    """
    bundle = rt.bundle(n, rmax, m)
    for ray in bundle:
        s.propagate_ray(ray)
        p.propagate_ray(ray)
        x = []
        y = []
        x.append(ray.positions[-1][0])  # Appends the last x position to "x".
        y.append(ray.positions[-1][1])  # Appends the last y position to "y".
        plt.plot(x, y, 'bo')
    plt.xlabel('x axis /mm')
    plt.ylabel('y axis /mm')
    plt.show()
    plt.axis('auto')
def zx_plot(n, rmax, m):
    """Creates a z-x plot of a bundle of rays propogated through "s".
    
       Parameters
       ----------
       n:    integer_type
             The number of concentric circles of rays within the
             distribution.
       rmax: float_type
             The maximum radius of the distribution of rays.
       m:    integer_type
             The rate at which the number of rays per concentric circle
             increases.
    """
    bundle = rt.bundle(n, rmax, m)
    for ray in bundle:
        "Loop that plots the z-x positions of the parallel rays."
        s.propagate_ray(ray)
        p.propagate_ray(ray)
        x = []
        z = []
        for position in ray.positions:
            x.append(position[0])  # Appends all x positions to the list "x".
            z.append(position[2])  # Appends all y positions to the list "y".
        plt.plot(z, x)
    plt.xlabel('z axis /mm')
    plt.ylabel('x axis /mm')
    plt.show()
Beispiel #5
0
def xypositions(n, rmax, m, lens1, lens2):
    """Creates a list of the x-y positions of the rays incident on the output
       plane.
       
       Parameters
       ----------
       n:     integer_type
              The number of concentric circles of rays within the
              distribution.
       rmax:  float_type
              The maximum radius of the distribution of rays.
       m:     integer_type
              The rate at which the number of rays per concentric circle
              increases.
       lens1: instance_type
              An optical element as defined in the raytracer module, and is the
              first optical element that the bundle is propagated through.
       lens2: instance_type
              An optical element as defined in teh raytracer module, and is the
              second optical element that the bundle is propagated through.
    """
    # Placing the output plane at the focal point of lens1 and lens2.
    output_plane = rt.OutputPlane(rt.focal_point2(lens1, lens2), 10000)
    positions = []
    bundle=rt.bundle(n, rmax, m)
    for ray in bundle:
        lens1.propagate_ray(ray)
        lens2.propagate_ray(ray)
        output_plane.propagate_ray(ray)
        x = []
        y = []
        x.append(ray.positions[-1][0]) # Appends the last x position to "x".
        y.append(ray.positions[-1][1]) # Appends the last y position to "y".
        positions.append([x[0],y[0]]) # Creates a list of x-y coordinates.
    return positions
Beispiel #6
0
def zxPlot(n, rmax, m , lens1, lens2):
    """ Creates a plot in the z-x plane of a bundle of rays through two optical
        elements.  The optical elements can be chosen such that they form
        planoconvex lenses.
        
        Parameters
        ----------
        n:    integer_type
              The number of concentric circles of rays within the
              distribution.
       rmax:  float_type
              The maximum radius of the distribution of rays.
       m:     integer_type
              The rate at which the number of rays per concentric circle
              increases.
       lens1: instance_type
              An optical element as defined in the raytracer module, and is the
              first optical element that the bundle is propagated through.
       lens2: instance_type
              An optical element as defined in the raytracer module, and is the
              second optical element that the bundle is propagated through.
    """
    bundle = rt.bundle(n, rmax, m)
    # Defining the output plane to be at the focal point of the combination of 
    # lens1 and lens2.  An arbitrarily large aperture radius was chosen to
    # ensure that all rays were incident on the plane. 
    output_plane = rt.OutputPlane(rt.focal_point2(lens1, lens2), 10000)
    for ray in bundle:
        lens1.propagate_ray(ray)
        lens2.propagate_ray(ray)
        output_plane.propagate_ray(ray)
        x = []
        z = []
        for position in ray.positions:
            x.append(position[0])
            z.append(position[2]) 
        plt.plot(z,x)
    plt.xlabel('z axis /mm')
    plt.ylabel('x axis /mm')
    plt.show()