def test_wallbounce(): if getz(4): printbold("4: Testing Wall bounce") qg = QGOL() qg.bc[0,0,0] = Cell(True) qg.bc[0,1,0] = Cell(True) qg.bc[-1,1,0] = Cell(True) qg.bc[-1,0,0] = Cell(True) qg.bc[1,1,0] = Cell(True) qg.bc[1,0,0] = Cell(True) qg.bc[2,1,0] = Cell(True) qg.bc[2,0,0] = Cell(True) qg.bc[3,3,3] = Cell(True) print("Wandering cell in position : ",[(x,y,z) for conf in qg.s.cs for (x,y,z) in conf.tuple() if z]) print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) print("Wandering cell in position : ",[(x,y,z) for conf in qg.s.cs for (x,y,z) in conf.tuple() if z]) return qg
def test_walls(): if getz(3): printbold("3: Testing Walls") qg = QGOL() qg.bc[0,0,0] = Cell(True) qg.bc[0,1,0] = Cell(True) qg.bc[-1,1,0] = Cell(True) qg.bc[-1,0,0] = Cell(True) qg.bc[1,1,0] = Cell(True) qg.bc[1,0,0] = Cell(True) qg.bc[2,1,0] = Cell(True) qg.bc[2,0,0] = Cell(True) print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) return qg
def test_hadamard(): printbold("12: Implementing a Hadamard Gate") qg = QGOL() qg.bc[0,0,0] = Cell(True) qg.bc[0,1,0] = Cell(True) qg.bc[-1,1,0] = Cell(True) qg.bc[-1,0,0] = Cell(True) qg.bc[1,1,0] = Cell(True) qg.bc[1,0,0] = Cell(True) qg.bc[2,1,0] = Cell(True) qg.bc[2,0,0] = Cell(True) qg.bc[1,-2,3] = Cell(True) qg.bc[5,-6,7] = Cell(True) qg.bc[-20,-18,19] = Cell(True) print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.evolve(100) print(qg) assert qg.numconf() == 8 return qg
def test_4cells(): printbold("15: Testing usual errored case with 4 cells (randomized)") qg = find_error()(4) print(qg) qg.next() print(qg) assert qg.numconf() > 0 return qg
def test_2cells(): printbold("13: Testing usual errored case with 2 cells (randomized)") qg = find_error()(2) print(qg) qg.next() print(qg) assert qg.numconf() == 1 return qg
def test_crossing(): printbold("16: Testing crossing (it should change the phase)") qg = QGOL() qg.bc[0,0,0] = Cell(True) qg.bc[0,1,1] = Cell(True) print(qg) qg.next() print(qg) assert qg.numconf() > 0 return qg
def test_L_usual2(): if getz(11): printbold("11: Testing Rule 3 and further evolution: another usual L shape") qg = QGOL() qg.bc[-1,0,0] = Cell(True) qg.bc[-1,1,0] = Cell(True) qg.bc[-1,0,1] = Cell(True) print(qg) qg.next() print(qg) return qg
def test_dislocLXaxis(): if getz(8): printbold("8: Testing Rule 3: dislocated L shape along X axis") qg = QGOL() qg.bc[1,0,1] = Cell(True) qg.bc[1,1,0] = Cell(True) qg.bc[0,1,0] = Cell(True) print(qg) qg.next() print(qg) return qg
def test_LXaxis(): if getz(7): printbold("7: Testing Rule 3: L shape along X axis") qg = QGOL() qg.bc[1,1,1] = Cell(True) qg.bc[1,1,0] = Cell(True) qg.bc[0,1,0] = Cell(True) print(qg) qg.next() print(qg) return qg
def test_stablesquare(): printbold("1: Testing stability of the well placed square") qg = QGOL() qg.bc[6,6,40] = Cell(True) qg.bc[6,7,40] = Cell(True) qg.bc[5,7,40] = Cell(True) qg.bc[5,6,40] = Cell(True) print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) return qg
def test_unstablesquare(): if getz(2): printbold("2: Testing unstability of the ill placed square") qg = QGOL() qg.bc[0,0,0] = Cell(True) qg.bc[0,1,0] = Cell(True) qg.bc[1,1,0] = Cell(True) qg.bc[1,0,0] = Cell(True) print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) return qg
def test_L_usual(): if getz(10): printbold("10: Testing Rule 3 and further evolution: usual L shape") qg = QGOL() qg.bc[0,0,0] = Cell(True) qg.bc[1,1,0] = Cell(True) qg.bc[1,0,0] = Cell(True) print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) return qg
def test_dislocLYaxis(): if getz(9): printbold("9: Testing Rule 3 and further evolution: dislocated L shape along Y axis") qg = QGOL() qg.bc[0,0,0] = Cell(True) qg.bc[1,1,1] = Cell(True) qg.bc[0,1,0] = Cell(True) print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) qg.next() print(qg) return qg