def run3D(size=4,tSteps=5,errorVec3 = testvec4, errorVec4=testvec4,timespace=[1,1],boundary_weight = 1,stabilizersNotComplete=0):


   t0 = time.time()
   L=planar_lattice.PlanarLattice(size)
   PL=planar_lattice.PlanarLattice3D(size)

   for i in range(tSteps):                     # loop over time                                                       
        L.measureNoisyStabilizers("plaquette",errorVec3, errorVec4,stabilizersNotComplete)
        L.measureNoisyStabilizers("star",errorVec3,errorVec4,stabilizersNotComplete)                                
        PL.addMeasurement(L)         # add the updated 2D lattice to 3D array

   L.measurePlaquettes(0)                      # measure one more layer with
   L.measureStars(0)                           # perfect stabilizers and add
   PL.addMeasurement(L)                        # this to the parity Lattice

   PL.findAnyons()

#   L.showArray("all",0)
   
   matchingX=perfect_matching.match_planar_3D(size,"plaquette",PL.anyon_positions_P,timespace,boundary_weight)
   matchingZ=perfect_matching.match_planar_3D(size,"star",PL.anyon_positions_S,timespace)

   flipsX=squashMatching(size,"X",matchingX)
   flipsZ=squashMatching(size,"Z",matchingZ)

   L.apply_flip_array("Z",flipsZ)
   L.apply_flip_array("X",flipsX)
 
   return L.measure_logical()
Exemplo n.º 2
0
def run3Dspin(size=8,errortype='normal',orbit='abrupt',tSteps=8,phaseParameters=0,timespace=[1,1],boundary_weight = 1):

# choose phaseParameters=0 to take the default values (as below )
# otherwise this should be a list of the form       [sdInX,sdInYsdInZ,Pj,prX,prY,prZ,initStateError,measureError]

   L=spin_lattice.SpinLattice(size)


#   generateArray(sdInX=0.01,sdInY=0.01,sdInZ=0.01,Pj=0.0016,prX=0.01/3,prY=0.01/3,prZ=0.01/3,initStateError=0.01,measureError=0.01): Default values    
   if phaseParameters ==0:
      pX,pY,pZ=0.002,0.002,0.002
      L.generateArray()
      d_error=0
   else: 
      sdInX,sdInY,sdInZ,Pj,prX,prY,prZ,initStateError,measureError,dataQubitError=phaseParameters
#      print "sp.run3Dphase sdInZ =",sdInZ

      L.generateArray(errortype,orbit,sdInX,sdInY,sdInZ,Pj,prX,prY,prZ,initStateError,measureError)
      d_error = dataQubitError/3.
   
 #     print L.errorArray[1][2][0]


   PL=planar_lattice.PlanarLattice3D(size)

   L.applyRandomErrors(0,0)   # leave this here for initialisation                                                    
   

   for i in range(tSteps):                     # loop over time                                                       

      L.measureNoisyStabilizers("plaquette")
      #L.measurePlaquettes(0)
      L.applyRandomErrorsXYZ(d_error,d_error,d_error)
       
      L.measureNoisyStabilizers("star")
      #L.measureStars(0) 
      L.applyRandomErrorsXYZ(d_error,d_error,d_error)
      PL.addMeasurement(L)         # add the updated 2D lattice to 3D array

   L.measurePlaquettes(0)                      # measure one more layer with
   L.measureStars(0)                           # perfect stabilizers and add
   PL.addMeasurement(L)             # this to the parity Lattice

   PL.findAnyons()
   


   matchingX=perfect_matching.match_planar_3D(size,"plaquette",PL.anyon_positions_P,timespace,boundary_weight)
   matchingZ=perfect_matching.match_planar_3D(size,"star",PL.anyon_positions_S,timespace,boundary_weight)

   flipsX=squashMatching(size,"X",matchingX)
   flipsZ=squashMatching(size,"Z",matchingZ)



   L.apply_flip_array("X",flipsX)
   L.apply_flip_array("Z",flipsZ)


   return L.measure_logical()
