Sfoglia il codice sorgente

merge branch 'pete'

master
Pete Shadbolt 8 anni fa
parent
commit
7544a79a72
5 ha cambiato i file con 62 aggiunte e 2 eliminazioni
  1. +2
    -0
      .bumpversion.cfg
  2. +1
    -0
      abp/static/scripts/editor.js
  3. +2
    -0
      abp/static/scripts/main.js
  4. +0
    -2
      abp/static/scripts/materials.js
  5. +57
    -0
      examples/visualization/raussendorf.py

+ 2
- 0
.bumpversion.cfg Vedi File

@@ -11,6 +11,8 @@ tag = True

[bumpversion:file:abp/static/index.html]

[bumpversion:file:abp/static/scripts/main.js]

[bumpversion:file:README.md]

[bumpversion:file:bin/abpserver]


+ 1
- 0
abp/static/scripts/editor.js Vedi File

@@ -127,6 +127,7 @@ editor.makeGrid = function() {
editor.grid.renderOrder = 1000;
editor.setOrientation(0);
gui.scene.add(editor.grid);
gui.scene.children[0].renderOrder = -3000;
};

editor.update = function() {};


+ 2
- 0
abp/static/scripts/main.js Vedi File

@@ -1,3 +1,5 @@
console.log("abp v0.4.24");

window.onload = function() {
graph.prepare();
materials.prepare();


+ 0
- 2
abp/static/scripts/materials.js Vedi File

@@ -22,10 +22,8 @@ materials.prepare = function() {
transparent: true,
vertexColors: THREE.VertexColors
});
materials.edge.depthTest = false;
};

console.log("what");

materials.makeCurve = function(a, b) {
var length = new THREE.Vector3().subVectors(a, b).length();


+ 57
- 0
examples/visualization/raussendorf.py Vedi File

@@ -0,0 +1,57 @@
from abp import GraphState, VizClient
from abp.util import xyz
import numpy as np
import time
import itertools
import networkx as nx

raussendorf_unit_cell = (
((1, 0, 0), (1, 1, 0)), ((0, 1, 0), (1, 1, 0)),
((1, 2, 0), (1, 1, 0)), ((2, 1, 0), (1, 1, 0)),
((1, 2, 2), (1, 1, 2)), ((0, 1, 2), (1, 1, 2)),
((1, 0, 2), (1, 1, 2)), ((2, 1, 2), (1, 1, 2)),
((0, 1, 0), (0, 1, 1)), ((0, 0, 1), (0, 1, 1)),
((0, 1, 2), (0, 1, 1)), ((0, 2, 1), (0, 1, 1)),
((2, 1, 0), (2, 1, 1)), ((2, 0, 1), (2, 1, 1)),
((2, 1, 2), (2, 1, 1)), ((2, 2, 1), (2, 1, 1)),
((1, 0, 0), (1, 0, 1)), ((0, 0, 1), (1, 0, 1)),
((1, 0, 2), (1, 0, 1)), ((2, 0, 1), (1, 0, 1)),
((1, 2, 0), (1, 2, 1)), ((0, 2, 1), (1, 2, 1)),
((1, 2, 2), (1, 2, 1)), ((2, 2, 1), (1, 2, 1)))


def add_offset(vector, offset):
""" Offset a vector in n-dimensional space """
return tuple(v + o*2 for v, o in zip(vector, offset))


def offset_unit_cell(unit_cell, offset):
""" Offset a unit cell """
return {(add_offset(a, offset), add_offset(b, offset)) for a, b in unit_cell}


def lattice(unit_cell, size):
""" Generate a lattice from a unit cell """
edges = set()
for offset in itertools.product(*map(range, size)):
edges |= offset_unit_cell(unit_cell, offset)

nodes = set(itertools.chain(*edges))
return nodes, edges

nodes, edges = lattice(raussendorf_unit_cell, (2, 2, 3 ))

psi = GraphState()
for node in nodes:
x, y, z = node
color = "red" if (x+y+z) % 2 > 0 else "black"
print color
psi.add_qubit(node, position=xyz(*node), color=color)
psi.act_hadamard(node)

for edge in edges:
psi.act_cz(edge[0], edge[1])

v = VizClient()
v.update(psi)


Loading…
Annulla
Salva