Example #1
0
def main():

    grating = Grating(pitch=3.3, height=100, angle=math.radians(0))

    #print(repr(grating[0]))
    #print(repr(grating[1]))

    #disc = Disc(-50,10)
    #pencil = RayPencil().addBeam(disc,0.0).addMonitor(RayPath())
    ip = ImagePlane(50, xsize=30)
    orders = [0, 1, 2, 3]
    for order in orders:

        pencil = RayPencil().addRays(
            -60, math.radians(0), [0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7])
        pencil.addMonitor(RayPath())

        pencil *= grating

        for ray in pencil:
            yi = ray.director.y
            ym = yi + order * ray.wavelength / grating.pitch
            zm = math.sqrt(1.0 - ym * ym)
            ray.director = Unit3d(0.0, ym, zm)

        pencil *= ip

        pencil.draw()

    grating.draw()
    ip.draw()
    plt.axis("equal")
    plt.grid()
    plt.show()
Example #2
0
def main():

    #       Make a set of surface
    op = ImagePlane(-100, 30)
    ca = CircularAperture(-10, 20)
    ia = IrisAperture(50, 15).setRatio(0.7)
    fs = SphericalSurface(20, 0.025, 15, "BK7")
    bs = SphericalSurface(30, -0.025, 15, "air")
    ip = ImagePlane(60, 40)

    #      Plot them in a simple diagram
    op.draw()
    ca.draw()
    ia.draw()
    fs.draw()
    bs.draw()
    ip.draw()
    plt.axis("equal")  # Set the x/y axis to the same scale
    plt.show()