Exemple #1
0
def run2D(size=4, p=0.03, pLie=0, showArray=False):

    L = planar_lattice.PlanarLattice(size)

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

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

    L.findAnyons()

    matchingX = perfect_matching.match_planar_2D(size, "plaquette",
                                                 L.positions_anyons_P)
    matchingZ = perfect_matching.match_planar_2D(size, "star",
                                                 L.positions_anyons_S)

    L.apply_matching("X", matchingX)
    L.apply_matching("Z", matchingZ)

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

    return L.measure_logical()
Exemple #2
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()
Exemple #3
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()
Exemple #4
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()
Exemple #5
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()