Exemple #1
0
elem = OpticalElement(lc0, name="thorlabs_AC_254-100-A")

bk7 = ConstantIndexGlass(lc1, n=1.5168)
sf5 = ConstantIndexGlass(lc2, n=1.6727)

elem.addMaterial("BK7", bk7)
elem.addMaterial("SF5", sf5)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("front", frontsurf, (None, "BK7"))
elem.addSurface("cement", cementsurf, ("BK7", "SF5"))
elem.addSurface("rear", rearsurf, ("SF5", None))
elem.addSurface("image", image, (None, None))

s.addElement("AC254-100", elem)

sysseq = [("AC254-100", [("stop", {
    "is_stop": True
}), ("front", {}), ("cement", {}), ("rear", {}), ("image", {})])]

r2 = raytrace(s,
              sysseq,
              20, {
                  "startz": -5,
                  "radius": 11.43,
                  "raster": raster.MeridionalFan()
              },
              wave=wavelength)[0]

draw(s, (r2, "blue"))
Exemple #2
0
(x01, k01, E01) = osa.collimated_bundle(11, {"radius": epd,
                                             "raster": MeridionalFan()})
(x02, k02, E02) = osa.collimated_bundle(11, {"radius": epd,
                                             "raster": MeridionalFan(),
                                             "anglex": 1.*degree})
(x03, k03, E03) = osa.collimated_bundle(11, {"radius": epd,
                                             "raster": MeridionalFan(),
                                             "anglex": -1.*degree})

mybundle1 = RayBundle(x01, k01, E01)
mybundle2 = RayBundle(x02, k02, E02)
mybundle3 = RayBundle(x03, k03, E03)

raypaths1 = s.seqtrace(mybundle1, seq)
raypaths2 = s.seqtrace(mybundle2, seq)
raypaths3 = s.seqtrace(mybundle3, seq)

obj_dx = 0.1
obj_dphi = 0.1*degree

pilotbundles = build_pilotbundle_complex(objsurf, s.material_background,
                                         (obj_dx, obj_dx),
                                         (obj_dphi, obj_dphi),
                                         num_sampling_points=3)
(m_obj_stop, m_stop_img) = s.extractXYUV(pilotbundles[-1], seq)

print(np.array_str(m_obj_stop, precision=5, suppress_small=True))
print(np.array_str(m_stop_img, precision=5, suppress_small=True))

draw(s, [raypaths1, raypaths2, raypaths3])
Exemple #3
0
#myeps1 = rnd_data1 + complex(0, 1)*rnd_data2
#myeps2 = rnd_data3 + complex(0, 1)*rnd_data4

crystal1 = AnisotropicMaterial(lc1, myeps1, name="crystal1")
crystal2 = AnisotropicMaterial(lc2, myeps2, name="crystal2")

elem.addMaterial("crystal1", crystal1)
elem.addMaterial("crystal2", crystal2)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("front", frontsurf, (None, "crystal1"))
elem.addSurface("cement", cementsurf, ("crystal1", "crystal2"))
elem.addSurface("rear", rearsurf, ("crystal2", None))
elem.addSurface("image", image, (None, None))

s.addElement("AC254-100", elem)

sysseq = [("AC254-100", [("stop", {}), ("front", {}), ("cement", {}),
                         ("rear", {}), ("image", {})])]

osa = OpticalSystemAnalysis(s, sysseq, name="Analysis")
osa.aim(10, {
    "radius": 11.43,
    "startz": -5.,
    "raster": raster.MeridionalFan()
},
        bundletype="collimated",
        wave=wavelength)
r2 = osa.trace(splitup=True)[0]
draw(s, [(r2[0], "blue"), (r2[1], "green")])
myeps = np.array([[no, 0, 0], [0, no, 0], [0, 0, neo]])

crystal = AnisotropicMaterial.p(lc1, myeps)

elem.addMaterial("crystal", crystal)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("front", frontsurf, (None, "crystal"))
elem.addSurface("rear", rearsurf, ("crystal", "crystal"))
elem.addSurface("image", image, ("crystal", None))