def run3Drandom(size=4,tSteps=5,p=0.05,pLie=0.00,timespace = [1,1],showTextArray=False):

   L=planar_lattice.PlanarLattice(size)
   PL=planar_lattice.PlanarLattice3D(size)
   

   for i in range(tSteps):                     # loop over time      
                
      L.applyRandomErrors(p,p)
      L.measurePlaquettes(pLie)               
      L.measureStars(pLie)                    
      PL.addMeasurement(L)         # add the updated 2D lattice to 3D array


   L.measurePlaquettes(0)                      # measure one more layer with
   L.measureStars(0)                           # perfect stabilizers and add
   PL.addMeasurement(L)             # this to the parity Lattice

   if showTextArray==True: L.showArrayText("errors","X")
   
   PL.findAnyons()

   matchingX=perfect_matching.match_planar_3D(size,"plaquette",PL.anyon_positions_P,timespace)
   matchingZ=perfect_matching.match_planar_3D(size,"star",PL.anyon_positions_S,timespace)


   flipsX=squashMatching(size,"X",matchingX)
   flipsZ=squashMatching(size,"Z",matchingZ)
   
   L.apply_flip_array("Z",flipsZ)
   L.apply_flip_array("X",flipsX)

   return L.measure_logical()
Exemplo n.º 4
0
def run3Drandom(size=4,
                tSteps=5,
                p=0.05,
                pLie=0.00,
                timespace=[1, 1],
                showTextArray=False):

    t0 = time.time()
    L = planar_lattice.PlanarLattice(size)
    PL = planar_lattice.PlanarLattice3D(size)

    L.applyRandomErrors(0, 0)  # leave this here for initialisation

    for i in range(tSteps):  # loop over time

        L.applyRandomErrors(p, p)
        L.measurePlaquettes(pLie)
        L.measureStars(pLie)

        #L.constructLists()
        PL.addMeasurement(L)  # add the updated 2D lattice to 3D array

    L.measurePlaquettes(0)  # measure one more layer with
    L.measureStars(0)  # perfect stabilizers and add
    PL.addMeasurement(L)  # this to the parity Lattice
    #   L.showArray("stabilizers","X")
    #   L.showArray("errors","X")

    if showTextArray == True: L.showArrayText("errors", "X")

    PL.findAnyons()

    matchingX = perfect_matching.match_planar_3D(size, "plaquette",
                                                 PL.anyon_positions_P,
                                                 timespace)
    matchingZ = perfect_matching.match_planar_3D(size, "star",
                                                 PL.anyon_positions_S,
                                                 timespace)

    flipsX = squashMatching(size, "X", matchingX)
    flipsZ = squashMatching(size, "Z", matchingZ)

    #L.showArray("errors","X")

    L.apply_flip_array("Z", flipsZ)
    L.apply_flip_array("X", flipsX)
    #   L.showArray("errors","X")
    #L.showArray("errors","X")
    #L.showArray("errors","Z")

    return L.measure_logical()
Exemplo n.º 5
0
def run3D(size=4,tSteps=5,errorVec3 = testvec4, errorVec4=testvec4,timespace=[1,1],boundary_weight = 1,stabilizersNotComplete=0):


   t0 = time.time()
   L=planar_lattice.PlanarLattice(size)
   PL=planar_lattice.PlanarLattice3D(size)

   L.applyRandomErrors(0,0)   # leave this here for initialisation                                                    


#   t1 = time.time()
#   print 'initialisation ',t1-t0
   for i in range(tSteps):                     # loop over time                                                       

        L.measureNoisyStabilizers("plaquette",errorVec3, errorVec4,stabilizersNotComplete)
        L.measureNoisyStabilizers("star",errorVec3,errorVec4,stabilizersNotComplete)                                
        PL.addMeasurement(L)         # add the updated 2D lattice to 3D array

#        L.showArrayText("stabs")

   L.measurePlaquettes(0)                      # measure one more layer with
   L.measureStars(0)                           # perfect stabilizers and add
   PL.addMeasurement(L)             # this to the parity Lattice

   PL.findAnyons()
   
