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) / (t2 - t1)))) + " ray-surface-operations per second") # plot
# # 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') else: ax.set_facecolor('white')