diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 29fe6ba..c13b710 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -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] diff --git a/abp/static/scripts/editor.js b/abp/static/scripts/editor.js index 87c2d7b..9ce4ad7 100644 --- a/abp/static/scripts/editor.js +++ b/abp/static/scripts/editor.js @@ -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() {}; diff --git a/abp/static/scripts/main.js b/abp/static/scripts/main.js index 9e16859..30675a1 100644 --- a/abp/static/scripts/main.js +++ b/abp/static/scripts/main.js @@ -1,3 +1,5 @@ +console.log("abp v0.4.24"); + window.onload = function() { graph.prepare(); materials.prepare(); diff --git a/abp/static/scripts/materials.js b/abp/static/scripts/materials.js index 68caffa..d0ee18d 100644 --- a/abp/static/scripts/materials.js +++ b/abp/static/scripts/materials.js @@ -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(); diff --git a/examples/visualization/raussendorf.py b/examples/visualization/raussendorf.py new file mode 100644 index 0000000..70507d7 --- /dev/null +++ b/examples/visualization/raussendorf.py @@ -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) +