netket.hilbert.CustomHilbert

class netket.hilbert.CustomHilbert

A custom hilbert space.

__init__(self: netket._C_netket.hilbert.CustomHilbert, graph: netket._C_netket.graph.Graph, local_states: List[float]) → None

Constructs a new CustomHilbert given a graph and a list of eigenvalues of the states.

Parameters
  • graph – Graph representation of sites.

  • local_states – Eigenvalues of the states.

Examples

Simple custom hilbert space.

>>> from netket.graph import Hypercube
>>> from netket.hilbert import CustomHilbert
>>> g = Hypercube(length=10,n_dim=2,pbc=True)
>>> hi = CustomHilbert(graph=g, local_states=[-1232, 132, 0])
>>> print(hi.size)
100

Methods

__init__(self, graph, local_states)

Constructs a new CustomHilbert given a graph and a list of eigenvalues of the states.

number_to_state(*args, **kwargs)

Overloaded function.

random_vals(self, state, 1], …)

Member function generating uniformely distributed local random states.

state_to_number(self, conf, 1]])

Returns index of the given many-body configuration.

states(self)

Returns an iterator over all valid configurations of the Hilbert space.

update_conf(self, v, 1], flags.writeable], …)

Member function updating a visible configuration using the information on where the local changes have been done.

Attributes

graph

The Graph used to construct this Hilbert space.

is_discrete

Whether the hilbert space is discrete.

is_indexable

We call a Hilbert space indexable if and only if the total Hilbert space dimension can be represented by an index of type int.

local_size

Size of the local hilbert space.

local_states

List of discreet local quantum numbers.

n_states

The total dimension of the many-body Hilbert space.

size

The number of visible units needed to describe the system.

property graph

The Graph used to construct this Hilbert space.

Type

netket.graph.Graph

property is_discrete

Whether the hilbert space is discrete.

Type

bool

property is_indexable

We call a Hilbert space indexable if and only if the total Hilbert space dimension can be represented by an index of type int.

Returns

Whether the Hilbert space is indexable.

Return type

bool

property local_size

Size of the local hilbert space.

Type

int

property local_states

List of discreet local quantum numbers.

Type

list[float]

property n_states

The total dimension of the many-body Hilbert space. Throws an exception iff the space is not indexable.

Type

int

number_to_state(*args, **kwargs)

Overloaded function.

  1. number_to_state(self: netket._C_netket.hilbert.Hilbert, i: int) -> numpy.ndarray[float64[m, 1]]

    Returns the visible configuration corresponding to the i-th basis state for input i. i can be a single integer or an array. Throws an exception iff the space is not indexable.

  2. number_to_state(self: netket._C_netket.hilbert.Hilbert, i: List[int]) -> numpy.ndarray[float64[m, n]]

    Returns the visible configuration corresponding to the i-th basis state for input i. i can be a single integer or an array. Throws an exception iff the space is not indexable.

random_vals(self: netket._C_netket.hilbert.Hilbert, state: numpy.ndarray[float64[m, 1], flags.writeable], rgen: std::__1::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u> = None) → None

Member function generating uniformely distributed local random states.

Parameters
  • state – A reference to a visible configuration, in output this contains the random state.

  • rgen – The random number generator. If None, the global NetKet random number generator is used.

Examples

Test that a new random state is a possible state for the hilbert space.

>>> import netket as nk
>>> import numpy as np
>>> hi = nk.hilbert.Boson(n_max=3, graph=nk.graph.Hypercube(length=5, n_dim=1))
>>> rstate = np.zeros(hi.size)
>>> rg = nk.utils.RandomEngine(seed=1234)
>>> hi.random_vals(rstate, rg)
>>> local_states = hi.local_states
>>> print(rstate[0] in local_states)
True
property size

The number of visible units needed to describe the system.

Type

int

state_to_number(self: netket._C_netket.hilbert.Hilbert, conf: numpy.ndarray[float64[m, 1]]) → int
Returns index of the given many-body configuration.

Throws an exception iff the space is not indexable.

states(self: netket._C_netket.hilbert.Hilbert) → netket::StateGenerator
Returns an iterator over all valid configurations of the Hilbert space.

Throws an exception iff the space is not indexable.

update_conf(self: netket._C_netket.hilbert.Hilbert, v: numpy.ndarray[float64[m, 1], flags.writeable], to_change: numpy.ndarray[int32], new_conf: numpy.ndarray[float64]) → None

Member function updating a visible configuration using the information on where the local changes have been done.

Parameters
  • v – The vector of visible units to be modified.

  • to_change – A list of which quantum numbers will be modified.

  • new_conf – Contains the value that those quantum numbers should take.