#   print 'P anyons', sum([len(_) for _ in PL.anyon_positions_P])
 #  print 'S anyons', sum([len(_) for _ in PL.anyon_positions_S])
   

#   t2 = time.time()
#   print 'loop over timeslices ', t2 -t1  

   matchingX=perfect_matching.match_planar_3D(size,"plaquette",PL.anyon_positions_P,timespace,boundary_weight)

#   t3 = time.time()
 #  print 'perfect matching ', t3 -t2  


   #matchingZ=perfect_matching.match_toric_3D(size,PL.anyon_positions_S,timespace)

   flipsX=squashMatching(size,"X",matchingX)
   #flipsZ=squashMatching(size,matchingZ)
#   t4 = time.time()
 #  print 'squash matching ',t4-t3
#   L.showArray("errors","X")

   #L.apply_flip_array("Z",flipsZ)
   L.apply_flip_array("X",flipsX)

 #  L.showArray("errors","X")
   #L.showArray("errors","Z")

   return L.measure_logical()
Exemplo n.º 6
0
def run3D(size=4,
          tSteps=5,
          errorVec3=testvec4,
          errorVec4=testvec4,
          timespace=[1, 1],
          boundary_weight=1,
          stabilizersNotComplete=0):

    t0 = time.time()
    L = planar_lattice.PlanarLattice(size)
    PL = planar_lattice.PlanarLattice3D(size)

    for i in range(tSteps):  # loop over time
        L.measureNoisyStabilizers("plaquette", errorVec3, errorVec4,
                                  stabilizersNotComplete)
        L.measureNoisyStabilizers("star", errorVec3, errorVec4,
                                  stabilizersNotComplete)
        PL.addMeasurement(L)  # add the updated 2D lattice to 3D array

    L.measurePlaquettes(0)  # measure one more layer with
    L.measureStars(0)  # perfect stabilizers and add
    PL.addMeasurement(L)  # this to the parity Lattice

    PL.findAnyons()

    #   L.showArray("all",0)

    matchingX = perfect_matching.match_planar_3D(size, "plaquette",
                                                 PL.anyon_positions_P,
                                                 timespace, boundary_weight)
    matchingZ = perfect_matching.match_planar_3D(size, "star",
                                                 PL.anyon_positions_S,
                                                 timespace)

    flipsX = squashMatching(size, "X", matchingX)
    flipsZ = squashMatching(size, "Z", matchingZ)

    L.apply_flip_array("Z", flipsZ)
    L.apply_flip_array("X", flipsX)

    return L.measure_logical()
Exemplo n.º 7
0
def run3Dtest(size=8,tSteps=100,errorVec3 = testvec4, errorVec4=testvec4,timespace=[1,1],boundary_weight = 1):

   errvec_file = "error_vectors/basic_0.txt"
   errorVec3, errorVec4 = [[] if x=={} else x[0.0] for x in load_errors.load(errvec_file)]
   

   t0 = time.time()
   L=planar_lattice.PlanarLattice(size)
   PL=planar_lattice.PlanarLattice3D(size)

   L.applyRandomErrors(0,0)   # leave this here for initialisation                                                    


#   t1 = time.time()
#   print 'initialisation ',t1-t0
   for i in range(tSteps):                     # loop over time                                                       

        L.measureNoisyStabilizers("plaquette",errorVec3, errorVec4)
        L.measureNoisyStabilizers("star",errorVec3,errorVec4)                                
        PL.addMeasurement(L)         # add the updated 2D lattice to 3D array


   L.measurePlaquettes(0)                      # measure one more layer with
   L.measureStars(0)                           # perfect stabilizers and add
   PL.addMeasurement(L)             # this to the parity Lattice

   PL.findAnyons()
   
#   print 'P anyons', sum([len(_) for _ in PL.anyon_positions_P])
 #  print 'S anyons', sum([len(_) for _ in PL.anyon_positions_S])
   

#   t2 = time.time()
#   print 'loop over timeslices ', t2 -t1  

   matchingX=perfect_matching.match_planar_3D(size,"plaquette",PL.anyon_positions_P,timespace,boundary_weight)

