Examples

CNOTAlgorithm

from struqture_py.spins import PauliProduct, SpinHamiltonianSystem
from py_alqorithms import CNOTAlgorithm

# create Hamiltonian
hamiltonian = SpinHamiltonianSystem(5)
hamiltonian.set("X0Y2", 0.5)
hamiltonian.set("Z1X3", 1.5)
hamiltonian.set("Z0", 1.0)
hamiltonian.set("X2", 1.0)

# create algorithm (here with second order trotterization)
alg = CNOTAlgorithm(number_trotter_steps=10).decomposition_blocks(True).order(2)
time = 3.0

# create circuit
circuit = alg.create_circuit(hamiltonian, time)

VariableMSXXAlgorithm

from struqture_py.spins import PauliProduct, SpinHamiltonianSystem
from py_alqorithms import VariableMSXXAlgorithm

# create Hamiltonian
hamiltonian = SpinHamiltonianSystem(5)
hamiltonian.set("X0Y2", 0.5)
hamiltonian.set("Z1X3", 1.5)
hamiltonian.set("Z0", 1.0)
hamiltonian.set("X2", 1.0)

# create algorithm
alg = VariableMSXXAlgorithm(number_trotter_steps=10).decomposition_blocks(True)
time = 3.0

# create circuit
circuit = alg.create_circuit(hamiltonian, time)

QSWAPAlgorithm

from struqture_py.spins import PauliProduct, SpinHamiltonianSystem
from py_alqorithms import QSWAPAlgorithm

# create Hamiltonian
hamiltonian = SpinHamiltonianSystem()
hamiltonian.set("X0Y3", 0.5)
hamiltonian.set("Z0X2", 1.5)
hamiltonian.set("Z0Y1", 1.0)
hamiltonian.set("X2", 1.0)
hamiltonian.set("Z1", 1.0)

# create algorithm
alg = QSWAPAlgorithm(number_trotter_steps=10).decomposition_blocks(True)
time = 3.0

# create circuit
circuit = alg.create_circuit(hamiltonian, time)