Anders and Briegel in Python
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

47 linhas
1.2KB

  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(*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