s.addElement("crystalelem", elem)

sysseq = [("crystalelem", [("stop", {}), ("front", {}),
                           ("rear", {
                               "is_mirror": True
                           }), ("image", {})])]

rays = raytrace(s,
                sysseq,
                10, {
                    "radius": 20 * degree,
                    "startz": -5.,
                    "raster": raster.MeridionalFan()
                },
                bundletype="divergent",
                traceoptions={"splitup": True},
                wave=wavelength)

draw(s, rays)
Exemple #5
0
}), ("m2", {
    "is_mirror": True
})])]

obj_dx = 0.1
obj_dphi = 1. * degree

osa = OpticalSystemAnalysis(s, sysseq, name="Analysis")

raysdict = {
    "opticalsystem": s,
    "startz": -5.,
    "radius": 10.,
    "raster": raster.MeridionalFan()
}
osa.aim(5, raysdict, bundletype="collimated", wave=wavelength)

r2 = osa.trace()[0]

kw = 5. * degree

pilotbundles = build_pilotbundle(
    objectsurf,
    crystal, (obj_dx, obj_dx), (obj_dphi, obj_dphi),
    kunitvector=np.array([0, math.sin(kw), math.cos(kw)]),
    num_sampling_points=3)
(pilotray2, r3) = s.para_seqtrace(pilotbundles[-1], osa.initial_bundles[0],
                                  sysseq)

draw(s, [(r2, "blue"), (r3, "orange"), (pilotray2, "red")])
# myeps1 = rnd_data1 + complex(0, 1)*rnd_data2
# myeps2 = rnd_data3 + complex(0, 1)*rnd_data4

crystal1 = AnisotropicMaterial(lc1, myeps1, name="crystal1")
crystal2 = AnisotropicMaterial(lc2, myeps2, name="crystal2")


elem.addMaterial("crystal1", crystal1)
elem.addMaterial("crystal2", crystal2)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("front", frontsurf, (None, "crystal1"))
elem.addSurface("cement", cementsurf, ("crystal1", "crystal2"))
elem.addSurface("rear", rearsurf, ("crystal2", None))
elem.addSurface("image", image, (None, None))

s.addElement("AC254-100", elem)

sysseq = [("AC254-100", [("stop", {}), ("front", {}), ("cement", {}),
                         ("rear", {}), ("image", {})])]

osa = OpticalSystemAnalysis(s, sysseq, name="Analysis")
osa.aim(11, {"radius": 11.43, "startz": -5., "raster": raster.MeridionalFan()},
        bundletype="collimated", wave=wavelength)
r2 = osa.trace(splitup=True)[0]
draw(s, [(r2[0], "blue"), (r2[1], "green")],
     interactive=True,
     show_box=False,
     figsize=None,
     export=None)
Exemple #7
0
    "anglex": 1. * degree
})
(x03, k03, E03) = osa.collimated_bundle(11, {
    "radius": epd,
    "raster": MeridionalFan(),
    "anglex": -1. * degree
})

mybundle1 = RayBundle(x01, k01, E01)
mybundle2 = RayBundle(x02, k02, E02)
mybundle3 = RayBundle(x03, k03, E03)

raypaths1 = s.seqtrace(mybundle1, seq)
raypaths2 = s.seqtrace(mybundle2, seq)
raypaths3 = s.seqtrace(mybundle3, seq)

obj_dx = 0.1
obj_dphi = 0.1 * degree

pilotbundles = build_pilotbundle_complex(objsurf,
                                         s.material_background,
                                         (obj_dx, obj_dx),
                                         (obj_dphi, obj_dphi),
                                         num_sampling_points=3)
(m_obj_stop, m_stop_img) = s.extractXYUV(pilotbundles[-1], seq)

print(np.array_str(m_obj_stop, precision=5, suppress_small=True))
print(np.array_str(m_stop_img, precision=5, suppress_small=True))

draw(s, [raypaths1, raypaths2, raypaths3])
Exemple #8
0
obj_dx = 0.1
obj_dphi = 5 * degree

