Anders and Briegel in Python
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

45 satır
1.1KB

  1. from abp.fancy import GraphState
  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(*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. psi = GraphState()
  26. while True:
  27. for node in nodes:
  28. psi.add_qubit(str(node), position=xyz(node[0], node[1], node[2]), vop="identity")
  29. psi.update(0.1)
  30. for edge in edges:
  31. psi.act_cz(str(edge[0]), str(edge[1]))
  32. psi.update(0.1)