Exemplo n.º 1
0
def system(lib):
    """The optical system run by LightPipes library lib."""
    F = lib.Begin(size, wavelength, N)
    F = lib.RectAperture(w, w, 0, 0, 0, F)
    F = lib.Fresnel(z, F)
    # plotutils.Plot(F)
    with tictoc.printtimer('Interpol'):
        F = lib.Interpol(newSize, newN, shift_x, shift_y, rot_alpha, scale, F)
    return F
Exemplo n.º 2
0
#******** Simulation parameters *************
wavelength=1*um
size=20.0*mm

N = 2048

R=5*mm
z=-1*m


#********* Run for new python LP *******

F = lp.Begin(size, wavelength, N)
F = lp.CircAperture(R, 0, 0, F)
F = lp.RectAperture(5*mm, size, 2.5*mm, 0, 23, F)
with tictoc.printtimer('lp.Forvard (N={})'.format(N)):
    F = lp.Forvard(z, F)
Ilp = lp.Intensity(0, F)
# Ilp = lp.Phase(F)
x_mm = F.xvalues/mm

#****** Run for reference cpp OLP *******

F = olp.Begin(size, wavelength, N)
F = olp.CircAperture(R, 0, 0, F)
F = olp.RectAperture(5*mm, size, 2.5*mm, 0, 23, F)
with tictoc.printtimer('olp.Forvard (N={})'.format(N)):
    F = olp.Forvard(z, F)
Iolp = np.asarray(olp.Intensity(0, F))
# Iolp = np.asarray(olp.Phase(F))
Exemplo n.º 3
0
size = 20.0 * mm

N = 70  #choose small number since Forward will be slow
N_new = 80

size_new = N_new / N * size

R = 5 * mm
z = 1 * m

#********* Run for new python LP *******

F = lp.Begin(size, wavelength, N)
F = lp.CircAperture(R, 0, 0, F)
F = lp.RectAperture(5 * mm, size, 2.5 * mm, 0, 13 * deg, F)
with tictoc.printtimer('lp.Forward (Nold,new={},{})'.format(N, N_new)):
    F = lp.Forward(z, size_new, N_new, F)
Ilp = lp.Intensity(0, F)
x_mm = F.xvalues / mm

#****** Run for reference cpp OLP *******

F = olp.Begin(size, wavelength, N)
F = olp.CircAperture(R, 0, 0, F)
F = olp.RectAperture(5 * mm, size, 2.5 * mm, 0, 13 * deg, F)
with tictoc.printtimer('olp.Forward (Nold,new={},{})'.format(N, N_new)):
    F = olp.Forward(z, size_new, N_new, F)
Iolp = np.asarray(olp.Intensity(0, F))

x_mm = []
for i in range(N_new):
Exemplo n.º 4
0
N = 1000

f = 10 * cm
f1 = 10 * m
f2 = f1 * f / (f1 - f)
frac = f / f1
newsize = frac * size
w = 5 * mm

#********* Run for new python LP *******

F = lp.Begin(size, wavelength, N)
F = lp.RectAperture(w, w, 0, 0, 0, F)

#1) Using Lens and Fresnel:
with tictoc.printtimer('Lens and Fresnel (N={})'.format(N)):
    F1 = lp.Lens(f, 0, 0, F)
    F1 = lp.Fresnel(f, F1)
I1 = lp.Intensity(0, F1)
phi1 = lp.Phase(F1)
# phi1 = lp.PhaseUnwrap(phi1)

#2) Using Lens + LensFresnel and Convert:
with tictoc.printtimer('With LensF+Convert (N={})'.format(N)):
    F2 = lp.Lens(f1, 0, 0, F)
    F2 = lp.LensFresnel(f2, f, F2)
    F2 = lp.Convert(F2)
I2 = lp.Intensity(0, F2)
phi2 = lp.Phase(F2)
# phi2 = lp.PhaseUnwrap(phi2)
    Young's experiment.
    Two holes with radii, R, separated by, d, in a screen are illuminated by a plane wave. The interference pattern
    at a distance, z, behind the screen is calculated.
"""
# print(LPversion)
wavelength = 5 * um
size = 20.0 * mm
N = 300
z = 50 * cm
R = 0.3 * mm
d = 1.2 * mm

# img=mpimg.imread('Young.png')
# plt.imshow(img); plt.axis('off')

# plt.show()

F = Begin(size, wavelength, N)
F1 = CircAperture(R / 2.0, -d / 2.0, 0, F)
F2 = CircAperture(R / 2.0, d / 2.0, 0, F)
F = BeamMix(F1, F2)
with tictoc.printtimer('LPFresnel'):
    F = Fresnel(z, F)
I = Intensity(2, F)

#lpplot.Plot(F)
plt.imshow(I, cmap='rainbow')
plt.axis('off')
plt.title('intensity pattern')
plt.show()