print("calculating pilotbundles")
pilotbundles = build_pilotbundle_complex(objsurf,
                                         air, (obj_dx, obj_dx),
                                         (obj_dphi, obj_dphi),
                                         num_sampling_points=3)

# print("seqtrace of rays_pilot")
# rays_pilot = [s.seqtrace(p, sysseq) for p in pilotbundles[2:]]
# only last two bundles hit the next surface

# print("para seqtrace")
# (pilotray, r_pilot) = s.para_seqtrace(pilotbundles[-1], initialbundle1,
#                                       sysseq)

print("calculating XYUV")
(m_obj_stop, m_stop_img) = s.extractXYUV(pilotbundles[-1], sysseq)

print(np.array_str(m_obj_stop, precision=5, suppress_small=True))
print(np.array_str(m_stop_img, precision=5, suppress_small=True))

# print(s.sequence_to_hitlist(sysseq))

draw(s, [r1, r2, r3])

# pz = np.array([26.36, 33.339, 18.817])
# py = np.array([-24.028, 19.109, -35.215])
Exemple #9
0
elem = OpticalElement(lc0, name="thorlabs_AC_254-100-A")

bk7 = ConstantIndexGlass(lc1, n=1.5168)
sf5 = ConstantIndexGlass(lc2, n=1.6727)

elem.addMaterial("BK7", bk7)
elem.addMaterial("SF5", sf5)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("front", frontsurf, (None, "BK7"))
elem.addSurface("cement", cementsurf, ("BK7", "SF5"))
elem.addSurface("rear", rearsurf, ("SF5", None))
elem.addSurface("image", image, (None, None))

s.addElement("AC254-100", elem)

sysseq = [("AC254-100",
           [
            ("stop", {"is_stop": True}),
            ("front", {}),
            ("cement", {}),
            ("rear", {}),
            ("image", {})])]


r2 = raytrace(s, sysseq, 20,
              {"startz": -5, "radius": 11.43, "raster": raster.MeridionalFan()},
              wave=wavelength)[0]

draw(s, (r2, "blue"))
Exemple #10
0
obj_dphi = 5*degree

print("calculating pilotbundles")
pilotbundles = build_pilotbundle_complex(objsurf,
                                         air,
                                         (obj_dx, obj_dx),
                                         (obj_dphi, obj_dphi),
                                         num_sampling_points=3)

# print("seqtrace of rays_pilot")
# rays_pilot = [s.seqtrace(p, sysseq) for p in pilotbundles[2:]]
# only last two bundles hit the next surface

# print("para seqtrace")
# (pilotray, r_pilot) = s.para_seqtrace(pilotbundles[-1], initialbundle1,
#                                       sysseq)

print("calculating XYUV")
(m_obj_stop, m_stop_img) = s.extractXYUV(pilotbundles[-1], sysseq)

print(np.array_str(m_obj_stop, precision=5, suppress_small=True))
print(np.array_str(m_stop_img, precision=5, suppress_small=True))

# print(s.sequence_to_hitlist(sysseq))


draw(s, [r1, r2, r3])

# pz = np.array([26.36, 33.339, 18.817])
# py = np.array([-24.028, 19.109, -35.215])
Exemple #11
0

initbundle1 = a.aim(np.array([0, 0]))
initbundle2 = a.aim(np.array([0, 0.5*degree]))
initbundle3 = a.aim(np.array([0, -0.5*degree]))

(pp1, r1p) = s.para_seqtrace(a.pilotbundle, initbundle1, sysseq)
(pp2, r2p) = s.para_seqtrace(a.pilotbundle, initbundle2, sysseq)
(pp3, r3p) = s.para_seqtrace(a.pilotbundle, initbundle3, sysseq)

r1r = s.seqtrace(initbundle1, sysseq)
r2r = s.seqtrace(initbundle2, sysseq)
r3r = s.seqtrace(initbundle3, sysseq)


draw(s, [(r1p, "blue"), (r2p, "green"), (r3p, "orange")])
# draw(s, [(r1r, "blue"), (r2r, "green"), (r3r, "orange")])


