Commit 5d726908 authored by Orkun Şensebat's avatar Orkun Şensebat
Browse files

Fix all trivial errors

parent 0a78e3d0
......@@ -7,9 +7,12 @@ np.random.seed(wxyz)
# input data
nsteps = 32
nsamples = 100000
HWP2 = 0 # degrees, orientation of wave plate 2 (EOM2)
T0 = 1000 # (ns), maximum time delay
W = 1 # (ns), time coincidence window
HWP2 = 0 # degrees, orientation of wave plate 2 (EOM2)
cHWP2 = np.cos(HWP2*np.pi/180)
sHWP2 = np.sin(HWP2*np.pi/180)
def analyzer(c, s, cHWP, sHWP, T0):
# EOM : plane rotation
......@@ -27,13 +30,11 @@ def analyzer(c, s, cHWP, sHWP, T0):
# time delay
# F90: call random_number(r1)
r1 = np.random.rand()
l = y*y*y*y*T0*r1 # delay time: T_0 sin(2*(theta1 - x))**4
l = y**4*T0*r1 # delay time: T_0 sin(2*(theta1 - x))**4
return j, l
cHWP2 = np.cos(HWP2*np.pi/180)
sHWP2 = np.sin(HWP2*np.pi/180)
count = 0 # set all counts to zero
count = np.zeros(shape=(2,2,2,nsteps), dtype=np.int16) # set all counts to zero
for ipsi0 in range(0, nsteps): # loop over different settings of EOM1
cHWP1 = np.cos(ipsi0*2*np.pi/nsteps)
sHWP1 = np.sin(ipsi0*2*np.pi/nsteps)
......@@ -50,34 +51,39 @@ for ipsi0 in range(0, nsteps): # loop over different settings of EOM1
# station 2
j2, l2 = analyzer(c2, s2, cHWP2, sHWP2, T0)
# count
Count(j1,j2,0,ipsi0) = Count(j1,j2,0,ipsi0)+1 # Malus law model
count[j1,j2,0,ipsi0] = count[j1,j2,0,ipsi0] + 1 # Malus law model
if(abs(l1-l2)<W):
Count(j1,j2,1,ipsi0) = Count(j1,j2,1,ipsi0)+1 # Malus law model + time window
count[j1,j2,1,ipsi0] = count[j1,j2,1,ipsi0] + 1 # Malus law model + time window
# data analysis
tot = np.zeros(shape=(nsteps,2), dtype=np.int16)
E12 = np.zeros(shape=(nsteps,2), dtype=np.int16)
E1 = np.zeros(shape=(nsteps,2), dtype=np.int16)
E2 = np.zeros(shape=(nsteps,2), dtype=np.int16)
for j in range(0, nsteps):
for i in range(0, 1): # i = 0 <==> no time window, i = 1 <=> use time coincidences
tot(i,j) = sum(count(:,:,i,j))
E12(i,j) = count(0,0,i,j)+count(1,1,i,j)-count(1,0,i,j)-count(0,1,i,j)
E1(i,j) = count(0,0,i,j)+count(0,1,i,j)-count(1,1,i,j)-count(1,0,i,j)
E2(i,j) = count(0,0,i,j)+count(1,0,i,j)-count(1,1,i,j)-count(0,1,i,j)
if(tot(i,j)>0) :
E12(i,j) = E12(i,j)/tot(i,j)
E1(i,j) = E1(i,j)/tot(i,j)
E2(i,j) = E2(i,j)/tot(i,j)
tot[i,j] = sum(count[:,:,i,j])
E12[i,j] = count[0,0,i,j] + count[1,1,i,j] - count[1,0,i,j] - count[0,1,i,j]
E1[i,j] = count[0,0,i,j] + count[0,1,i,j] - count[1,1,i,j] - count[1,0,i,j]
E2[i,j] = count[0,0,i,j] + count[1,0,i,j] - count[1,1,i,j] - count[0,1,i,j]
if(tot[i,j]>0) :
E12[i,j] = E12[i,j]/tot[i,j]
E1[i,j] = E1[i,j]/tot[i,j]
E2[i,j] = E2[i,j]/tot[i,j]
# print out to two different files, suitable for plotting by GNUPLOT
for i in range(0, 1):
print(7+i,'("# ** DLM Demo EPRB **")')
print(7+i,'("# Input variables: ")')
print(7+i,'("# Nsamples = ",i0)') nsamples
print(7+i,'("# theta HWP2 = ",e11.3)') HWP2
print(7+i,'("# T0 = ",e11.3)') T0
print(7+i,'("# W = ",e11.3)') W
print(7+i,'("# iseed = ",i0)') iseed(1)
print(7+i,'("# Nsamples = ",i0)', nsamples)
print(7+i,'("# theta HWP2 = ",e11.3)', HWP2)
print(7+i,'("# T0 = ",e11.3)', T0)
print(7+i,'("# W = ",e11.3)', W)
print(7+i,'("# seed = ",i0)', wxyz)
print(7+i,'("# Theta <S1.a> <S2.b> <S1.a S2.b> theory S N++ N-+ N+- N-- sum(N..)")')
print(7+i,'("#",116("-"))')
print(7+i,'("# Theta <S1.a> <S2.b> <S1.a S2.b> theory S N++ N-+ N+- N-- sum(N..)")')
for j in range(0, nsteps):
S = 3*E12(i,j)-E12(i,mod(j*3,nsteps)) # correlation of QT
S = 3*E12[i, j] - E12[i, (j*3)%nsteps] # correlation of QT
r0 = -np.cos(2*j*2*np.pi/nsteps)
print(7+i,'(1x,6e11.3,5i10)')
j*360.0/nsteps,E1(i,j),E2(i,j),E12(i,j),r0,S,count(:,:,i,j),tot(i,j)
\ No newline at end of file
print(j*360.0/nsteps, E1[i, j], E2[i, j], E12[i, j], r0, S, count[:, :, i, j], tot[i, j])
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment