The Raqet User Interface

Raqet's user interface is based on the FactorMethod class, which can be imported and instantiated as follows

from raqet_py.factor import FactorMethod

my_method = FactorMethod()

Once we have a FactorMethod instance, we will be adding to it all the information necessary for running the simulation, and finally calling the compute_EOMs() method to obtain the equations of motion, appropriately factorized. The main information we need to add to the FactorMethod are

  • The Hamiltonian (as a struqture_py.spins.SpinHamiltonianSystem) for the unitary time evolution;
  • The Lindblad-type noise (as a struqture_py.spins.SpinLindbladNoiseSystem) for the non-unitary time evolution;
  • The "connectivity" set used for deciding which operators are "too large"

More specifically, the connectivity set is the set of all pairs of sites whose distance is less than the cutoff length scale. This implies that it is the responsibility of the user to determine a distance function and a cutoff length scale, and then provide Raqet with a list of all pairs of sites whose distance is below this scale. It is important not to confuse this connectivity set with the list of all sites that are directly coupled (or "connected") through the Hamiltonian - two sites will appear in the connectivity set so long as their mutual distance is less than the chosen cutoff, regardless of whether they are directly coupled through the Hamiltonian.

Moreover, the operators whose time evolution we want to compute can be set with the method set_operator_heap. If these are not specified, Raqet will default to looking at the \( 3N \) single-site operators \( \langle \sigma^x \rangle \), \( \langle \sigma^y \rangle \), \( \langle \sigma^z \rangle \). Adding information to the FactorMethod instance is done as follows:

import numpy as np
from struqture_py.spins import SpinHamiltonianSystem, SpinLindbladNoiseSystem

number_spins = 5

# Define the Hamiltonian
hamiltonian = spins.SpinHamiltonianSystem(number_spins)
hamiltonian.set("0X1X", 1.0)
hamiltonian.set("0X", 1.0)
hamiltonian.set("1X3X", 1.0)
hamiltonian.set("2Y4X", 1.0)

# Define noise term
noise = SpinLindbladNoiseSystem(number_spins)

for q in range(number_spins):
    this_op = str(q) + "X"
    noise.add_operator_product((this_op, this_op), 1.0)

# Add connectivity information, as a set of pairs
connectivity = set()

# Assume distance and cutoff such that only 1D neighbors are "close"
for i in range(number_spins-1):
    connectivity.add((i, i+ 1))

# Set the Hamiltonian:
my_method.set_hamiltonian(hamiltonian)

# Set the noise:
my_method.set_noise(noise)

# Set the connectivity information
my_method.set_connectivity(connectivity)

With our FactorMethod instance all set, we can compute the factorized equations of motion, and print both the linear and nonlinear (i.e. factorized) parts

my_method.compute_EOMs()

print(my_method.linear_EOM())
print(my_method.nonlinear_EOM())

The nonlinear part of the equations of motion is represented as a dictionary whose keys represent terms like \( \langle \sigma^x_1 \rangle \langle \sigma^z_2 \sigma^y_3 \rangle \) as lists of PauliProduct, and whose values are the corresponding complex coefficients.