# netket.operator.HeisenbergÂ¶

class netket.operator.Heisenberg(hilbert, graph, J=1.0, sign_rule=None, *, acting_on_subspace=None)Â¶

The Heisenberg hamiltonian on a lattice.

Inheritance
__init__(hilbert, graph, J=1.0, sign_rule=None, *, acting_on_subspace=None)[source]Â¶

Constructs an Heisenberg operator given a hilbert space and a graph providing the connectivity of the lattice.

Parameters
• hilbert (AbstractHilbert) â€“ Hilbert space the operator acts on.

• graph (AbstractGraph) â€“ The graph upon which this hamiltonian is defined.

• J (Union[float, Sequence[float]]) â€“ The strength of the coupling. Default is 1. Can pass a sequence of coupling strengths with coloured graphs: edges of colour n will have coupling strength J[n]

• sign_rule â€“ If True, Marshalâ€™s sign rule will be used. On a bipartite lattice, this corresponds to a basis change flipping the Sz direction at every odd site of the lattice. For non-bipartite lattices, the sign rule cannot be applied. Defaults to True if the lattice is bipartite, False otherwise. If a sequence of coupling strengths is passed, defaults to False and a matching sequence of sign_rule must be specified to override it

• acting_on_subspace (Union[List[int], int, None]) â€“ Specifies the mapping between nodes of the graph and Hilbert space sites, so that graph node i âˆˆ [0, ..., graph.n_nodes - 1], corresponds to acting_on_subspace[i] âˆˆ [0, ..., hilbert.n_sites]. Must be a list of length graph.n_nodes. Passing a single integer start is equivalent to [start, ..., start + graph.n_nodes - 1].

Examples

Constructs a Heisenberg operator for a 1D system.

>>> import netket as nk
>>> g = nk.graph.Hypercube(length=20, n_dim=1, pbc=True)
>>> hi = nk.hilbert.Spin(s=0.5, total_sz=0, N=g.n_nodes)
>>> op = nk.operator.Heisenberg(hilbert=hi, graph=g)
>>> print(op)
Heisenberg(J=1.0, sign_rule=True; dim=20)

Attributes
HÂ¶

Returns the Conjugate-Transposed operator

Return type

AbstractOperator

JÂ¶

The coupling strength.

Return type

float

TÂ¶

Returns the transposed operator

Return type

AbstractOperator

acting_onÂ¶

List containing the list of the sites on which every operator acts.

Every operator self.operators[i] acts on the sites self.acting_on[i]

Return type
acting_on_subspaceÂ¶

Mapping between nodes of the graph and Hilbert space sites as given in the constructor.

constantÂ¶
Return type

Number

dtypeÂ¶
Return type

Any

graphÂ¶

The graph on which this Operator is defined

Return type

AbstractGraph

hilbertÂ¶

The hilbert space associated to this operator.

Return type

AbstractHilbert

is_hermitianÂ¶

Returns true if this operator is hermitian.

Return type

bool

max_conn_sizeÂ¶

The maximum number of non zero âŸ¨x|O|xâ€™âŸ© for every x.

Return type

int

mel_cutoffÂ¶

The cutoff for matrix elements. Only matrix elements such that abs(O(i,i))>mel_cutoff are considered

Type

float

Return type

float

n_operatorsÂ¶
Return type

int

operatorsÂ¶

List of the matrices of the operators encoded in this Local Operator. Returns a copy.

Return type
sizeÂ¶
Return type

int

uses_sign_ruleÂ¶
Methods
__call__(v)Â¶

Call self as a function.

Return type

ndarray

Parameters

v (numpy.ndarray) â€“

apply(v)Â¶
Return type

ndarray

Parameters

v (numpy.ndarray) â€“

collect()Â¶

Returns a guranteed concrete instancce of an operator.

As some operations on operators return lazy wrapperes (such as transpose, hermitian conjugateâ€¦), this is used to obtain a guaranteed non-lazy operator.

Return type

AbstractOperator

conj(*, concrete=False)Â¶
Return type

AbstractOperator

conjugate(*, concrete=False)Â¶

LocalOperator: Returns the complex conjugate of this operator.

copy(*, dtype=None)Â¶

Returns a copy of the operator, while optionally changing the dtype of the operator.

Parameters

dtype â€“ optional dtype

get_conn(x)Â¶

