netket.operator.BoseHubbardJax#
- class netket.operator.BoseHubbardJax[source]#
Bases:
BoseHubbardBase
,DiscreteJaxOperator
- Inheritance
- __init__(hilbert, graph, U, V=0.0, J=1.0, mu=0.0, dtype=None)[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 strength 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
- J#
The hopping amplitude.
- T#
Returns the transposed operator
- U#
The strength of on-site interaction term.
- V#
The strength of density-density interaction term.
- dtype#
The dtype of the matrix elements.
- edges#
- hilbert#
The hilbert space associated to this observable.
- is_hermitian#
- max_conn_size#
The maximum number of non zero β¨x|O|xββ© for every x.
- mu#
The chemical potential.
- Methods
-
- collect()[source]#
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:
- 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)[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}}\).
- Parameters:
x (
ndarray
) β 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
- Raises:
ValueError β If the given quantum number is not compatible with the hilbert space.
- get_conn_flattened(x, sections)[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:
- Returns:
- The connected states xβ, flattened together in
a single matrix. An array containing the matrix elements \(O(x,x')\) associated to each xβ.
- Return type:
(matrix, array)
- get_conn_padded(x)[source]#
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)
- n_conn(x, out=None)[source]#
Return the number of (non-zero) connected entries to x.
Warning
This is not the True number of connected entries, because some elements might appear twice (however this should not be too common.)
Note that this deviates from the Numba implementation, and can generally return a smaller number of connected entries.
- 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()[source]#
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 jax Array.
- to_jax_operator()[source]#
Return the JAX version of this operator.
If this is a JAX operator does nothing.
- Return type:
- to_numba_operator()[source]#
Returns the standard (numba) version of this operator, which is an instance of {class}`nk.operator.BoseHubbard`.
- Return type:
- to_sparse()[source]#
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 jax matrix representation of the operator.