Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stress_test.py 1.2KB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from abp import GraphState, VizClient
  2. from abp.util import xyz
  3. import numpy as np
  4. import time
  5. import itertools
  6. threedee_unit_cell = (
  7. (( 0, 0, 0), (0, 1, 0)),
  8. (( 0, 0, 0), (1, 0, 0)),
  9. (( 1, 0, 0), (1, 1, 0)),
  10. (( 0, 1, 0), (1, 1, 0)))
  11. def add_offset(vector, offset):
  12. """ Offset a vector in n-dimensional space """
  13. return tuple(v + o for v, o in zip(vector, offset))
  14. def offset_unit_cell(unit_cell, offset):
  15. """ Offset a unit cell """
  16. return {(add_offset(a, offset), add_offset(b, offset)) for a, b in unit_cell}
  17. def lattice(unit_cell, size):
  18. """ Generate a lattice from a unit cell """
  19. edges = set()
  20. for offset in itertools.product(*list(map(range, size))):
  21. edges |= offset_unit_cell(unit_cell, offset)
  22. nodes = set(itertools.chain(*edges))
  23. return nodes, edges
  24. nodes, edges = lattice(threedee_unit_cell, (4, 4, 4))
  25. v = VizClient()
  26. while True:
  27. psi = GraphState()
  28. for node in nodes:
  29. v.update(psi, 0.1)
  30. psi.add_qubit(str(node), position=xyz(node[0], node[1], node[2]), vop="identity")
  31. for edge in edges:
  32. v.update(psi, 0.1)
  33. psi.act_cz(str(edge[0]), str(edge[1]))
  34. del psi