示例#1
0
db_path = "refractiveindex.info-database/database"

(s,
 seq) = build_rotationally_symmetric_optical_system(
     [(-5.922, 0, 2.0, 1.7, "surf1", {}), (-3.160, 0, 3.0, None, "surf2", {}),
      (15.884, 0, 5.0, 1.7, "surf3", {}), (-12.756, 0, 3.0, None, "surf4", {}),
      (0, 0, 3.0, None, "stop", {
          "is_stop": True
      }), (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)

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")
示例#2
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,
示例#3
0
lctmp = LocalCoordinates("tmp")

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

(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)
示例#4
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(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)
示例#5
0
                    ("m1", {"is_mirror": True}),
                    ("m2", {"is_mirror": True}),
                    ("m3", {"is_mirror": True}),
                    ("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,
                                 crystal,
                                 (obj_dx, obj_dx),
                                 (obj_dphi, obj_dphi),
                                 kunitvector=np.array([0,
示例#6
0
(s, seq) = build_rotationally_symmetric_optical_system(
        [(-5.922, 0, 2.0, 1.7, "surf1", {}),
         (-3.160, 0, 3.0, None, "surf2", {}),
         (15.884, 0, 5.0, 1.7, "surf3", {}),
         (-12.756, 0, 3.0, None, "surf4", {}),
         (0, 0, 3.0, None, "stop", {"is_stop": True}),
         (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)

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")
示例#7
0
# 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')
示例#8
0
wavelength = 0.5876e-3

# definition of optical system
(s, sysseq) = build_simple_optical_system(
                [
                 ({"shape": "Conic"}, {"decz": 0.0}, None, "stop",
                  {"is_stop": True}),
                 ({"shape": "Conic"}, {"decz": 5.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.
    """
    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
示例#9
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.drawSpotDiagram(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')
示例#10
0
文件: demo_hud.py 项目: joha2/pyrate
                ("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,
                                        "raster": raster.MeridionalFan(),
                                        "anglex": -15*degree},
                                    wave=standard_wavelength)

示例#11
0
                                        np.exp(-np.linspace(0, 10, 20)))
optimi = Optimizer(s, \
                    meritfunctionrms, \
                    backend=opt_backend, \
                    updatefunction=osupdate)
optimi.logger.setLevel(logging.DEBUG)
s = optimi.run()

r2 = s.seqtrace(initialbundle, sysseq)  # trace again
print("drawing!")
for r in r2:
    r.draw2d(ax2, color="blue", plane_normal=pn, up=up)

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

s.draw2d(ax2, color="grey", vertices=50, plane_normal=pn,
         up=up)  # try for phi=0.
#s.draw2d(ax, color="grey", inyzplane=False, vertices=50, plane_normal=pn, up=up) # try for phi=pi/4
osa = OpticalSystemAnalysis(s)
osa.drawSpotDiagram(r2[0], sysseq)
sa = ShapeAnalysis(surf1.shape)
sa.plot(np.linspace(-1, 1, 10), np.linspace(-1, 1, 10), contours=100, ax=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.drawSpotDiagram(ax3, s, r3, -1)
#plt.subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0)
示例#12
0
文件: demo_zmx.py 项目: joha2/pyrate
p = ZMXParser(file_to_read, name='ZMXParser')
lctmp = LocalCoordinates("tmp")

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

(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)
示例#13
0
alpha = 10.*degree

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.setvalue(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})

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)
示例#14
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.setvalue(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
})
mybundle1 = RayBundle(x01, k01, E01)
mybundle2 = RayBundle(x02, k02, E02)

raypaths1 = s.seqtrace(mybundle1, seq)
raypaths2 = s.seqtrace(mybundle2, seq)
示例#15
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,