def littrow(): """ Trace rectangular beam into OPG in Littrow. 400 nm groove period 8.4 m groove convergence """ #Set up beam rays = sources.rectArray(50., 50., 1e2) #Trace to Littrow and diffract tran.transform(rays, 0, 0, 0, 0, 52.28 * np.pi / 180, 0) surf.flat(rays) tran.transform(rays, 0, 8400., 0, 0, 0, 0) tran.radgrat(rays, 400. / 8400., 1, 632.8) #Steer out beam tilt tran.steerX(rays) tran.steerY(rays) #Bring rays to common plane surf.flat(rays) #Get wavefront r = anal.wavefront(rays, 200, 200) return r
def littrow(): """ Trace rectangular beam into OPG in Littrow. 400 nm groove period 8.4 m groove convergence """ #Set up beam rays = sources.rectArray(50., 50., 1e2) #Trace to Littrow and diffract tran.transform(rays, 0, 0, 0, 0, 52.28 * np.pi / 180, 0) surf.flat(rays) tran.transform(rays, 0, 8400., 0, 0, 0, 0) tran.radgrat(rays, 400. / 8400., 1, 632.8) #Steer out beam tilt tran.steerX(rays) tran.steerY(rays) #Bring rays to common plane surf.flat(rays) #Interpolate slopes to regular grid y, dx, dy = anal.interpolateVec(rays, 5, 200, 200) x, dx, dy = anal.interpolateVec(rays, 4, 200, 200) #Prepare arrays for integration #Reconstruct requires nans be replaced by 100 #Fortran functions require arrays to be packed in #fortran contiguous mode x = man.padRect(x) y = man.padRect(y) phase = np.zeros(np.shape(x), order='F') phase[np.isnan(x)] = 100. x[np.isnan(x)] = 100. y[np.isnan(y)] = 100. y = np.array(y, order='F') x = np.array(x, order='F') #Reconstruct and remove border phase = reconstruct.reconstruct(x, y, 1e-12, dx, phase) phase[phase == 100] = np.nan x[x == 100] = np.nan y[y == 100] = np.nan return man.stripnans(phase), man.stripnans(x), man.stripnans(y)
trans.grat(control_rays, period, np.full(len(ind), 5, dtype=float), np.full(len(ind), wave), ind=ind) for period in np.unique(expds): ind = np.where(expds == period)[0] trans.grat(experiment_rays, period, np.full(len(ind), 5, dtype=float), np.full(len(ind), wave), ind=ind) # # Diffract rays. trans.radgrat(rays, d / L, -int(5), wave) # Go back to starting coordinate system. rays = trans.applyT(rays, glob_coords, inverse=True) experiment_rays = trans.applyT(experiment_rays, glob_coords, inverse=True) control_rays = trans.applyT(control_rays, glob_coords, inverse=True) # Focus rays. surfaces.focusX(rays) surfaces.focusX(experiment_rays) surfaces.focusX(control_rays) plt.figure() plt.scatter(experiment_rays[1], experiment_rays[2], s=0.5) plt.scatter(control_rays[1], control_rays[2], s=0.5) plt.scatter(rays[1], rays[2], s=0.5)
# i.addComponent(w) # i.addComponent(g2) # i.simulate() # # prays.focusX() ## good_ind = np.where((rays[2] < 3300.) & (rays[2] > 3200.))[0] rays = [r[good_ind] for r in deepcopy(rays)] # Reflect rays. trans.reflect(rays) # Diffract rays. trans.radgrat(rays, d / L, -1, wave) # Go back to starting coordinate system. rays = trans.applyT(rays, glob_coords, inverse=True) # xcen = rays[1].min() + (rays[1].max() - rays[1].min()) / 2 # ycen = rays[2].min() + (rays[2].max() - rays[2].min()) / 2 # zcen = rays[3].min() + (rays[3].max() - rays[3].min()) / 2 # ind = np.argmin(np.abs(rays[1])) # dir = np.array([xcen - rays[1][ind], ycen - rays[2][ind], zcen - rays[3][ind]]) # # ind = np.argmin(np.abs(rays[2] - ycen)) # adir = np.array([xcen - rays[1][ind], ycen - rays[2][ind], zcen - rays[3][ind]]) # # norm = np.cross(dir,adir) * -1 #
ind = np.where((rays[2] > (hub - grat_length / 2)) & (rays[2] < (hub + grat_length / 2)))[0] # Remove indices which have already been reflected/diffracted. ind = ind[np.isin(ind, diff_inds, invert=True)] ind = np.array(ind, dtype=int) print(ind) diff_inds = np.concatenate((ind, diff_inds)) # If there are no rays that interact with the grating, continue. if len(ind) < 1: rays = trans.applyT(rays, glob_coords, inverse=True) continue # Reflect photons which fall onto this grating. trans.reflect(rays, ind=ind) # Diffract photons. trans.radgrat(rays, 1e6 / d / hub, 1, waves, ind=ind) # trans.radgrat(rays,1e6/d/hub,1,waves) # # Return back to original coordinate system. rays = trans.applyT(rays, glob_coords, inverse=True) # Only keep rays which have been diffracted. diff_inds = np.array(diff_inds, dtype=int) print(len(rays[0]), len(diff_inds)) rays = [r[diff_inds] for r in rays] # With the rays propagated through the grating module, we will now go to the spectral focus. # In[22]: # Find optimal focus position. grat_focus = surfaces.focusX(rays)