Example #1
0
optimi = Optimizer(s,
                   meritfunctionrms,
                   backend=opt_backend,
                   updatefunction=osupdate)
optimi.logger.setLevel(logging.DEBUG)
s = optimi.run()

r2 = s.seqtrace(initialbundle, sysseq)  # trace again

for r in r2:
    r.draw2d(ax2, color="blue", plane_normal=pn, up=up)

listOptimizableVariables(s, filter_status='variable', max_line_width=80)

s.draw2d(ax2, color="grey", vertices=50, plane_normal=pn, up=up)  # try phi=0.
# s.draw2d(ax, color="grey", inyzplane=False, vertices=50, plane_normal=pn, up=up) # try for phi=pi/4

osa.aim(500, divbundledict, wave=wavelength)
osa.draw_spotdiagram()
sa = ShapeAnalysis(surf1.shape)
sa.plot(np.linspace(-1, 1, 10), np.linspace(-1, 1, 10), contours=100, axes=ax3)

plt.show()

plt.subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0)
# plots.drawLayout2d(ax2, s, [r2, r3, r4])
plt.subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0)
# plots.draw_spotdiagram(ax3, s, r3, -1)
# plt.subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0)
Example #2
0
if s is None:
    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()
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)
Example #4
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")])