In [2]:
%matplotlib notebook
from math import sqrt,sin,pi
from numpy import empty
from pylab import imshow,gray,show

wavelength = 10.0
k = 2*pi/wavelength
xi0 = 1.0
separation = 20.0
side = 100.0
points = 500
spacing = side/points  # Spacing of points in cm
# Separation of centers in cm
# Side of the square in cm
# Number of grid points along each side
# Calculate the positions of the centers of the circles
x1 = side/2 + separation/2
y1 = side/2
x2 = side/2 - separation/2
y2 = side/2
   # Make an array to store the heights
xi = empty([points,points],float)
   # Calculate the values in the array
for i in range(points):
    y = spacing*i
    for j in range(points):
        x = spacing*j
        r1 = sqrt((x-x1)**2+(y-y1)**2)
        r2 = sqrt((x-x2)**2+(y-y2)**2)
        xi[i,j] = xi0*sin(k*r1) + xi0*sin(k*r2)

imshow(xi,origin="lower",extent=[0,side,0,side])
gray()
show()



In [ ]: