def main(return_final=False): N = r_[2**21, 2] # Number of pixels (different resolution for demo) DX = 60 * mm # physical size in the important direction wavelength = 780 * nm # Wavelength gaussian_size = 1.0 / sqrt( 2) * mm # 1/e Intensity width of beam; (note, it's not the 1/e^2) L_propagate = 25 * mm # distance from initial lens to 2D-MOT # grating parameters grating_period = mm / 900 grating_lambda = 1200 * nm # for the blazed grating ######## END Param ############## side_length = DX * r_[1, N[1] / float(N[0])] # physical size ####### Create grating G = grating.phase.Blazed(grating_period / m, wavelength / m, grating_lambda / m) ####### END Create grating propagate = Propagate1D(N, side_length, window_size=511) ##### With the knife edge between the SLM (at SLM focus) relay:1,lens:1. ##### In this case, we relay the knife edge to the MOT and not the SLM plane. F = Field(N, side_length / m, wavelength / m) # beginning field F.gaussian_aperture(gaussian_size / m, 1e300) G.apply(F) if return_final: F.forvard(L_propagate / m) plot((F.value * F.value.conj()).real[:, N[1] / 2]) return F else: propagate(F, L_propagate / m, L_propagate / m / 75.) print 'press enter to exit' raw_input()
from pylab import * m = 1 nm = 1e-9 * m mm = 1e-3 * m cm = 1e-2 * m wavelength = 550 * nm size = 5 * mm N = 150 R = 0.12 * mm x = 0.5 * mm y = 0.25 * mm z = 5 * cm F = Field(N, size, wavelength) F2 = F.copy() F3 = F.copy() F.circular_aperture(R, -x, -y) F2.circular_aperture(R, x, -y) F3.circular_aperture(R, 0, y) F.value[:] = F.value + F2.value + F3.value del F2, F3 for l in xrange(1, 11): F.forvard(z) subplot(2, 5, l) imshow(abs(F.value)**2) xticks([]), yticks([]) title('z={z} cm'.format(z=(l * z / cm)))
######## END Param ############## ####### Create LG order dx = (2 / (N - 1.)) x = y = 3 * r_[-1:(1 + dx):dx] [xx, yy] = meshgrid(x, y) lg = lg.LG_xy(l=l, p=0, xx=xx, yy=yy, omega0=2 / sqrt(l)) # normalize lg; we only want the phase information lg /= abs(lg) #imshow (x,y,arg(lg)) ####### END Create LG order propagate = Propagate() F = Field(N, side_length, wavelength) F.gaussian_aperture(gaussian_size) F.axicon(axicon_angle, axicon_n1) #F4 = propagate(13.*cm, step_size, F3,0,0,4); F.forvard(7.5 * cm) F.axicon(axicon_angle, axicon_n1) print 'moving towards slm' #F.forvard(40*cm) propagate(F, z=40. * cm, dz=10 * cm) print 'applying slm' F.value[:] *= lg propagate(F, z=50. * cm, dz=2 * cm) print 'press enter to exit' raw_input()
####### Create LG order dx = (2 / (N - 1.)) x = y = 3 * r_[-1:(1 + dx):dx] [xx, yy] = meshgrid(x, y) lg = lg.LG_xy(l=l, p=0, xx=xx, yy=yy, omega0=2 / sqrt(l)) # normalize lg; we only want the phase information lg /= abs(lg) #imshow (x,y,arg(lg)) ####### END Create LG order propagate = Propagate() if False: ##### Just the hollow beam relayed. F = Field(N, side_length, wavelength) # beginning field F.gaussian_aperture(gaussian_size) F.value[:] *= lg # SLM LG phase F.lens(fslm) # 'SLM' lens F.forvard(fslmR) F.lens(fslmR) # relay:1 lens:1 F.forvard(2 * fslmR) F.lens(fslmR) # relay:1 lens:2 F.forvard(fslmR + fslm) # MOT (1st pass) imshow((F.value * F.value.conj()).real) print 'press enter to continue' raw_input() F.forvard(fr1) F.lens(fr1, ) # relay:2 lens:1
wavelength = 780 * nm # Wavelength gaussian_size = 1.00 / sqrt( 2) * mm # 1/e Intensity width of beam; (note, it's not the 1/e^2) step_size = 5. * mm # LPForvard step size f = 20 * cm # focal length of SLM lens l = 8 # azimuthal order of LG beam ######## END Param ############## ####### Create LG order dx = (2 / (N - 1.)) x = y = 3 * r_[-1:(1 + dx):dx] [xx, yy] = meshgrid(x, y) lg = lg.LG_xy(l=l, p=0, xx=xx, yy=yy, omega0=2 / sqrt(l)) # normalize lg; we only want the phase information lg /= abs(lg) #imshow (x,y,arg(lg)) ####### END Create LG order propagate = Propagate() F = Field(N, side_length, wavelength) F.gaussian_aperture(gaussian_size) F.lens(f) F.value[:] *= lg propagate(F, z=f + cm, dz=.5 * cm) #F.forvard(18.0*cm) #F5 = propagate(4.*cm,.5*cm, F4,0,0,4) #F5 = propagate(13.*cm, step_size, F4,0,0,4)
import common from lightpipes import Field from pylab import * m=1 nm=1e-9*m um=1e-6*m mm=1e-3*m cm=1e-2*m ion() F = Field( 256, side_length=1*cm, wavelength=1*um ) \ .gaussian_aperture( w=2.25*mm ) \ .zernike( 2, 2, 4.5*mm, 20) \ .zernike( 2, 0, 4.5*mm, -10) \ .fresnel(1.55*m) \ .interpolate( angle=pi/32 ) # example of rotating the grid imshow( (F.value * F.value.conj()).real ) title('Intensity') draw() print 'press enter to show phase' raw_input() imshow( angle(F.value) ) title('Phase') draw() print 'press enter to exit' raw_input()
#!/usr/bin/env python """ LightPipes for Python Optical Toolbox Calculates the Fraunhofer diffraction of a round hole. """ import common from lightpipes import Field from pylab import * m = 1 nm = 1e-9 * m mm = 1e-3 * m cm = 1e-2 * m wavelength = 1000 * nm size = 10 * cm N = 150 R = 10 * mm z = 1000 * m f1 = 200 * m f2 = -200 * m F = Field(N, size, wavelength) F.circular_aperture(R) F.lens(f1) F.lens_forvard(f2, z) imshow(abs(F.value)**2) # plot intensity show()
omega0_p = .5 ######## END Param ############## ####### Create LG order dx = (2 / (N - 1.)) x = y = 3 * r_[-1:(1 + dx):dx] [xx, yy] = meshgrid(x, y) lg = lg.LG_xy( l=l, p=0, xx=xx, yy=yy, omega0=2/sqrt(l) ) \ + lg.LG_xy( l=0, p=p, xx=xx, yy=yy, omega0=.85*2/sqrt(l) ) # normalize lg; we only want the phase information lg /= abs(lg) #imshow (angle(lg)); show() ####### END Create LG order propagate = Propagate(vmin=0., vmax=100.) F = Field(N, side_length, wavelength) F.gaussian_aperture(gaussian_size) #F.lens(f) F.value[:] *= lg #propagate(F, z=2*f, dz=.5*cm) for z in r_[0:(2 * f):(.1 * f)]: Fcopy = F.copy() Fcopy.lens_forvard(f, z) propagate.imshow((Fcopy.value * Fcopy.value.conj()).real) raw_input()
#!/usr/bin/env python """ LightPipes for Python Optical Toolbox """ import common from lightpipes import Field from pylab import * phi = 178 * (pi/180.) F = Field(256, 512*15e-6, 780e-9) F.gaussian_aperture(.75e-3) F.axicon(phi, 1.5, 0e-6, 0) F.forvard(25e-2) imshow( abs(F.value)**2 ) show() F.axicon(phi, 1.5, 0e-6, 0) F.forvard(100e-2) imshow( abs(F.value)**2 ) show() #F.lens(-20e-2) #F.forvard(3e-2) # gsplot F7.F.*conj(F7.F);
while True: print """ CHOOSE ABERRATION 0. {0} 1. {1} 2. {2} 3. {3} <other> STOP """.format(*choices) choice = raw_input() if choice not in ['0','1','2','3']: break choice = int(choice) F = Field(N,size,wavelength) F.circular_aperture(R) if choice == 3: F.lens(f) else: k = choice F.zernike(nZ[k],mZ[k],RZ[k],AZ[k]) F.forvard(z1) F1 = F.copy() F1.value[:] *= Rplate F.value[:] *= (1 - Rplate) F.interpolate(size,N,D,D1) F.value[:] += F1.value Int = (F.value * F.value.conj()).real
nm = 1e-9 * m mm = 1e-3 * m cm = 1e-2 * m wavelength = 308 * nm size = 14 * mm N = 100 w = 5.48 * mm f1 = -10 * m f2 = 20 * m L = 10 * m Isat = 1.0 alpha = 1e-4 Lgain = 1e4 F = Field(N, size, wavelength) randomize.intensity(F) randomize.phase(1, F) SR = dict() for l in xrange(10): F.rectangular_aperture(w, w) F.l_amplify(alpha, Lgain, Isat) F.lens_fresnel(f1, L) F.l_amplify(alpha, Lgain, Isat) F.lens_fresnel(f2, L) SR[l] = F.get_strehl() F.interpolate(size, N) print 'Round trip {l} Strehl ratio= {s}'.format(l=l, s=SR[l]) F2 = F.copy()
x = y = (side_length / 2) * r_[-1:(1 + dx):dx] [xx, yy] = meshgrid(x, y) lg = lg.LG_xy(l=l, p=0, xx=xx * 6 / side_length, yy=yy * 6 / side_length, omega0=2 / sqrt(l)) # normalize lg; we only want the phase information lg /= abs(lg) #imshow (x,y,angle(lg)) ####### END Create LG order propagate = Propagate() F = Field(N, side_length, wavelength) F.gaussian_aperture(gaussian_size) Pf = P / sum(F.value * F.value.conj()) # power per grid cell [ W ] Ef = sqrt(Pf / grid_dx**2) # sqrt(I) [ sqrt(W/m^2) ] Ef /= sqrt(mW / cm**2) # put Ef in units [ sqrt(mW/cm^2) ] F.value[:] *= Ef # put F in units of sqrt(I) print 'writing SLM phase...' F.lens(f) # apply lens (physical lens) Fb = F.copy() # store the undeflected beam Fb.value[:] *= sqrt(0.2) # undeflected light F.value[:] *= lg # apply lg phase grating.phase.perfect(F, 32, 0) # apply a perfect grating phase. F.value[:] *= sqrt(0.8) # deflection efficiency of SLM F.value[:] += Fb.value # mix the beams back together.
wavelength = 500 * nm size = 30 * mm R = 5 * mm N = 250 z1 = 50 * cm z2 = 40 * cm z3 = 40 * cm z4 = 100 * cm RBS = 0.3 nz = 3 mz = 1 Rz = 0.005 Az = 25 F1 = Field(N, size, wavelength) F1.circular_aperture(R) F1.forvard(z1) F2 = F1.copy() F1 *= RBS F2 *= 1 - RBS F1.forvard(2 * z2) F2.forvard(z3) F1 F2.zernike(nz, mz, Rz, Az) F1 F2.forvard(z3) F1 *= RBS F2 *= 1 - RBS
from pylab import * m = 1 nm = 1e-9*m mm = 1e-3*m cm = 1e-2*m wavelength = 632.8*nm size = 4*mm N = 100 R = 1.5*mm dz = 10*mm f = 50*cm n = (1 + .1j)*ones( (N,N) ) F = Field(N,size,wavelength) F.circular_aperture(R) F.lens(f) Icross = zeros( (N,N) ) for l in xrange(N): F.steps(dz,1,n) Int = (F.value * F.value.conj()).real for k in xrange(N): Icross[l,k] = Int[N/2,k] imshow(Icross) show()
phi[ nonzero( r2 < Ri_2 ) ] = 0 return phi x = y = grid_dx * r_[-255.5:256:1.] [xx, yy] = meshgrid(x,y) torus_phase = tlens(xx,yy,R0,f_torus,wavelength) + phase_ring(xx,yy,R1,w1) propagate = Propagate() #print 'press enter to continue' #propagate.imshow( torus_phase ) #raw_input() # propagate the field from the SLM and take a look F = Field( N, side_length, wavelength) # initial field F.gaussian_aperture(w) # gaussian input F.circular_aperture(side_length/2.) # Iris in front of SLM F.value[:] *= exp(1j * torus_phase ) # apply SLM phase F.forvard(f_torus) propagate(F, z=f_torus, dz=f_torus/25.) print 'press enter to show final phase...' raw_input() propagate.imshow( angle(F.value) ) print 'press enter to show final intensity...' raw_input() propagate.imshow( (F.value * F.value.conj()).real ) print 'press enter to exit'
#!/usr/bin/env python """ LightPipes for Python Optical Toolbox One Hole Diffraction. """ import common from lightpipes import Field from pylab import * m=1 nm=1e-9*m mm=1e-3*m cm=1e-2*m wavelength = 550*nm; size = 5*mm N = 100 R = 1*mm z = 25*cm F = Field(N,size,wavelength) F.circular_aperture(R) F.rectangular_screen(R*2, R/8, 0, 0, -45) F.circular_screen(R/4) F.fresnel(z) imshow( abs(F.value)**2 ) # plot intensity title('Intensity Distribution in the somewhat far-field'); show()