# TODO:
# first tries to implement aiming, but the code is somewhat hard to use
# we need to get rid of the pilot ray in every call
# we need to convert between XK representation local 3D coordinates and
# global raybundle coordinates in a more easy way
#
# oea = OpticalElementAnalysis(s.elements["TMA"])
#
# xyuvobjectstop = oea.calcXYUV([("object", "m1", 1), ("m1", "m2", 1)],
#                               pilotbundle2, sysseq[0][1], air)
#
# Axyuv = xyuvobjectstop[0:2, 0:2]
Exemple #12
0

initbundle1 = a.aim(np.array([0, 0]))
initbundle2 = a.aim(np.array([0, 0.5*degree]))
initbundle3 = a.aim(np.array([0, -0.5*degree]))

(pp1, r1p) = s.para_seqtrace(a.pilotbundle, initbundle1, sysseq)
(pp2, r2p) = s.para_seqtrace(a.pilotbundle, initbundle2, sysseq)
(pp3, r3p) = s.para_seqtrace(a.pilotbundle, initbundle3, sysseq)

r1r = s.seqtrace(initbundle1, sysseq)
r2r = s.seqtrace(initbundle2, sysseq)
r3r = s.seqtrace(initbundle3, sysseq)


draw(s, [(r1p, "blue"), (r2p, "green"), (r3p, "orange")])
# draw(s, [(r1r, "blue"), (r2r, "green"), (r3r, "orange")])


# TODO:
# first tries to implement aiming, but the code is somewhat hard to use
# we need to get rid of the pilot ray in every call
# we need to convert between XK representation local 3D coordinates and
# global raybundle coordinates in a more easy way
#
# oea = OpticalElementAnalysis(s.elements["TMA"])
#
# xyuvobjectstop = oea.calc_xyuv([("object", "m1", 1), ("m1", "m2", 1)],
#                                pilotbundle2, sysseq[0][1], air)
#
# Axyuv = xyuvobjectstop[0:2, 0:2]
Exemple #13
0
elem.addMaterial("water", water)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("surf1", frontsurf, (None, "water"))
elem.addSurface("surf2", rearsurf, ("water", "water"))
elem.addSurface("surf4", frontsurf, ("water", None))
elem.addSurface("image", image, (None, None))

s.addElement("droplet", elem)

sysseq = [("droplet",
           [
                ("stop", {"is_stop": True}),
                ("surf1", {}),
                ("surf2", {"is_mirror": True}),
                ("surf4", {}),
                ("image", {})])]

raysdict = {
     "radius": dropletradius*0.05,
     "starty": dropletradius*0.9,
     "anglex": -12.*degree,
     "raster": raster.MeridionalFan()
     }

r_red = raytrace(s, sysseq, 11, raysdict, wave=wave_red)[0]
r_blue = raytrace(s, sysseq, 11, raysdict, wave=wave_blue)[0]

draw(s, [(r_red, "red"), (r_blue, "blue")])
Exemple #14
0
if s is None:
    sys.exit()

initialbundles_dict = p.createInitialBundle()

osa = OpticalSystemAnalysis(s, seq, name="Analysis")

ray_paths = []

if initialbundles_dict == []:
    initialbundles_dict = [{"radius": enpd*0.5}]

for d in initialbundles_dict:
    if show_spot:
        d["raster"] = raster.RectGrid()
        osa.aim(num_rays*num_rays, d, wave=standard_wavelength)
        osa.drawSpotDiagram()
    else:
        d["raster"] = raster.MeridionalFan()
        d["anglex"] = anglex
        osa.aim(num_rays, d, wave=standard_wavelength)
        ray_paths.append(osa.trace()[0])

if not show_spot:
    draw(s, ray_paths, do_not_draw_surfaces=surfaces_do_not_draw,
         do_not_draw_raybundles=raybundles_do_not_draw)
else:
    plt.show()
osa.prettyprint()
Exemple #15
0
                                     dndx,
                                     dndy,
                                     dndz,
                                     parameterlist=[("n0", 0.5)])
grinmaterial.ds = 0.05
grinmaterial.energyviolation = 0.01
grinmaterial.boundaryfunction = bnd

