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

applies a few fixes

parent 324727cd
Pipeline #466525 passed with stage
in 59 seconds
......@@ -132,15 +132,17 @@ for j in range(n_configs):
# 1. as expected
# 2. from simulation results
plot_i = 1
# correlation
phi = np.linspace(0, 360, n_configs)
phi_theory = np.linspace(0, 360, n_configs*100)
phi = np.linspace(0, 360/n_configs*(n_configs-1), n_configs)
phi_theory = np.linspace(0, 360/n_configs*(n_configs-1), n_configs*100)
theory = -np.cos(2 * phi_theory * (2 * np.pi / 360))
plt.figure()
plt.xlabel(r'$\Delta \varphi$')
plt.ylabel(r'$<x_1 x_2>$')
plt.plot(phi_theory, theory, '.', markersize=1, color='orange')
plt.plot(phi, E_12[0, :], 'o', color='blue')
plt.plot(phi, E_12[plot_i, :], 'o', color='blue')
plt.savefig('correlation.pdf')
if showPlots:
plt.show()
......@@ -154,7 +156,7 @@ plt.ylabel(r'$<x_1><x_2>$')
plt.ylim([-1, 1])
plt.xticks([0, 45, 90, 135, 180, 225, 270, 305, 360])
plt.plot(phi_theory, line, '.', markersize=1, color='orange')
plt.plot(phi, E_1[0, :]*E_2[0, :], 'o', color='blue')
plt.plot(phi, E_1[plot_i, :]*E_2[plot_i, :], 'o', color='blue')
plt.savefig('expectation_value.pdf')
if showPlots:
plt.show()
......
......@@ -4,7 +4,7 @@ import matplotlib.pyplot as plt
import time
# settings
N = int(1e6)
N = int(100000)
T_0 = 1000
W = 1
showPlots = True
......@@ -16,14 +16,11 @@ def simulate(phi1, phi2):
thetas[:, 0] = np.random.rand(N) * 2 * np.pi
thetas[:, 1] = thetas[:, 0] + np.pi / 2
# generate random number for timestamp
rs = np.random.rand(N)
# calculate outcome of observation station
x1 = (np.cos(2 * (phi1 - thetas[:, 0])) >= (2*np.random.rand(N) -1)).reshape(N, 1)
t1 = T_0 * rs * np.sin(2 * (phi1 - thetas[:, 0])) ** 2
t1 = T_0 * np.random.rand(N) * np.sin(2 * (phi1 - thetas[:, 0])) ** 4
x2 = (np.cos(2 * (phi2 - thetas[:, 1])) >= (2*np.random.rand(N) -1)).reshape(N, 1)
t2 = T_0 * rs * np.sin(2 * (phi2 - thetas[:, 1])) ** 2
t2 = T_0 * np.random.rand(N) * np.sin(2 * (phi2 - thetas[:, 1])) ** 4
# determine which events are conincidences (1) and which not (0)
coincidences = np.abs(t1 - t2) < W
......@@ -38,10 +35,10 @@ def simulate(phi1, phi2):
counts[0, 2] = np.sum(np.all(x1x2 == np.array([1, 0]), axis=1), axis=0)
counts[0, 3] = np.sum(np.all(x1x2 == np.array([1, 1]), axis=1), axis=0)
counts[1, 0] = np.sum(np.all(x1x2 == np.array([0, 0]), axis=1) == coincidences, axis=0)
counts[1, 1] = np.sum(np.all(x1x2 == np.array([0, 1]), axis=1) == coincidences, axis=0)
counts[1, 2] = np.sum(np.all(x1x2 == np.array([1, 0]), axis=1) == coincidences, axis=0)
counts[1, 3] = np.sum(np.all(x1x2 == np.array([1, 1]), axis=1) == coincidences, axis=0)
counts[1, 0] = np.sum(np.logical_and(np.all(x1x2 == np.array([0, 0]), axis=1), coincidences), axis=0)
counts[1, 1] = np.sum(np.logical_and(np.all(x1x2 == np.array([0, 1]), axis=1), coincidences), axis=0)
counts[1, 2] = np.sum(np.logical_and(np.all(x1x2 == np.array([1, 0]), axis=1), coincidences), axis=0)
counts[1, 3] = np.sum(np.logical_and(np.all(x1x2 == np.array([1, 1]), axis=1), coincidences), axis=0)
E_all = np.sum(counts, axis=1).astype(float)
E_12 = (counts[:, 0] - counts[:, 1] - counts[:, 2] + counts[:, 3]).astype(float)
......@@ -71,20 +68,43 @@ def try_all_configs(n_configs):
E_1[i, :] = E_1_
E_2[i, :] = E_2_
x = np.linspace(0, 360, n_configs)
# correlation
phi = np.linspace(0, 360/n_configs*(n_configs-1), n_configs)
phi_theory = np.linspace(0, 360/n_configs*(n_configs-1), n_configs*100)
theory = -np.cos(2 * phi_theory * (2 * np.pi / 360))
plt.figure()
plt.xlabel(r'$\Delta \varphi$')
plt.ylabel(r'$<x_1 x_2>$')
plt.plot(phi_theory, theory, '.', markersize=1, color='orange')
plt.plot(phi, E_12[:, 0], 'o', color='blue')
#plt.savefig('correlation.pdf')
if showPlots:
plt.show()
plt.close()
# product of expectation values
line = np.zeros(phi_theory.shape)
plt.figure()
plt.plot(x, E_12[:, 0])
plt.xlabel(r'$\Delta \varphi$')
plt.ylabel(r'$<x_1><x_2>$')
plt.ylim([-1, 1])
plt.xticks([0, 45, 90, 135, 180, 225, 270, 305, 360])
plt.plot(phi_theory, line, '.', markersize=1, color='orange')
plt.plot(phi, E_1[:, 0]*E_2[:, 0], 'o', color='blue')
#plt.savefig('expectation_value.pdf')
if showPlots:
plt.show()
plt.close()
# correlation
phi = np.linspace(0, 360, n_configs)
phi_theory = np.linspace(0, 360, n_configs*100)
phi = np.linspace(0, 360/n_configs*(n_configs-1), n_configs)
phi_theory = np.linspace(0, 360/n_configs*(n_configs-1), n_configs*100)
theory = -np.cos(2 * phi_theory * (2 * np.pi / 360))
plt.figure()
plt.xlabel(r'$\Delta \varphi$')
plt.ylabel(r'$<x_1 x_2>$')
plt.plot(phi_theory, theory, '.', markersize=1, color='orange')
plt.plot(phi, E_12[:, 0], 'o', color='blue')
plt.plot(phi, E_12[:, 1], 'o', color='blue')
#plt.savefig('correlation.pdf')
if showPlots:
plt.show()
......@@ -98,7 +118,7 @@ def try_all_configs(n_configs):
plt.ylim([-1, 1])
plt.xticks([0, 45, 90, 135, 180, 225, 270, 305, 360])
plt.plot(phi_theory, line, '.', markersize=1, color='orange')
plt.plot(phi, E_1[:, 0]*E_2[:, 0], 'o', color='blue')
plt.plot(phi, E_1[:, 1]*E_2[:, 1], 'o', color='blue')
#plt.savefig('expectation_value.pdf')
if showPlots:
plt.show()
......
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