#   t3 = time.time()
 #  print 'perfect matching ', t3 -t2  


   #matchingZ=perfect_matching.match_toric_3D(size,PL.anyon_positions_S,timespace)

   flipsX=squashMatching(size,"X",matchingX)
   #flipsZ=squashMatching(size,matchingZ)
#   t4 = time.time()
 #  print 'squash matching ',t4-t3
#   L.showArray("errors","X")
   
   Lbefore = copy.copy(L)

   #L.apply_flip_array("Z",flipsZ)
   L.apply_flip_array("X",flipsX)

   if L.measure_logical[0]==-1:

      Lbefore.showArray("errors","X")
      L.showArray("errors","X")
      
   #L.showArray("errors","Z")

   return L.measure_logical()
Exemplo n.º 8
0
def run3Dshow(size=8,
              tSteps=20,
              errorVec3=testvec4,
              errorVec4=testvec4,
              timespace=[1, 1],
              boundary_weight=1,
              stabilizersNotComplete=0):

    L = planar_lattice.PlanarLattice(size)
    PL = planar_lattice.PlanarLattice3D(size)

    L.applyRandomErrors(0, 0)  # leave this here for initialisation

    #   t1 = time.time()
    #   print 'initialisation ',t1-t0
    for i in range(tSteps):  # loop over time

        L.measureNoisyStabilizers("plaquette", errorVec3, errorVec4,
                                  stabilizersNotComplete)
        L.measureNoisyStabilizers("star", errorVec3, errorVec4,
                                  stabilizersNotComplete)
        PL.addMeasurement(L)  # add the updated 2D lattice to 3D array

    L.measurePlaquettes(0)  # measure one more layer with
    L.measureStars(0)  # perfect stabilizers and add
    PL.addMeasurement(L)  # this to the parity Lattice

    PL.findAnyons()

    matchingX = perfect_matching.match_planar_3D(size, "plaquette",
                                                 PL.anyon_positions_P,
                                                 timespace, boundary_weight)

    #   t3 = time.time()
    #  print 'perfect matching ', t3 -t2

    #matchingZ=perfect_matching.match_toric_3D(size,PL.anyon_positions_S,timespace)

    flipsX = squashMatching(size, "X", matchingX)
    #flipsZ=squashMatching(size,matchingZ)
    #   t4 = time.time()
    #  print 'squash matching ',t4-t3

    Lbefore = copy.deepcopy(L)

    #L.apply_flip_array("Z",flipsZ)
    L.apply_flip_array("X", flipsX)
    log = L.measure_logical()

    if log[0] == -1:

        print 'P anyons', sum([len(_) for _ in PL.anyon_positions_P])
        print PL.anyon_positions_P
        print matchingX
        for x in flipsX:
            print x

        perfect_matching.match_planar_3D(size, "plaquette",
                                         PL.anyon_positions_P, timespace,
                                         boundary_weight, True)

        Lbefore.showArray("errors", "X")
        L.showArray("errors", "X")

    #L.showArray("errors","Z")

    return L.measure_logical()
