Monday, April 11, 2016

Interference

Try to make a simple code

#mentah

from pylab import *

n   = 193
t   = 0
dy  = 1./64.

w   = 1./8.         #wavelength

L   = 1.            #distance to screen

d   = .001/L          #half slit distance, weird it is, but anyway...
y   = zeros(n)
S   = zeros(n)
A   = 1.
f   = 1./w          # v = 1. ,:)


for i in arange(n):
    y[i]= dy*i
    l1  = sqrt(pow((y[i]-d),2)+pow(L,2))
    l2  = sqrt(pow((y[i]+d),2)+pow(L,2))
    print '***'
    print l1
    print l2
    y1  = A*sin(f*l1)
    y2  = A*sin(f*l2)
    #S[i]= y1+y2
    S[i]= pow((y1+y2),2)   


plot(y,S)
xlabel('y')
ylabel('V')
title('Interferensi')
grid(True)

show()



.