I am trying to implement entangled modes and to measure them. I am interested in seeing the entanglement through the measurement results.
Here is the code I have so far.
from numpy import pi
import strawberryfields as sf
from strawberryfields import ops
import numpy as np
from strawberryfields import RemoteEngine
I4 = np.identity(4)
prog = sf.Program(8)
with prog.context as q:
# Two-mode squeezing. Allowed values are r=1.0 (on) or r=0.0 (off)
ops.S2gate(1.0) | (q[0], q[4])
ops.S2gate(1.0) | (q[1], q[5])
#**************************************** BSM
ops.BSgate(0.543, 0.123) | (q[0], q[1])
ops.BSgate(0.543, 0.123) | (q[4], q[5])
# Equal interferometers on signal and idler modes
ops.Interferometer(I4) | (q[0], q[1], q[2], q[3])
ops.Interferometer(I4) | (q[4], q[5], q[6], q[7])
ops.MeasureFock() | q
Nshots=1000
eng = RemoteEngine("X8")
results = eng.run(prog, shots=Nshots)
I think (q[0] and q[1]) are entangled and (q[4] and q[4]) are entangled as well .
I have tried to plot the results to see if their final measurement show any form of correlation.
aa = list(zip(results.samples[:,0], results.samples[:,1]))
L=[]
for i in range(len(results.samples[:,1])):
L.append(str(aa[i][0])+ str(aa[i][1]))
import matplotlib.pyplot as plt
plt.hist(L) #gives you a histogram of your array 'a'
plt.show() #
print('\n (q[0] and q[1]) modes measurement results:\n')
print([[x,aa.count(x)] for x in set(aa)])
(q[0] and q[1]) modes measurement results follow. [[(4, 0), 5] means that 5 times q[0] detects 4 photons and q[1] detects none.
[[(4, 0), 5], [(3, 1), 4], [(0, 2), 29], [(0, 5), 2], [(2, 2), 2], [(1, 0), 153], [(1, 3), 1], [(3, 0), 19], [(3, 3), 1], [(5, 0), 4], [(0, 1), 139], [(2, 4), 1], [(1, 2), 10], [(2, 1), 13], [(3, 2), 1], [(4, 1), 1], [(0, 0), 496], [(1, 1), 48], [(0, 3), 10], [(2, 0), 61]]
I do not see the entanglement between them at all.
How to interpret the data to show the entanglement.
Compared to Qiskit, I can find out how many times they both end up in (00, 01, 10,11).