ey[1,:] = 1. E0_red = np.cross(k_red, ey, axisa=0, axisb=0).T E0_blue = np.cross(k_blue, ey, axisa=0, axisb=0).T sysseq = [("prism", [("stop", {"is_stop":True}), ("surf1", {}), ("surf2", {}), ("image", {})])] phi = 5.*math.pi/180.0 initialbundle_red = RayBundle(x0=o, k0=k_red, Efield0=E0_red, wave=wave_red) initialbundle_blue = RayBundle(x0=o, k0=k_blue, Efield0=E0_blue, wave=wave_blue) r_red = s.seqtrace(initialbundle_red, sysseq) r_blue = s.seqtrace(initialbundle_blue, sysseq) fig = plt.figure(1) ax = fig.add_subplot(111) ax.axis('equal') if StrictVersion(matplotlib.__version__) < StrictVersion('2.0.0'): ax.set_axis_bgcolor('white') else: ax.set_facecolor('white') phi = 0.#math.pi/4 pn = np.array([math.cos(phi), 0, math.sin(phi)]) # canonical_ex up = canonical_ey
k = np.zeros(oshape, dtype=complex) k[2, :] = 1. #2.*math.pi/wavelength ey = np.zeros_like(o) ey[1, :] = 1. E0 = np.cross(k, ey, axisa=0, axisb=0).T sysseq = [("AC254-100", [("stop", {}), ("front", {}), ("cement", {}), ("rear", {}), ("image", {})])] phi = 5. * math.pi / 180.0 initialbundle = RayBundle(x0=o, k0=k, Efield0=E0, wave=wavelength) r2 = s.seqtrace(initialbundle, sysseq, splitup=True) fig = plt.figure(1) ax = fig.add_subplot(111) ax.axis('equal') if StrictVersion(matplotlib.__version__) < StrictVersion('2.0.0'): ax.set_axis_bgcolor('white') else: ax.set_facecolor('white') phi = 0. #math.pi/4 pn = np.array([math.cos(phi), 0, math.sin(phi)]) # canonical_ex up = canonical_ey r2[0].draw2d(ax, color="blue", plane_normal=pn, up=up)
o = np.vstack((rpup * px, rpup * py, -5. * np.ones_like(px))) k = np.zeros_like(o) k[2, :] = 1. #2.*math.pi/wavelength ey = np.zeros_like(o) ey[1, :] = 1. E0 = np.cross(k, ey, axisa=0, axisb=0).T sysseq = [("grinelement", [("object", { "is_stop": True }), ("surf1", {}), ("surf2", {}), ("image", {})])] initialbundle = RayBundle(x0=o, k0=k, Efield0=E0, wave=wavelength) r2 = s.seqtrace(initialbundle, sysseq, splitup=False) fig = plt.figure(1) ax = fig.add_subplot(111) ax.axis('equal') if StrictVersion(matplotlib.__version__) < StrictVersion('2.0.0'): ax.set_axis_bgcolor('white') else: ax.set_facecolor('white') phi = 0. #math.pi/4 pn = np.array([math.cos(phi), 0, math.sin(phi)]) # canonical_ex up = canonical_ey for r in r2:
sysseq_pilot = [("TMA", [("object", True, {}), ("m1", False, {}), ("m2", False, { "is_stop": True }), ("m3", False, {}), ("m2", False, {}), ("m1", False, {}), ("m2", False, {}), ("m1", False, {}), ("m2", False, {})])] phi = 5. * math.pi / 180.0 obj_dx = 0.1 obj_dphi = 1. * math.pi / 180.0 kwave = 2. * math.pi / wavelength initialbundle = RayBundle(x0=o, k0=k, Efield0=E0, wave=wavelength) r2 = s.seqtrace(initialbundle, sysseq) #pilotbundle = RayBundle( # x0 = np.array([[0], [0], [0]]), # k0 = np.array([[0], [kwave*math.sin(phi)], [kwave*math.cos(phi)]]), # Efield0 = np.array([[1], [0], [0]]), wave=wavelength # ) #pilotray = s.seqtrace(pilotbundle, sysseq_pilot) pilotbundles = pyrateoptics.raytracer.helpers.build_pilotbundle( objectsurf, air, (obj_dx, obj_dx), (obj_dphi, obj_dphi), num_sampling_points=3) rays_pilot = [s.seqtrace(p, sysseq) for p in pilotbundles]
#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') else: ax.set_facecolor('white') phi = 0. #math.pi/4 pn = np.array([math.cos(phi), 0, math.sin(phi)]) # canonical_ex
#k[2,:] = k0*math.cos(phik) ey = np.zeros_like(o) ey[1, :] = 1. E0 = np.cross(k, ey, axisa=0, axisb=0).T sysseq = [("crystalelem", [("stop", {}), ("front", {}), ("rear", { "is_mirror": True }), ("image", {})])] phi = 5. * math.pi / 180.0 initialbundle = RayBundle(x0=o, k0=k, Efield0=E0, wave=wavelength) r2 = s.seqtrace(initialbundle, sysseq) fig = plt.figure(1) ax = fig.add_subplot(111) ax.axis('equal') if StrictVersion(matplotlib.__version__) < StrictVersion('2.0.0'): ax.set_axis_bgcolor('white') else: ax.set_facecolor('white') phi = 0. #math.pi/4 pn = np.array([math.cos(phi), 0, math.sin(phi)]) # canonical_ex up = canonical_ey for r in r2:
k3[1, :] = math.sin(-15 * degree) k3[2, :] = math.cos(-15 * degree) E3 = np.cross(k3, ey, axisa=0, axisb=0).T 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", {})])] initialbundle1 = RayBundle(x0=o, k0=k1, Efield0=E1, wave=standard_wavelength) initialbundle2 = RayBundle(x0=o, k0=k2, Efield0=E2, wave=standard_wavelength) initialbundle3 = RayBundle(x0=o, k0=k3, Efield0=E3, wave=standard_wavelength) r1 = s.seqtrace(initialbundle1, sysseq) r2 = s.seqtrace(initialbundle2, sysseq) r3 = s.seqtrace(initialbundle3, sysseq) obj_dx = 0.1 obj_dphi = 5 * degree pilotbundles = pyrateoptics.raytracer.helpers.build_pilotbundle( objsurf, air, (obj_dx, obj_dx), (obj_dphi, obj_dphi), num_sampling_points=3) rays_pilot = [s.seqtrace(p, sysseq) for p in pilotbundles[2:]] # only last two bundles hit the next surface (pilotray, r_pilot) = s.para_seqtrace(pilotbundles[-1], initialbundle1,
def correctKRayBundle(bundle): """ Should get correct k from raybundle. """ pass 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)],
"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) initialbundle1 = RayBundle(x0=o, k0=k1, Efield0=E1, wave=standard_wavelength) initialbundle2 = RayBundle(x0=o, k0=k2, Efield0=E2, wave=standard_wavelength) initialbundle3 = RayBundle(x0=o, k0=k3, Efield0=E3, wave=standard_wavelength) print("performing sequential raytrace") r1 = s.seqtrace(initialbundle1, sysseq) r2 = s.seqtrace(initialbundle2, sysseq) r3 = s.seqtrace(initialbundle3, sysseq) 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