def initDemoSystem(self): s = OpticalSystem() lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0), refname=s.rootcoordinatesystem.name) lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=2.0), refname=lc0.name) # objectDist lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=3.0), refname=lc1.name) lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=5.0, tiltx=0.0*math.pi/180.0), refname=lc2.name) lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf4", decz=3.0), refname=lc3.name) lc5 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf5", decz=3.0), refname=lc4.name) lc6 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf6", decz=2.0), refname=lc5.name) lc7 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf7", decz=3.0), refname=lc6.name) lc8 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=19.0), refname=lc7.name) objectsurf = Surface(lc0) surf1 = Surface(lc1, shape=Conic(lc1, curv=1/-5.922)) surf2 = Surface(lc2, shape=Conic(lc2, curv=1/-3.160)) surf3 = Surface(lc3, shape=Conic(lc3, curv=1/15.884)) surf4 = Surface(lc4, shape=Conic(lc4, curv=1/-12.756)) stopsurf = Surface(lc5) surf6 = Surface(lc6, shape=Conic(lc6, curv=1/3.125)) surf7 = Surface(lc7, shape=Conic(lc7, curv=1/1.479)) image = Surface(lc8) elem = OpticalElement(lc0, label="lenssystem") glass = material_isotropic.ConstantIndexGlass(lc0, n=1.7) glass2 = material_isotropic.ConstantIndexGlass(lc0, n=1.5) elem.addMaterial("glass", glass) elem.addMaterial("glass2", glass2) elem.addSurface("object", objectsurf, (None, None)) elem.addSurface("surf1", surf1, (None, "glass")) elem.addSurface("surf2", surf2, ("glass", None)) elem.addSurface("surf3", surf3, (None, "glass")) elem.addSurface("surf4", surf4, ("glass", None)) elem.addSurface("stop", stopsurf, (None, None)) elem.addSurface("surf6", surf6, (None, "glass2")) elem.addSurface("surf7", surf7, ("glass2", None)) elem.addSurface("image", image, (None, None)) s.addElement("lenssys", elem) return s
aperture=CircularAperture(lc5ap, maxradius=30.0)) image2 = Surface(lc6, aperture=CircularAperture(lc6, maxradius=20.0)) elem = OpticalElement(lc0, name="TMA") # elem.addMaterial("crystal", crystal) elem.addSurface("object", objectsurf, (None, None)) elem.addSurface("m1", m1surf, (None, None)) elem.addSurface("m2", m2surf, (None, None)) elem.addSurface("m3", m3surf, (None, None)) elem.addSurface("image1", image1, (None, None)) elem.addSurface("oapara", oapara, (None, None)) elem.addSurface("image2", image2, (None, None)) s.addElement("TMA", elem) print(s.rootcoordinatesystem.pprint()) sysseq = [("TMA", [("object", {}), ("m1", { "is_mirror": True }), ("m2", { "is_mirror": True }), ("m3", { "is_mirror": True }), ("image1", {}), ("oapara", { "is_mirror": True }), ("image2", {})])] sysseq_pilot = [("TMA", [("object", {}), ("m1", { "is_mirror": True
water = ConstantIndexGlass(lc0, n=1.336, name="water (failsafe)") logging.info("wavelength %f, index %f" % (wave_red, water.getIndex(None, wave_red).real)) logging.info("wavelength %f, index %f" % (wave_blue, water.getIndex(None, wave_blue).real)) 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]
# 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,
# 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)
image = Surface(lc3) elem = OpticalElement(lc0, name="prism") glass = ModelGlass(lc1) elem.addMaterial("glass", glass) elem.addSurface("stop", stopsurf, (None, None)) elem.addSurface("surf1", frontsurf, (None, "glass")) elem.addSurface("surf2", rearsurf, ("glass", None)) elem.addSurface("image", image, (None, None)) s.addElement("prism", elem) rstobj = raster.MeridionalFan() (px, py) = rstobj.getGrid(20) rpup = 5 oy = -20.0 o = np.vstack((rpup*px, rpup*py + oy, -5.*np.ones_like(px))) kangle = 23.*deg kwave_red = 1. #2.*math.pi/wave_red k_red = np.zeros_like(o) k_red[1,:] = kwave_red*math.sin(kangle) k_red[2,:] = kwave_red*math.cos(kangle)
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)
image2 = Surface(lc6, aperture=CircularAperture(lc6, maxradius=20.0)) elem = OpticalElement(lc0, name="TMA") # elem.addMaterial("crystal", crystal) elem.addSurface("object", objectsurf, (None, None)) elem.addSurface("m1", m1surf, (None, None)) elem.addSurface("m2", m2surf, (None, None)) elem.addSurface("m3", m3surf, (None, None)) elem.addSurface("image1", image1, (None, None)) elem.addSurface("oapara", oapara, (None, None)) elem.addSurface("image2", image2, (None, None)) s.addElement("TMA", elem) print(s.rootcoordinatesystem.pprint()) sysseq = [("TMA", [ ("object", {}), ("m1", {"is_mirror": True}), ("m2", {"is_mirror": True}), ("m3", {"is_mirror": True}), ("image1", {}), ("oapara", {"is_mirror": True}), ("image2", {})])] sysseq_pilot = [("TMA", [ ("object", {}),
no = 1.5 neo = 1.8 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)
glass2 = ConstantIndexGlass(lc0, n=1.5) elem.addMaterial("glass", glass) elem.addMaterial("glass2", glass2) elem.addSurface("object", objectsurf, (None, None)) elem.addSurface("surf1", surf1, (None, "glass")) elem.addSurface("surf2", surf2, ("glass", None)) elem.addSurface("surf3", surf3, (None, "glass")) elem.addSurface("surf4", surf4, ("glass", None)) elem.addSurface("stop", stopsurf, (None, None)) elem.addSurface("surf6", surf6, (None, "glass2")) elem.addSurface("surf7", surf7, ("glass2", None)) elem.addSurface("image", image, (None, None)) s.addElement("lenssys", elem) # plot initial system # aimy = aim.aimFiniteByMakingASurfaceTheStop(s, pupilType=pupil.ObjectSpaceNA, # pupilSizeParameter=0.2,#3.0, # fieldType= field.ObjectHeight, # rasterType= raster.RectGrid, # nray=20, wavelength=wavelength, # stopPosition=5) # # initialBundle2 = aimy.getInitialRayBundle(s, fieldXY=np.array([0, 0]), # wavelength=wavelength) # # r2 = RayPath(initialBundle2, s) #
no = 1.5 neo = 1.8 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", None)) elem.addSurface("image", image, (None, None)) s.addElement("crystalelem", elem) sysseq = [("crystalelem", [("stop", { "is_stop": True }), ("front", {}), ("rear", {}), ("image", {})])] raysdict = { "opticalsystem": s, "startz": -5., "radius": 20 * degree, "raster": raster.MeridionalFan() } splitup = True r2 = raytrace(s, sysseq, 10, raysdict, bundletype="divergent",\ traceoptions={"splitup":splitup}, wave=wavelength)[0]
elem.addSurface("object", objsurf, (None, None)) elem.addSurface("d1", D1surf, (None, None)) elem.addSurface("s1", S1surf, (None, "glass")) elem.addSurface("d1p", D1Psurf, ("glass", "glass")) elem.addSurface("d2", D2surf, ("glass", "glass")) elem.addSurface("s2", S2surf, ("glass", "glass")) elem.addSurface("d2p", D2Psurf, ("glass", "glass")) elem.addSurface("d3", D3surf, ("glass", "glass")) elem.addSurface("s3", S1surf, ("glass", "glass")) elem.addSurface("d3p", D3Psurf, ("glass", "glass")) elem.addSurface("d4", D4surf, ("glass", "glass")) elem.addSurface("s4", S4surf, ("glass", None)) 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", {}),
glass2 = ConstantIndexGlass(lc0, n=1.5) elem.addMaterial("glass", glass) elem.addMaterial("glass2", glass2) elem.addSurface("object", objectsurf, (None, None)) elem.addSurface("surf1", surf1, (None, "glass")) elem.addSurface("surf2", surf2, ("glass", None)) elem.addSurface("surf3", surf3, (None, "glass")) elem.addSurface("surf4", surf4, ("glass", None)) elem.addSurface("stop", stopsurf, (None, None)) elem.addSurface("surf6", surf6, (None, "glass2")) elem.addSurface("surf7", surf7, ("glass2", None)) elem.addSurface("image", image, (None, None)) s.addElement("lenssys", elem) # plot initial system #aimy = aim.aimFiniteByMakingASurfaceTheStop(s, pupilType=pupil.ObjectSpaceNA, #.StopDiameter, # pupilSizeParameter=0.2,#3.0, # fieldType= field.ObjectHeight, # rasterType= raster.RectGrid, # nray=20, wavelength=wavelength, stopPosition=5) # #initialBundle2 = aimy.getInitialRayBundle(s, fieldXY=np.array([0, 0]), wavelength=wavelength) # #r2 = RayPath(initialBundle2, s) # #initialBundle3 = aimy.getInitialRayBundle(s, fieldXY=np.array([0, 0.1]), wavelength=wavelength) #r3 = RayPath(initialBundle3, s) #
elem.addSurface("object", objsurf, (None, None)) elem.addSurface("d1", D1surf, (None, None)) elem.addSurface("s1", S1surf, (None, "glass")) elem.addSurface("d1p", D1Psurf, ("glass", "glass")) elem.addSurface("d2", D2surf, ("glass", "glass")) elem.addSurface("s2", S2surf, ("glass", "glass")) elem.addSurface("d2p", D2Psurf, ("glass", "glass")) elem.addSurface("d3", D3surf, ("glass", "glass")) elem.addSurface("s3", S1surf, ("glass", "glass")) elem.addSurface("d3p", D3Psurf, ("glass", "glass")) elem.addSurface("d4", D4surf, ("glass", "glass")) elem.addSurface("s4", S4surf, ("glass", None)) elem.addSurface("d4p", D4Psurf, (None, None)) elem.addSurface("image", imgsurf, (None, None)) s.addElement("HUD", elem) print(s.rootcoordinatesystem.pprint()) rstobj = raster.MeridionalFan() (px, py) = rstobj.getGrid(3) rpup = 2 o = np.vstack((rpup * px, rpup * py, 0. * np.ones_like(px))) k1 = np.zeros_like(o) k1[2, :] = 1.0 ey = np.zeros_like(o) ey[1, :] = 1. E1 = np.cross(k1, ey, axisa=0, axisb=0).T k2 = np.zeros_like(o)
water = ConstantIndexGlass(lc0, n=1.336, name="water (failsafe)") logging.info("wavelength %f, index %f" % (wave_red, water.getIndex(None, wave_red).real)) logging.info("wavelength %f, index %f" % (wave_blue, water.getIndex(None, wave_blue).real)) 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() }
""" return x[0]**2 + x[1]**2 < 10.**2 # grinmaterial = ConstantIndexGlass(lc1, 1.0 + grin_strength) grinmaterial = IsotropicGrinMaterial(lc1, nfunc, 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)