Finds the connected elements of the Operator. Starting from a given quantum number x, it finds all other quantum numbers xâ€™ such that the matrix element $$O(x,x')$$ is different from zero. In general there will be several different connected states xâ€™ satisfying this condition, and they are denoted here $$x'(k)$$, for $$k=0,1...N_{\mathrm{connected}}$$. :type x: ndarray :param x: An array of shape (hilbert.size) containing the quantum numbers x. :type x: array

Returns

The connected states xâ€™ of shape (N_connected,hilbert.size) array: An array containing the matrix elements $$O(x,x')$$ associated to each xâ€™.

Return type

matrix

Raises

ValueError â€“ If the given quantum number is not compatible with the hilbert space.

Parameters

x (numpy.ndarray) â€“

get_conn_filtered(x, sections, filters)Â¶

Finds the connected elements of the Operator using only a subset of operators. Starting from a given quantum number x, it finds all other quantum numbers xâ€™ such that the matrix element $$O(x,x')$$ is different from zero. In general there will be several different connected states xâ€™ satisfying this condition, and they are denoted here $$x'(k)$$, for $$k=0,1...N_{\mathrm{connected}}$$.

This is a batched version, where x is a matrix of shape (batch_size,hilbert.size).

Parameters
• x (matrix) â€“ A matrix of shape (batch_size,hilbert.size) containing the batch of quantum numbers x.

• sections (array) â€“ An array of size (batch_size) useful to unflatten the output of this function. See numpy.split for the meaning of sections.

• filters (array) â€“ Only operators op(filters[i]) are used to find the connected elements of x[i].

Returns

The connected states xâ€™, flattened together in a single matrix. array: An array containing the matrix elements $$O(x,x')$$ associated to each xâ€™.

Return type

matrix

get_conn_flattened(x, sections, pad=False)Â¶

Finds the connected elements of the Operator. Starting from a given quantum number x, it finds all other quantum numbers xâ€™ such that the matrix element $$O(x,x')$$ is different from zero. In general there will be several different connected states xâ€™ satisfying this condition, and they are denoted here $$x'(k)$$, for $$k=0,1...N_{\mathrm{connected}}$$.

This is a batched version, where x is a matrix of shape (batch_size,hilbert.size).

Parameters
• x (matrix) â€“ A matrix of shape (batch_size,hilbert.size) containing the batch of quantum numbers x.

• sections (array) â€“ An array of size (batch_size) useful to unflatten the output of this function. See numpy.split for the meaning of sections.

• pad (bool) â€“ Whether to use zero-valued matrix elements in order to return all equal sections.

Returns

The connected states xâ€™, flattened together in a single matrix. array: An array containing the matrix elements $$O(x,x')$$ associated to each xâ€™.

Return type

matrix

get_conn_padded(x)Â¶

Finds the connected elements of the Operator. Starting from a batch of quantum numbers x={x_1, â€¦ x_n} of size B x M where B size of the batch and M size of the hilbert space, finds all states y_i^1, â€¦, y_i^K connected to every x_i. Returns a matrix of size B x Kmax x M where Kmax is the maximum number of connections for every y_i. :type x: ndarray :param x: A N-tensor of shape (â€¦,hilbert.size) containing

the batch/batches of quantum numbers x.

Returns

The connected states xâ€™, in a N+1-tensor. mels: A N-tensor containing the matrix elements $$O(x,x')$$

associated to each xâ€™ for every batch.

Return type

x_primes

Parameters

x (numpy.ndarray) â€“

n_conn(x, out=None)Â¶

Return the number of states connected to x.

Parameters
• x (matrix) â€“ A matrix of shape (batch_size,hilbert.size) containing the batch of quantum numbers x.

• out (array) â€“ If None an output array is allocated.

Returns

The number of connected states xâ€™ for each x[i].

Return type

array

to_dense()Â¶

Returns the dense matrix representation of the operator. Note that, in general, the size of the matrix is exponential in the number of quantum numbers, and this operation should thus only be performed for low-dimensional Hilbert spaces or sufficiently sparse operators.

This method requires an indexable Hilbert space.

Return type

ndarray

Returns

The dense matrix representation of the operator as a Numpy array.

to_linear_operator()Â¶
to_qobj()Â¶

Convert the operator to a qutipâ€™s Qobj. :rtype: qutip.Qobj :returns: A qutip.Qobj object.

Return type

qutip.Qobj

to_sparse()Â¶

Returns the sparse matrix representation of the operator. Note that, in general, the size of the matrix is exponential in the number of quantum numbers, and this operation should thus only be performed for low-dimensional Hilbert spaces or sufficiently sparse operators.

This method requires an indexable Hilbert space.

Return type

csr_matrix

Returns

The sparse matrix representation of the operator.

transpose(*, concrete=False)Â¶

LocalOperator: Returns the tranpose of this operator.