예제 #1
0
# fig15 = plt.figure(15)
# ax3 = fig15.add_subplot(111)
#
# 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)

sysseq = [("lenssys", [("object", {}), ("surf1", {}), ("surf2", {}),
                       ("surf3", {}), ("surf4", {}), ("stop", {
                           "is_stop": True
                       }), ("surf6", {}), ("surf7", {}), ("image", {})])]

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

divbundledict = {"radius": 10 * degree, "raster": RandomGrid()}
(o, k, E0) = osa.divergent_bundle(900, divbundledict, wave=wavelength)
initialbundle = RayBundle(x0=o, k0=k, Efield0=E0)
r2 = s.seqtrace(initialbundle, sysseq)

fig = plt.figure(1)
ax = fig.add_subplot(311)
ax2 = fig.add_subplot(312)
ax3 = fig.add_subplot(313)

ax.axis('equal')
ax2.axis('equal')
if StrictVersion(matplotlib.__version__) < StrictVersion('2.0.0'):
    ax.set_axis_bgcolor('white')
예제 #2
0
      }), (3.125, 0, 2.0, 1.5, "surf5", {}),
      (1.479, 0, 3.0, None, "surf6", {}), (0, 0, 19.0, None, "surf7", {})],
     material_db_path=db_path)


def mytiming():
    if sys.version_info.major >= 3:
        return time.perf_counter()
    else:
        return time.clock()


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 = 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) /
예제 #3
0
surf = fi1.create_surfaces(cs)

#create material
fi1.create_material(cs, elem1, surf)
#######################################Neuende##################################

# ----------- assemble optical system
s.addElement(elem1.name, elem1)

# II---------------------- optical system analysis
# --- 1. elem

sysseq = fi1.get_sysseq(elem1)

# ----------- define optical system analysis object
osa = OpticalSystemAnalysis(s, sysseq)

# III ----------- defining raybundles for optimization and plotting
rays_dict = fi1.get_rays_dict()

#rays_dict = {"startz":[0], "starty": [0], "radius": [16],
#             "anglex": [0., 0.1832595],
#             "rasterobj":raster.RectGrid()}

#wavelength = [0.5875618e-3, 0.4861327e-3, 0.6562725e-3]
#numrays = 50
sample_param = 'bundle'

(initialbundle, meritfunctionrms) = get_bundle_merit(osa,
                                                     s,
                                                     sysseq,
예제 #4
0
epd = 5.

(s, seq) = build_rotationally_symmetric_optical_system(
    [(0, 0, 0., None, "object", {}),
     (100., 0, 5, 1.5, "lens1front", {
         "is_stop": True
     }), (0., 0, 5, None, "lens1rear", {}),
     (0, 0, 196.228, None, "image", {})],
    name="os")

imsurf = s.elements["stdelem"].surfaces["image"]
imsurf.rootcoordinatesystem.tiltx.set_value(alpha)
imsurf.rootcoordinatesystem.update()
objsurf = s.elements["stdelem"].surfaces["object"]
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
})
(x03, k03, E03) = osa.collimated_bundle(11, {
    "radius": epd,
    "raster": MeridionalFan(),
    "anglex": -1. * degree
})
예제 #5
0
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)
예제 #6
0
파일: demo_zmx.py 프로젝트: mniehus/pyrate
lctmp = LocalCoordinates.p("tmp")

matdict = {
    "BK7": ConstantIndexGlass.p(lctmp, 1.5168),
    "LAFN21": ConstantIndexGlass.p(lctmp, 1.788),
    "SF53": ConstantIndexGlass.p(lctmp, 1.72)
}

(s, seq) = p.create_optical_system(matdict)

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)
예제 #7
0
}, 1.5168, "front", {}),
                                           ({
                                               "shape": "Asphere",
                                               "curv": -1. / 50.,
                                               "cc": -1.,
                                               "coefficients": [0.0, 0.0, 0.0]
                                           }, {
                                               "decz": 20.0
                                           }, None, "back", {}),
                                           ({
                                               "shape": "Conic"
                                           }, {
                                               "decz": 100.0
                                           }, None, "image", {})], )

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

(o, k, E0) = osa.collimated_bundle(121, {
    "startz": -5.,
    "radius": 11.43
},
                                   wave=wavelength)
initialbundle = RayBundle(x0=o, k0=k, Efield0=E0, wave=wavelength)

# initialbundle = generatebundle(openangle=10.*math.pi/180, numrays=121)


def meritfunctionrms(my_s):
    """
    Standard rms spot radius merit function without removing centroid.
    """
예제 #8
0
}), ("m2", {
    "is_mirror": True
}), ("m1", {
    "is_mirror": True
}), ("m2", {
    "is_mirror": True
}), ("m1", {
    "is_mirror": True
}), ("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,
예제 #9
0
elem.addSurface("d4p", D4Psurf, (None, None))
elem.addSurface("image", imgsurf, (None, None))

s.addElement("HUD", elem)

print(s.rootcoordinatesystem.pprint())

sysseq = [("HUD", [("object", {
    "is_stop": True
}), ("d1", {}), ("s1", {}), ("d1p", {}), ("d2", {}), ("s2", {
    "is_mirror": True
}), ("d2p", {}), ("d3", {}), ("s3", {
    "is_mirror": True
}), ("d3p", {}), ("d4", {}), ("s4", {}), ("d4p", {}), ("image", {})])]

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

print("collimated bundles")
(o, k1, E1) = osa.collimated_bundle(3, {
    "radius": 2,
    "raster": raster.MeridionalFan()
},
                                    wave=standard_wavelength)
(o, k2, E2) = osa.collimated_bundle(3, {
    "radius": 2,
    "raster": raster.MeridionalFan(),
    "anglex": 15 * degree
},
                                    wave=standard_wavelength)
(o, k3, E3) = osa.collimated_bundle(3, {
    "radius": 2,