Finite geometries

Finite geometries#

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

import qse
import numpy as np

Now we generate a hexagon.

qhex = qse.lattices.ring(1.0, 6)
qhex.draw(radius=1)
../_images/ae60afff0d71373ca0bc592aac6fdffa3de13d1ded9fe7dc60d107c90b9cc4fa.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/3718cc60887415a4c8887bf554bb4dbeaaddf5d2f67073496e32a2c42fb7677f.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/cde34d4f5d954aa020963598dd9bb7d04237b17aaff8ba8085b73f7fb6ee7ac4.png

Let’s try another example with octagon geometry.

qoct = qse.lattices.ring(1.0, 8)
qoct.draw(radius=1)
../_images/4ca687467b4d7c6eb462028a5019cdf9a225123fc167a4455bc8d52193822cd6.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/bf422a76ff442893fb774168adbea8f91be16cfe9dea54331af92804c35cda12.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/96b490540b5197f05efa0f203c55986dccbbf97db2f16d5b38d0cd6eecda30a2.png ../_images/18ea3cef3e8e1209d43b84e5b8e45e2ddbc6dcc3610e71f6b01d94ff4169d6f1.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/13899eee42ea73e3f7ce5483ce6b9929a9cb8f6761bd08ed6c25145edf6bd55c.png