netket.operator.Ising
netket.operator.Ising#
- class netket.operator.Ising#
Bases:
netket.operator._hamiltonian.SpecialHamiltonian
The Transverse-Field Ising Hamiltonian \(-h\sum_i \sigma_i^{(x)} +J\sum_{\langle i,j\rangle} \sigma_i^{(z)}\sigma_j^{(z)}\).
This implementation is considerably faster than the Ising hamiltonian constructed by summing
LocalOperator
s.- Inheritance
- __init__(hilbert, graph, h, J=1.0, dtype=None)[source]#
Constructs the Ising Operator from an hilbert space and a graph specifying the connectivity.
- Parameters
hilbert (
AbstractHilbert
) β Hilbert space the operator acts on.h (
float
) β The strength of the transverse field.J (
float
) β The strength of the coupling. Default is 1.0.graph (netket.graph.AbstractGraph) β
Examples
Constructs an
Ising
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, N=g.n_nodes) >>> op = nk.operator.Ising(h=1.321, hilbert=hi, J=0.5, graph=g) >>> print(op) Ising(J=0.5, h=1.321; dim=20)
- Attributes
- H#
Returns the Conjugate-Transposed operator
- Return type
- T#
Returns the transposed operator
- Return type
- hilbert#
The hilbert space associated to this operator.
- Return type
- Methods
- __call__(v)#
Call self as a function.
- Return type
- Parameters
v (numpy.ndarray) β
- apply(v)#
- Return type
- Parameters
v (numpy.ndarray) β
- collect()#
Returns a guaranteed concrete instance of an operator.
As some operations on operators return lazy wrappers (such as transpose, hermitian conjugateβ¦), this is used to obtain a guaranteed non-lazy operator.
- Return type
- conj(*, concrete=False)#
- Return type
- conjugate(*, concrete=True)[source]#
Returns the complex-conjugate of this operator.
- Parameters
concrete β if True returns a concrete operator and not a lazy wrapper
- Returns
if concrete is not True, self or a lazy wrapper; the complex-conjugated operator otherwise
- 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_flattened(x, sections, pad=False)[source]#
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
) β no effect here
- 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 \times 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 \times K_{max} \times M\) where \(K_{max}\) is the maximum number of connections for every \(y_i\).
- Parameters
x (
ndarray
) β 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 and an N-tensor containing the matrix elements \(O(x,x')\) associated to each xβ for every batch.
- Return type
(x_primes, mels)
- static n_conn(x, out)[source]#
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
- 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.
- Returns
A
qutip.Qobj
object.
- 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
- Returns
The sparse matrix representation of the operator.
- transpose(*, concrete=False)#
Returns the transpose of this operator.
- Parameters
concrete β if True returns a concrete operator and not a lazy wrapper
- Return type
- Returns
if concrete is not True, self or a lazy wrapper; the transposed operator otherwise