Examples

CNOTAlgorithm

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

# create Hamiltonian
hamiltonian = PauliHamiltonian()
hamiltonian.set("0X2Y", 0.5)
hamiltonian.set("1Z3X", 1.5)
hamiltonian.set("0Z", 1.0)
hamiltonian.set("2X", 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, PauliHamiltonian
from py_alqorithms import VariableMSXXAlgorithm

# create Hamiltonian
hamiltonian = PauliHamiltonian()
hamiltonian.set("0X2Y", 0.5)
hamiltonian.set("1Z3X", 1.5)
hamiltonian.set("0Z", 1.0)
hamiltonian.set("2X", 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, PauliHamiltonian
from py_alqorithms import QSWAPAlgorithm

# create Hamiltonian
hamiltonian = PauliHamiltonian()
hamiltonian.set("0X3Y", 0.5)
hamiltonian.set("0Z2X", 1.5)
hamiltonian.set("0Z1Y", 1.0)
hamiltonian.set("2X", 1.0)
hamiltonian.set("1Z", 1.0)

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

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