Finite geometries

Finite geometries#

Here we list a few examples of manipulating finite geometries. First we import the necessary modules.

import numpy as np

import qse

Now we generate a hexagon.

qhex = qse.lattices.ring(1.0, 6)
qhex.draw(radius=1)
../_images/5d433922031151ca71b8fcad0b3efe1ab3e4fd68720289c2ce9c400cc278e4a7.png

Now lets rotate it by 30 degrees.

qhex.rotate(30)
qhex.draw(radius=1)
print(qhex.positions.round(6))
[[ 0.866025  0.5     ]
 [ 0.        1.      ]
 [-0.866025  0.5     ]
 [-0.866025 -0.5     ]
 [-0.       -1.      ]
 [ 0.866025 -0.5     ]]
../_images/4e64210d1fa26d47f532b61265afb9947ed05df8f7a469cabf65dd18ffd98e7c.png

Now we scale the positions of qubits. All the points are defined around origin, and we scale the alternating points inversely.

scale = np.sqrt(2)
qhex.positions[::2] *= 1 / scale
qhex.positions[1::2] *= scale
qhex.draw(radius=2)
../_images/b2fbe4f8fb1b78e180c7b3a66d0284a3402c761477a5e82386e141e2ad8d5b81.png

Let’s try another example with octagon geometry.

qoct = qse.lattices.ring(1.0, 8)
qoct.draw(radius=1)
../_images/dc395f1efb09a1ad31c1244231b640e6997bb4a5145504e32c84815147d477f1.png

Here also we scale inversely the alternating points.

scale = np.sqrt(2)
qoct.positions[::2] *= 1 / scale
qoct.positions[1::2] *= scale
qoct.draw(radius=2)
../_images/1e665414010939735aed23368b96f12595802d47d8f6ef22a6693f05a8f96b95.png

Here is a combined example with 12 points.

q12 = qse.lattices.ring(1.0, 12)
q12.draw(radius=1)
scale = np.sqrt(2)
q12.positions[::2] *= 1 / scale
q12.positions[1::2] *= scale
q12.draw(radius=2)
../_images/2c88e6b755b5fd1e8cc91950377ad25af9a330b598866f2919b02ced55c0c571.png ../_images/fb1743fe871982327c952005c98dfd71a073817f4fd27778ab086766ae2c23e0.png

We can also create structures by adding different Qbits objects. See below

npoints = 6
qq = qse.Qbits()
qq.remove_dim("z")
for i, r in enumerate(np.linspace(1, 2, 2)):
    q = qse.lattices.ring(r, npoints)
    q.rotate(180 * (i + 1) / npoints)
    qq += q
qq.draw(radius=2)
qq.nqbits
12
../_images/b3ce24d86081f472d3bfb6742fb68b860f43c87082d586e7fe70683a50d40786.png