# netket.operator.BoseHubbard¶

class netket.operator.BoseHubbard(hilbert, graph, U, V=0.0, J=1.0, mu=0.0, dtype=<class 'float'>)[source]

Bases: netket.operator._hamiltonian.SpecialHamiltonian

An extended Bose Hubbard model Hamiltonian operator, containing both on-site interactions and nearest-neighboring density-density interactions.

__init__(hilbert, graph, U, V=0.0, J=1.0, mu=0.0, dtype=<class 'float'>)[source]

Constructs a new BoseHubbard operator given a hilbert space, a graph specifying the connectivity and the interaction strength. The chemical potential and the density-density interaction strenght can be specified as well.

Parameters

Examples

Constructs a BoseHubbard operator for a 2D system.

>>> import netket as nk
>>> g = nk.graph.Hypercube(length=3, n_dim=2, pbc=True)
>>> hi = nk.hilbert.Fock(n_max=3, n_particles=6, N=g.n_nodes)
>>> op = nk.operator.BoseHubbard(hi, U=4.0, graph=g)
>>> print(op.hilbert.size)
9

Attributes
H

Returns the Conjugate-Transposed operator

Return type

AbstractOperator

J

The hopping amplitude.

T

Returns the transposed operator

Return type

AbstractOperator

U

The strength of on-site interaction term.

V

The strength of density-density interaction term.

dtype
edges
Return type

ndarray

hilbert

The hilbert space associated to this operator.

Return type

AbstractHilbert

is_hermitian
max_conn_size

The maximum number of non zero ⟨x|O|x’⟩ for every x.

Return type

int

mu

The chemical potential.

size

The total number number of local degrees of freedom.

Return type

int

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=True)

Returns the complex-conjugate of this operator.

Parameters

concrete (bool) – 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

copy()[source]
get_conn(x)[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 (array) – An array of shape (hilbert.size) containing the quantum numbers x.

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

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.

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.

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. mels: A N-tensor containing the matrix elements $$O(x,x')$$

associated to each x’ for every batch.

Return type

x_primes

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_local_operator()[source]
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)

Returns the transpose of this operator.

Parameters

concrete – if True returns a concrete operator and not a lazy wrapper

Return type

AbstractOperator

Returns

if concrete is not True, self or a lazy wrapper; the transposed operator otherwise