Hello,
For this circuit:
I first write this code (Thanks to @Tom_Bromley )
prog = sf.Program(modes)
with prog.context as q:
Ket(initial_state) | q # Initial state preparation
BSgate() | (q[0], q[1])
BSgate() | (q[2], q[3])
#BSgate() | (q[1], q[2])
Rgate((np.pi)/(8)) | q[0]
Rgate((np.pi)/(8)) | q[2]
BSgate() | (q[0], q[1])
BSgate() | (q[2], q[3])
Rgate(0) | q[0]
Rgate((np.pi)/2) | q[2]
BSgate() | (q[0], q[1])
BSgate() | (q[2], q[3])
#MeasureFock() | q[0]
#MeasureFock() | q[2]
MeasureFock() | q
results = eng.run(prog)
However I am quite confused with cross sections like the following figure:
And do you think that I should follow which mode goes to where
For instance in my circuit
0 mode goes to 2nd mode
1st mode goes to 0 mode
2nd mode goes to 3rd mode and finally
3rd mode goes to 1st mode
So should I change the indices after first beam splitter like that:
prog = sf.Program(modes)
with prog.context as q:
Ket(initial_state) | q # Initial state preparation
BSgate() | (q[0], q[1]) #it is ok
BSgate() | (q[2], q[3]) #it is ok
#BSgate() | (q[1], q[2])
Rgate((np.pi)/(8)) | q[1] # here they are going different places
Rgate((np.pi)/(8)) | q[0] # same
BSgate() | (q[1], q[3])
BSgate() | (q[2], q[0])
Rgate(0) | q[3]
Rgate((np.pi)/2) | q[2]
BSgate() | (q[3], q[1])
BSgate() | (q[2], q[0])
#MeasureFock() | q[0]
#MeasureFock() | q[2]
MeasureFock() | q
results = eng.run(prog)