Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quantum Solver Concepts

In this chapter we discuss the elementary concepts needed to use HQS Quantum Solver.

Since quantum mechanical systems are described by linear operators, the first step in learning how to use Quantum Solver is how to construct and use operators. In Quantum Solver you define operators by specifying a vector space and an expression. The latter describes the mathematical terms that the operator is made of.

The examples in this chapter make use of the following imports.

from hqs_quantum_solver.spins import Operator, VectorSpace, spin_z, raising

Vector Spaces

All particle related modules, e.g., the spins, spinless_fermions, or bosons module, contain a VectorSpace class. Instantiating such a class is the first step in constructing an operator in Quantum Solver. In quantum mechanics, the states a system can be in determine the vector space that the operator describing the system is defined on. Therefore, VectorSpace objects are constructed by providing parameters that describe these states, e.g., the VectorSpace class from the spins module is constructed by providing the sites and the total_spin_z arguments. The first argument defines the number of spins in the system, while the second argument can be used to restrict to a sets of states with a fixed total spin polarization.

We could, e.g., create a vector space object for a spin system with four spins and the total spin polarization being restricted to zero by the following code, where the total_spin_z spin quantum number is provided in units of .

VectorSpace(sites=4, total_spin_z=0)

A vector space object for a spin system with four spins and no restrictions on the total spin polarization could be constructed as follows.

VectorSpace(sites=4, total_spin_z="all")

Operator Expressions

The mathematical term that describes the operator is defined by an operator expression. The particle related modules, like the spins module, contain functions that return expression. Examples are the raising, magnetic_field_z, and isotropic_interaction functions. Expressions can be combined into arbitrary complex linear combinations, e.g.,

3 * spin_z(site=1) + 2 * spin_z(site=3)

corresponds to the term .

Many of these functions (also) take a coefficient array or vector as an input, e.g., the expression above could also be written as follows.

spin_z(coef=[0, 3, 0, 2])

Operators

To construct an operator, you need to create an instance of the desired operator class, which requires the operator expression and the vector space. We can construct the operator given by on a space where the total spin polarization is fixed to zero as follows.

v = VectorSpace(sites=4, total_spin_z=0)
H = Operator(3 * spin_z(site=1) + 2 * spin_z(site=3), domain=v)

Note that when the codomain attribute is not specified it is assumed that the domain of the operator is equal to the codomain. In cases, where the two spaces differ, the codomain attribute must be explicitly given. This is the case, e.g., when applying the spin raising operator on a space with a fixed total spin polarization, as is done in the code below.

v = VectorSpace(sites=4, total_spin_z=0)
w = v.copy(total_spin_z_change=2)
A = Operator(raising(site=2), domain=v, codomain=w)

Once an operator object is constructed, it can be used by applying methods like the dot or similar methods. Furthremore, Quantum Solver operators are compatible to most SciPy sparse routines and therefore can directly be used in functions like eigsh.