Exemplo n.º 9
0
def run3Dtest(size=8,
              tSteps=100,
              errorVec3=testvec4,
              errorVec4=testvec4,
              timespace=[1, 1],
              boundary_weight=1):

    errvec_file = "error_vectors/basic_0.txt"
    errorVec3, errorVec4 = [[] if x == {} else x[0.0]
                            for x in load_errors.load(errvec_file)]

    t0 = time.time()
    L = planar_lattice.PlanarLattice(size)
    PL = planar_lattice.PlanarLattice3D(size)

    L.applyRandomErrors(0, 0)  # leave this here for initialisation

    #   t1 = time.time()
    #   print 'initialisation ',t1-t0
    for i in range(tSteps):  # loop over time

        L.measureNoisyStabilizers("plaquette", errorVec3, errorVec4)
        L.measureNoisyStabilizers("star", errorVec3, errorVec4)
        PL.addMeasurement(L)  # add the updated 2D lattice to 3D array

    L.measurePlaquettes(0)  # measure one more layer with
    L.measureStars(0)  # perfect stabilizers and add
    PL.addMeasurement(L)  # this to the parity Lattice

    PL.findAnyons()

    #   print 'P anyons', sum([len(_) for _ in PL.anyon_positions_P])
    #  print 'S anyons', sum([len(_) for _ in PL.anyon_positions_S])

    #   t2 = time.time()
    #   print 'loop over timeslices ', t2 -t1

    matchingX = perfect_matching.match_planar_3D(size, "plaquette",
                                                 PL.anyon_positions_P,
                                                 timespace, boundary_weight)

    #   t3 = time.time()
    #  print 'perfect matching ', t3 -t2

    #matchingZ=perfect_matching.match_toric_3D(size,PL.anyon_positions_S,timespace)

    flipsX = squashMatching(size, "X", matchingX)
    #flipsZ=squashMatching(size,matchingZ)
    #   t4 = time.time()
    #  print 'squash matching ',t4-t3
    #   L.showArray("errors","X")

    Lbefore = copy.copy(L)

    #L.apply_flip_array("Z",flipsZ)
    L.apply_flip_array("X", flipsX)

    if L.measure_logical[0] == -1:

        Lbefore.showArray("errors", "X")
        L.showArray("errors", "X")

    #L.showArray("errors","Z")

    return L.measure_logical()
Exemplo n.º 10
0
def run3Dspin(size=8,
              errortype='normal',
              orbit='abrupt',
              tSteps=8,
              phaseParameters=0,
              timespace=[1, 1],
              boundary_weight=1):

    # choose phaseParameters=0 to take the default values (as below )
    # otherwise this should be a list of the form       [sdInX,sdInYsdInZ,Pj,prX,prY,prZ,initStateError,measureError]

    L = spin_lattice.SpinLattice(size)

    #   generateArray(sdInX=0.01,sdInY=0.01,sdInZ=0.01,Pj=0.0016,prX=0.01/3,prY=0.01/3,prZ=0.01/3,initStateError=0.01,measureError=0.01): Default values
    if phaseParameters == 0:
        pX, pY, pZ = 0.002, 0.002, 0.002
        L.generateArray()
        d_error = 0
    else:
        sdInX, sdInY, sdInZ, Pj, prX, prY, prZ, initStateError, measureError, dataQubitError = phaseParameters
        #      print "sp.run3Dphase sdInZ =",sdInZ

        L.generateArray(errortype, orbit, sdInX, sdInY, sdInZ, Pj, prX, prY,
                        prZ, initStateError, measureError)
        d_error = dataQubitError / 3.

#     print L.errorArray[1][2][0]

    PL = planar_lattice.PlanarLattice3D(size)

    L.applyRandomErrors(0, 0)  # leave this here for initialisation

    for i in range(tSteps):  # loop over time

        L.measureNoisyStabilizers("plaquette")
        #L.measurePlaquettes(0)
        L.applyRandomErrorsXYZ(d_error, d_error, d_error)

        L.measureNoisyStabilizers("star")
        #L.measureStars(0)
        L.applyRandomErrorsXYZ(d_error, d_error, d_error)
        PL.addMeasurement(L)  # add the updated 2D lattice to 3D array

    L.measurePlaquettes(0)  # measure one more layer with
    L.measureStars(0)  # perfect stabilizers and add
    PL.addMeasurement(L)  # this to the parity Lattice

    PL.findAnyons()

    matchingX = perfect_matching.match_planar_3D(size, "plaquette",
                                                 PL.anyon_positions_P,
                                                 timespace, boundary_weight)
    matchingZ = perfect_matching.match_planar_3D(size, "star",
                                                 PL.anyon_positions_S,
                                                 timespace, boundary_weight)

    flipsX = squashMatching(size, "X", matchingX)
    flipsZ = squashMatching(size, "Z", matchingZ)

    L.apply_flip_array("X", flipsX)
    L.apply_flip_array("Z", flipsZ)

    return L.measure_logical()