netket.graph.Grid

class netket.graph.Grid(length, *, pbc=True, color_edges=False)[source]

Bases: netket.graph.graph.NetworkX

A Grid lattice of d dimensions, and possibly different sizes of each dimension. Periodic boundary conditions can also be imposed

__init__(length, *, pbc=True, color_edges=False)[source]

Constructs a new Grid given its length vector.

Parameters
  • length (List) – Side length of the Grid. It must be a list with integer components >= 1.

  • pbc (bool) – If True, the grid will have periodic boundary conditions (PBC); if False, the grid will have open boundary conditions (OBC). This parameter can also be a list of booleans with same length as the parameter length, in which case each dimension will have PBC/OBC depending on the corresponding entry of pbc.

  • color_edges (bool) – If True, the edges will be colored by their grid direction.

Examples

A 5x10 lattice with periodic boundary conditions can be constructed as follows:

>>> import netket
>>> g=netket.graph.Grid(length=[5, 10], pbc=True)
>>> print(g.n_nodes)
50

Also, a 2x2x3 lattice with open boundary conditions can be constructed as follows:

>>> g=netket.graph.Grid(length=[2,2,3], pbc=False)
>>> print(g.n_nodes)
12
Attributes
n_edges

The number of edges in the graph.

Return type

int

n_nodes

The number of nodes (or vertices) in the graph

Return type

int

Methods
adjacency_list()

List containing the adjacency list of the graph where each node is represented by an integer in [0, n_nodes)

Return type

List[List]

automorphisms()

Symmetry group containing the automorphisms of the graph

Return type

SymmGroup

axis_reflection(axis=0)[source]

Returns SymmGroup consisting of identity and the lattice reflected about the hyperplane axis = 0

Parameters

axis (int) – Axis to be reflected about

Return type

SymmGroup

distances()

List containing the distances between the nodes. The fact that some node may not be reachable from another is represented by -1

Return type

List[List]

edges(color=False)

Iterator over the edges of the graph

Return type

Generator

Parameters

color (Union[bool, int]) –

is_bipartite()

True if the graph is bipartite

Return type

bool

is_connected()

True if the graph is connected

Return type

bool

lattice_group()[source]

Returns the full lattice symmetry group consisting of rotations, reflections, and periodic translation.

The lattice group is a subset of the permutations returned by self.automorphisms().

Return type

SymmGroup

nodes()

Iterator over the nodes of the graph

Return type

Generator

planar_rotation(axes=(0, 1))[source]

Returns SymmGroup consisting of rotations about the origin in the plane defined by axes

Parameters

axes (tuple) – Axes that define the plane of rotation specified by dims.

Return type

SymmGroup

rotations(*, remove_duplicates=True)[source]

Returns all possible rotation symmetries of the lattice.

The rotations are a subset of the permutations returned by self.automorphisms().

Parameters
  • period – Period of the rotations; should be a divisor of 4.

  • remove_duplicates (bool) – Only include unique rotations.

Return type

SymmGroup

space_group()[source]

Returns the full space group of the lattice.

The space group is a subset of the permutations returned by self.automorphisms().

Parameters

remove_duplicates – Only include unique space group elements.

Return type

SymmGroup

translations(dim=None, step=1)[source]

Returns all permutations of lattice sites that correspond to translations along the grid directions with periodic boundary conditions.

The periodic translations are a subset of the permutations returned by self.automorphisms().

Parameters
  • dim (Union[int, Sequence[int], None]) – If set, only translations along dim will be returned. Can be a either a single dimension or a sequence of dimensions.

  • step (int) – Return translations by multiples of step sites (default: 1); should be a divisor of the length in the corresponding lattice dimension.

Return type

SymmGroup