Beispiel #1
0
def pairs_incr(gamma,eta,tmin,tmax,tstep,fname,mode=(0,1)):
  '''Print the coincidence rates to a file for a range of times with constant
increment
gamma  : Magnitude of (complex) on-site potential
eta    : Magnitude of couplings
tmin   : Start time
tmax   : End time
tstep  : Increment between times
fname  : Path to output file
mode   : (optional) input modes
return : None'''
  pairs=[(0,1),(0,2),(0,3),(0,4),(0,5),(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),\
(2,5),(3,4),(3,5),(4,5)]
  t=tmin
  fmt="{0:.6f} {1:.6f}"
  for i in range(len(pairs)):
    fmt+=" {"+str(i+2)+":.6f}"
  fmt+="\n"
  with open(fname, 'w') as fout:
    fout.write("# gamma {0:.4f}\n# eta   {1:.4f}\n# t norm 01 02 03 04 \
05 12 13 14 15 23 24 25 34 35 45\n".format(gamma,eta))
    while t<tmax:
      U,norm = threesitematrix(gamma,eta,t)
      #powers = [abs2(U[i,mode[0]]*U[j,mode[1]]+U[i,mode[1]]*U[j,mode[0]])\
      powers = [abs2(U[i,mode[0]]*U[j,mode[1]]+U[i,mode[1]]*U[j,mode[0]])\
for i,j in pairs]
      fout.write(fmt.format(t,norm,*powers))
      powers/=sum(powers) # Normalise visible coincidences to 1
      t+=tstep
Beispiel #2
0
def singles_exp(gamma,eta,tree,sym,mode=0):
  '''Print the singles rates to a file for the range of times that I
want in the experiment. Generate unitaries for experimental run
gamma  : Magnitude of (complex) on-site potential
eta    : Magnitude of couplings
tree   : Binary tree representing points
sym    : Symmetry of the matrix (symmetric | broken)
mode   : (optional) input mode
return : None'''
  fmt="{0:.6f} {1:.6f} {2:.6f} {3:.6f} {4:.6f} {5:.6f} {6:.6f} {7:.6f}\n"
  with open("data/threesite/"+sym+"/simulation/singles{0:d}.dat".format(mode),\
'w') as fout:
    fout.write("# gamma {0:.4f}\n# eta   {1:.4f}\n\
# t norm 0 1 2 3 4 5\n".format(gamma,eta))
    for n,t in enumerate(tree.points()):
      U,norm = threesitematrix(gamma,eta,t)
      powers=[abs2(U[i,mode]) for i in range(6)]
      fout.write(fmt.format(t,norm,*powers))
      with open("data/threesite/"+sym+"/unitaries/"+sym+str(n)+".csv", 'w') \
as matrix:
        matrix.write("# gamma {0:.4f}\n# eta   {1:.4f}\n\
# t     {2:.4f}\n# norm  {3:.4f}\n".format(gamma,eta,t,norm))
        for i in range(6):
          for j in range(5):
            z=U[i,j]
            matrix.write("({0:.6f},{1:.6f}),".format(z.real,z.imag))
          z=U[i,5]
          matrix.write("({0:.6f},{1:.6f})\n".format(z.real,z.imag))
Beispiel #3
0
def singles_incr(gamma,eta,tmin,tmax,tstep,fname,mode=0):
  '''Print the singles rates to a file for a range of times with constant
increment
gamma  : Magnitude of (complex) on-site potential
eta    : Magnitude of couplings
tmin   : Start time
tmax   : End time
tstep  : Increment between times
fname  : Path to output file
mode   : (optional) input mode
return : None'''
  t=tmin
  fmt="{0:.6f} {1:.6f} {2:.6f} {3:.6f} {4:.6f} {5:.6f} {6:.6f} {7:.6f}\n"
  with open(fname,'w') as fout:
    fout.write("# gamma {0:.4f}\n# eta   {1:.4f}\n\
# t norm 0 1 2 3 4 5\n".format(gamma,eta))
    while t<tmax:
      U,norm = threesitematrix(gamma,eta,t)
      powers=[abs2(U[i,mode]) for i in range(6)]
      fout.write(fmt.format(t,norm,*powers))
      t+=tstep
Beispiel #4
0
def pairs_exp(gamma,eta,tree,sym,mode=(0,1)):
  '''Print the singles rates to a file for the range of times that I
want in the experiment.
gamma  : Magnitude of (complex) on-site potential
eta    : Magnitude of couplings
tree   : Binary tree representing points
sym    : Symmetry of the matrix (symmetric | broken)
mode   : (optional) input mode
return : None'''
  pairs=[(0,1),(0,2),(0,3),(0,4),(0,5),(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),\
(2,5),(3,4),(3,5),(4,5)]
  fmt="{0:.6f} {1:.6f}"
  for i in range(len(pairs)):
    fmt+=" {"+str(i+2)+":.6f}"
  fmt+="\n"
  with open("data/threesite/"+sym+"/simulation/pairs{0:d}{1:d}.dat".format(\
mode[0],mode[1]), 'w') as fout:
    fout.write("# gamma {0:.4f}\n# eta   {1:.4f}\n# t norm 01 02 03 04 \
05 12 13 14 15 23 24 25 34 35 45\n".format(gamma,eta))
    for n,t in enumerate(tree.points()):
      U,norm = threesitematrix(gamma,eta,t)
      powers = [abs2(U[i,mode[0]]*U[j,mode[1]]+U[i,mode[1]]*U[j,mode[0]])\
for i,j in pairs]
      fout.write(fmt.format(t,norm,*powers))
Beispiel #5
0
 12 02\n".format(gamma,eta))
  singles_fmt="{0:.6f}"
  for i in range(1,13):
    singles_fmt+=" {"+str(i)+":.6f}"
  singles_fmt+="\n"
  pairs_fmt="{0:.6f}"
  for i in range(1,31):
    pairs_fmt+=" {"+str(i)+":.6f}"
  pairs_fmt+="\n"
  fidelities_fmt="{0:.6f}"
  for i in range(1,10):
    fidelities_fmt+=" {"+str(i)+":.6f}"
  fidelities_fmt+="\n"

  for n,t in enumerate(symmetric_tree.points()):
    U,norm=threesitematrix(gamma,eta,t)
    singles,singles_err,pairs,pairs_err=GetData("symmetric",n)
    # Get fidelities
    singles_fidelities=[1-0.5*sum(abs(numpy.array([abs2(U[i,j]) \
for j in range(6)])-singles[i])) for i in range(6)]
    pairs_ideal=[IdealPairs(U,mode) for mode in [(0,1),(1,2),(0,2)]]
    pairs_fidelities=[1-0.5*sum(abs(pairs_ideal[i]-pairs[i])) for i in range(3)]
    fidelities_out.write(fidelities_fmt.format(t,*numpy.append(\
singles_fidelities,pairs_fidelities)))
    # Write experimental data
    for i in range(6):
      singles_out[i].write(singles_fmt.format(t,*numpy.append(singles[i],\
singles_err[i])))
    for i in range(3):
      pairs_out[i].write(pairs_fmt.format(t,*numpy.append(pairs[i],\
pairs_err[i])))