Commit a0dbe89d authored by Tobias Jörg Theodor Kempe's avatar Tobias Jörg Theodor Kempe
Browse files

adds comments

parent 20efa2cd
Pipeline #464970 passed with stage
in 1 minute and 2 seconds
......@@ -5,22 +5,31 @@ import matplotlib.pyplot as plt
# some initialization
wxyz = 1234
np.random.seed(wxyz)
# input data
nsteps = 32
nsamples = 100000
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
# this is basically the application of a rotation matrix!
c2 = cHWP*c + sHWP*s
s2 = -sHWP*c + cHWP*s
x = c2*c2 - s2*s2 # cos(2(x-a))
y = 2*c2*s2 # sin(2(x-a))
# when the x component is larger than a certain value, we count it as +1 and else as -1 event
# Malus law
r0 = np.random.rand()
if(x>2*r0 - 1):
......@@ -33,21 +42,53 @@ def analyzer(c, s, cHWP, sHWP, T0):
return j, l
# this is our result array, in which we store, how detection combinations we detected during the entire experiment
# 1st index: arriving in station1 at bottom (0) or at top (1)
# 2nd index: arriving in station2 at bottom (0) or at top (1)
# 3rd index: non-coincidences included (0) or not (1)
# 4th index: configuration of the polarizors/detectors
count = np.zeros(shape=(2, 2, 2, nsteps), dtype=np.int32) # set all counts to zero
# we split a whole rotation (2PI) into nsteps and make experiments for each step
# TODO What do these angles represent?
# it seems to be that the angles is the difference between the polarizations angles of both analyzer stations
for ipsi0 in range(nsteps): # loop over different settings of EOM1
cHWP1 = np.cos(ipsi0*2*np.pi/nsteps)
sHWP1 = np.sin(ipsi0*2*np.pi/nsteps)
# we want probabilities, basically, so we iterate over a number of random samples
for i in range(nsamples):
# source
# we randomize the polarization of the photons,
# however they're always entangle, so they will have a phase of pi/2 between them
r0 = np.random.rand()
# but these aren't angles, right?
# why don't we input the angles into the analzer?
# would be more declarative...
c1 = np.cos(r0*2*np.pi) # polarization angle x of particle going to station 1
s1 = np.sin(r0*2*np.pi) # polarization angle x + pi/2 of particle going to station 2
c2 = -s1
s2 = c1
# produces binary x values along with a timestamp for the current event
# for both analyzers.
# station 1
j1, l1 = analyzer(c1, s1, cHWP1, sHWP1, T0)
# station 2
j2, l2 = analyzer(c2, s2, cHWP2, sHWP2, T0)
# we increase the count of the associated x1, x2 counter elements.
# count
count[j1, j2, 0, ipsi0] = count[j1, j2, 0, ipsi0] + 1 # Malus law model
if(abs(l1 - l2)<W):
......@@ -58,6 +99,8 @@ tot = np.zeros(shape=(2, nsteps), dtype=np.int32)
E12 = np.zeros(shape=(2, nsteps), dtype=np.float64)
E1 = np.zeros(shape=(2, nsteps), dtype=np.float64)
E2 = np.zeros(shape=(2, nsteps), dtype=np.float64)
# we build the expectation values for various combinations of particles being dectected "up"
for j in range(nsteps):
for i in [0, 1]:
# i = 0 <==> no time window, i = 1 <=> use time coincidences
......@@ -66,11 +109,14 @@ for j in range(nsteps):
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]
# normalization of prevention of 0-division
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]
# plotting of the correlated graph.
theta = np.linspace(0, 360, nsteps)
theta_theory = np.linspace(0, 360, nsteps*100)
theory = []
......@@ -79,4 +125,9 @@ for j in range(nsteps*100):
plt.plot(theta, E12[0, :], 'o')
plt.plot(theta_theory, theory, '.', markersize=1)
plt.savefig('e12.pdf')
plt.close()
\ No newline at end of file
plt.close()
# TODO adjust y range
plt.figure()
plt.plot(theta, E1[0, :]*E2[0, :], 'o')
plt.show()
\ 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