elem.addMaterial("grin", grinmaterial)

elem.addSurface("object", stopsurf, (None, None))
elem.addSurface("surf1", surf1, (None, "grin"))
elem.addSurface("surf2", surf2, ("grin", None))
elem.addSurface("image", image, (None, None))

s.addElement("grinelement", elem)

sysseq = [("grinelement", [("object", {
    "is_stop": True
}), ("surf1", {}), ("surf2", {}), ("image", {})])]

r2 = raytrace(s,
              sysseq,
              21, {
                  "startz": -5.,
                  "radius": 2.5,
                  "raster": raster.MeridionalFan()
              },
              wave=wavelength)
draw(s, r2)
Exemple #16
0
    """
    initialbundle_local = RayBundle(x0=o, k0=k, Efield0=E0, wave=wavelength)
    rpaths = my_s.seqtrace(initialbundle_local, sysseq)
    # other constructions lead to fill up of initial bundle with intersection
    # values

    # for glassy asphere only one path necessary
    x = rpaths[0].raybundles[-1].x[-1, 0, :]
    y = rpaths[0].raybundles[-1].x[-1, 1, :]

    res = np.sum(x**2 + y**2)

    return res


backsurf = s.elements["stdelem"].surfaces["back"]
backsurf.shape.params["curv"].changetype("variable")
backsurf.shape.params["cc"].changetype("variable")
# A2 not variable
backsurf.shape.params["A4"].changetype("variable")
backsurf.shape.params["A6"].changetype("variable")

opt_backend = ScipyBackend(method='Nelder-Mead', tol=1e-9)
optimi = Optimizer(s, meritfunctionrms, opt_backend,
                   name="Nelder-Mead Optimizer")
s = optimi.run()

r2 = s.seqtrace(initialbundle, sysseq)

draw(s, r2)
Exemple #17
0
    sys.exit()

initialbundles_dict = p.create_initial_bundle()

osa = OpticalSystemAnalysis(s, seq, name="Analysis")

ray_paths = []

if initialbundles_dict == []:
    initialbundles_dict = [{"radius": enpd * 0.5}]

for d in initialbundles_dict:
    if show_spot:
        d["raster"] = raster.RectGrid()
        osa.aim(num_rays * num_rays, d, wave=standard_wavelength)
        osa.draw_spotdiagram()
    else:
        d["raster"] = raster.MeridionalFan()
        d["anglex"] = anglex
        osa.aim(num_rays, d, wave=standard_wavelength)
        ray_paths.append(osa.trace()[0])

if not show_spot:
    draw(s,
         ray_paths,
         do_not_draw_surfaces=surfaces_do_not_draw,
         do_not_draw_raybundles=raybundles_do_not_draw)
else:
    plt.show()
osa.prettyprint()
                 ])
                ]


obj_dx = 0.1
obj_dphi = 1.*degree

osa = OpticalSystemAnalysis(s, sysseq, name="Analysis")

raysdict = {"opticalsystem": s, "startz": -5., "radius": 10.,
            "raster": raster.MeridionalFan()}
osa.aim(5, raysdict, bundletype="collimated", wave=wavelength)

r2 = osa.trace()[0]


kw = 5.*degree

pilotbundles = build_pilotbundle(objectsurf,
                                 crystal,
                                 (obj_dx, obj_dx),
                                 (obj_dphi, obj_dphi),
                                 kunitvector=np.array([0,
                                                       math.sin(kw),
                                                       math.cos(kw)]),
                                 num_sampling_points=3)
(pilotray2, r3) = s.para_seqtrace(pilotbundles[-1],
                                  osa.initial_bundles[0], sysseq)

draw(s, [(r2, "blue"), (r3, "orange"), (pilotray2, "red")])
crystal2 = AnisotropicMaterial(lc2, myeps2, name="crystal2")

elem.addMaterial("crystal1", crystal1)
elem.addMaterial("crystal2", crystal2)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("front", frontsurf, (None, "crystal1"))
elem.addSurface("cement", cementsurf, ("crystal1", "crystal2"))
elem.addSurface("rear", rearsurf, ("crystal2", None))
elem.addSurface("image", image, (None, None))

s.addElement("AC254-100", elem)

sysseq = [("AC254-100", [("stop", {}), ("front", {}), ("cement", {}),
                         ("rear", {}), ("image", {})])]

osa = OpticalSystemAnalysis(s, sysseq, name="Analysis")
osa.aim(11, {
    "radius": 11.43,
    "startz": -5.,
    "raster": raster.MeridionalFan()
},
        bundletype="collimated",
        wave=wavelength)
r2 = osa.trace(splitup=True)[0]
draw(s, [(r2[0], "blue"), (r2[1], "green")],
     interactive=True,
     show_box=False,
     figsize=None,
     export=None)
Exemple #20
0
nrays = 100000
nrays_draw = 21

osa = OpticalSystemAnalysis(s, seq, name="Analysis")

(x0, k0, E0) = osa.divergent_bundle(nrays,
                                    {"radius": 10.*degree,
                                     "raster": raster.RectGrid()})
t0 = time.clock()
initialraybundle = RayBundle(x0=x0, k0=k0, Efield0=E0)
raypath = s.seqtrace(initialraybundle, seq)
logging.info("benchmark : " + str(time.clock() - t0) +
             "s for tracing " + str(nrays) + " rays through " +
             str(len(s.elements["stdelem"].surfaces) - 1) + " surfaces.")
logging.info("That is " +
             str(int(round(nrays * (len(s.elements["stdelem"].surfaces) - 1)
                           / (time.clock() - t0)))) +
             "ray-surface-operations per second")

# plot

(x0_draw, k0_draw, E0_draw) =\
    osa.divergent_bundle(nrays_draw,
                         {"radius": 10.*degree,
                          "raster": raster.MeridionalFan()})
initialraybundle_draw = RayBundle(x0=x0_draw, k0=k0_draw, Efield0=E0_draw)
raypath_draw = s.seqtrace(initialraybundle_draw, seq)


draw(s, raypath_draw)
Exemple #21
0
options = {
    'gcat': gcat,
    'db_path': db_path
}

try:
    # TODO: this relative path is not very beautiful
    spd = SPDParser("demos/data/double_gauss_rudolph_1897_v2.SPD",
                    name="rudolph2")
except FileNotFoundError:
    pass
else:
    (s, seq) = spd.create_optical_system(options=options)

    draw(s)

    def bundle(fpx, fpy, nrays=16, rpup=5):
        """
        Creates a RayBundle

        * o is the origin - this is ok
        * k is the wave vector, i.e. direction; needs to be normalized
        * E0 is the polarization vector

        """

        (px, py) = RectGrid().getGrid(nrays)

        #pts_on_first_surf = np.vstack((rpup*px, rpup*py, np.zeros_like(px)))
        pts_on_entrance_pupil = np.vstack(
myeps = np.array([[no, 0, 0], [0, no, 0], [0, 0, neo]])

crystal = AnisotropicMaterial(lc1, myeps)


elem.addMaterial("crystal", crystal)

elem.addSurface("stop", stopsurf, (None, None))
elem.addSurface("front", frontsurf, (None, "crystal"))
elem.addSurface("rear", rearsurf, ("crystal", "crystal"))
elem.addSurface("image", image, ("crystal", None))

s.addElement("crystalelem", elem)

sysseq = [
    ("crystalelem", [
        ("stop", {}),
        ("front", {}),
        ("rear", {"is_mirror": True}),
        ("image", {})]
     )]

rays = raytrace(s, sysseq, 10,
                {"radius": 20*degree, "startz": -5.,
                 "raster": raster.MeridionalFan()},
                bundletype="divergent", traceoptions={"splitup": True},
                wave=wavelength)


draw(s, rays)
Exemple #23
0
nrays_draw = 21

osa = OpticalSystemAnalysis(s, seq, name="Analysis")

(x0, k0, E0) = osa.divergent_bundle(nrays, {
    "radius": 10. * degree,
    "raster": raster.RectGrid()
})
t0 = mytiming()
initialraybundle = RayBundle(x0=x0, k0=k0, Efield0=E0)
t1 = mytiming()
raypath = s.seqtrace(initialraybundle, seq)
t2 = mytiming()
logging.info("benchmark : " + str(t2 - t1) + " s for tracing " + str(nrays) +
             " rays through " + str(len(s.elements["stdelem"].surfaces) - 1) +
             " surfaces.")
logging.info("That is " + str(
    int(round(nrays * (len(s.elements["stdelem"].surfaces) - 1) /
              (t2 - t1)))) + " ray-surface-operations per second")

# plot

(x0_draw, k0_draw, E0_draw) =\
    osa.divergent_bundle(nrays_draw,
                         {"radius": 10.*degree,
                          "raster": raster.MeridionalFan()})
initialraybundle_draw = RayBundle(x0=x0_draw, k0=k0_draw, Efield0=E0_draw)
raypath_draw = s.seqtrace(initialraybundle_draw, seq)

draw(s, raypath_draw)
Exemple #24
0
(s, seq) = p.createOpticalSystem(matdict)

if s is None:
    sys.exit()

initialbundles_dict = p.createInitialBundle()

osa = OpticalSystemAnalysis(s, seq, name="Analysis")

ray_paths = []

if initialbundles_dict == []:
    initialbundles_dict = [{"radius": enpd * 0.5}]

for d in initialbundles_dict:
    if show_spot:
        d["raster"] = raster.RectGrid()
        osa.aim(num_rays * num_rays, d, wave=standard_wavelength)
        osa.drawSpotDiagram()
    else:
        d["raster"] = raster.MeridionalFan()
        d["anglex"] = anglex
        osa.aim(num_rays, d, wave=standard_wavelength)
        ray_paths.append(osa.trace()[0])

if not show_spot:
    draw(s, ray_paths)
else:
    plt.show()
osa.prettyprint()
Exemple #25
0
                ("surf1", {}),
                ("surf2", {"is_mirror": True}),
                ("surf4", {}),
                ("image", {})])]

raysdict = {
     "radius": dropletradius*0.05,
     "starty": dropletradius*0.9,
     "anglex": -12.*degree,
     "raster": raster.MeridionalFan()
     }

r_red = raytrace(s, sysseq, 11, raysdict, wave=wave_red)[0]
r_blue = raytrace(s, sysseq, 11, raysdict, wave=wave_blue)[0]

draw(s, [(r_red, "red"), (r_blue, "blue")])

system_dump = Serializer(s).serialization
system_gui_toplevel = UIInterfaceClassWithOptimizableVariables(
        s.elements["droplet"].surfaces["surf4"].shape).query_for_dictionary()

#pprint(system_gui_toplevel)
#pprint(system_dump)

fp = open("rainbow.yaml", "wt")
yaml.dump(system_dump, fp)
fp.close()


fp = open("rainbow.json", "wt")
json.dump(system_dump, fp, indent=4)
Exemple #26
0
osa = OpticalSystemAnalysis(s, seq, name="Analysis")
(x01, k01, E01) = osa.collimated_bundle(11, {
    "radius": epd,
    "raster": MeridionalFan()
})
(x02, k02, E02) = osa.collimated_bundle(11, {
    "radius": epd,
    "raster": MeridionalFan(),
    "anglex": 1. * degree
})
mybundle1 = RayBundle(x01, k01, E01)
mybundle2 = RayBundle(x02, k02, E02)

raypaths1 = s.seqtrace(mybundle1, seq)
raypaths2 = s.seqtrace(mybundle2, seq)

obj_dx = 0.1
obj_dphi = 0.1 * degree

pilotbundles = build_pilotbundle_complex(objsurf,
                                         s.material_background,
                                         (obj_dx, obj_dx),
                                         (obj_dphi, obj_dphi),
                                         num_sampling_points=3)
(m_obj_stop, m_stop_img) = s.extractXYUV(pilotbundles[-1], seq)

print(np.array_str(m_obj_stop, precision=5, suppress_small=True))
print(np.array_str(m_stop_img, precision=5, suppress_small=True))

draw(s, [raypaths1, raypaths2])