quimb.tensor.geometry ===================== .. py:module:: quimb.tensor.geometry .. autoapi-nested-parse:: Some functions for generating the edges of a lattice. Functions --------- .. autoapisummary:: quimb.tensor.geometry.sort_unique quimb.tensor.geometry.edges_1d_chain quimb.tensor.geometry.check_2d quimb.tensor.geometry.edges_2d_square quimb.tensor.geometry.edges_2d_hexagonal quimb.tensor.geometry.edges_2d_triangular quimb.tensor.geometry.edges_2d_triangular_rectangular quimb.tensor.geometry.edges_2d_kagome quimb.tensor.geometry.check_3d quimb.tensor.geometry.edges_3d_cubic quimb.tensor.geometry.edges_3d_pyrochlore quimb.tensor.geometry.edges_3d_diamond quimb.tensor.geometry.edges_3d_diamond_cubic quimb.tensor.geometry.edges_tree_rand Module Contents --------------- .. py:function:: sort_unique(edges) Make sure there are no duplicate edges and that for each ``coo_a < coo_b``. .. py:function:: edges_1d_chain(L, cyclic=False) Return the graph edges of a finite 1D chain lattice. :param L: The number of cells. :type L: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :returns: **edges** :rtype: list[(int, int)] .. py:function:: check_2d(coo, Lx, Ly, cyclic) Check ``coo`` in inbounds for a maybe cyclic 2D lattice. .. py:function:: edges_2d_square(Lx, Ly, cyclic=False, cells=None) Return the graph edges of a finite 2D square lattice. The nodes (sites) are labelled like ``(i, j)``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int), (int, int))] .. py:function:: edges_2d_hexagonal(Lx, Ly, cyclic=False, cells=None) Return the graph edges of a finite 2D hexagonal lattice. There are two sites per cell, and note the cells do not form a square tiling. The nodes (sites) are labelled like ``(i, j, s)`` for ``s`` in ``'AB'``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int, str), (int, int, str))] .. py:function:: edges_2d_triangular(Lx, Ly, cyclic=False, cells=None) Return the graph edges of a finite 2D triangular lattice. There is a single site per cell, and note the cells do not form a square tiling. The nodes (sites) are labelled like ``(i, j)``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int), (int, int))] .. py:function:: edges_2d_triangular_rectangular(Lx, Ly, cyclic=False, cells=None) Return the graph edges of a finite 2D triangular lattice tiled in a rectangular geometry. There are two sites per rectangular cell. The nodes (sites) are labelled like ``(i, j, s)`` for ``s`` in ``'AB'``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int, s), (int, int, s))] .. py:function:: edges_2d_kagome(Lx, Ly, cyclic=False, cells=None) Return the graph edges of a finite 2D kagome lattice. There are three sites per cell, and note the cells do not form a square tiling. The nodes (sites) are labelled like ``(i, j, s)`` for ``s`` in ``'ABC'``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int, str), (int, int, str))] .. py:function:: check_3d(coo, Lx, Ly, Lz, cyclic) Check ``coo`` in inbounds for a maybe cyclic 3D lattice. .. py:function:: edges_3d_cubic(Lx, Ly, Lz, cyclic=False, cells=None) Return the graph edges of a finite 3D cubic lattice. The nodes (sites) are labelled like ``(i, j, k)``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param Lz: The number of cells along the z-direction. :type Lz: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly), range(Lz))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int, int), (int, int, int))] .. py:function:: edges_3d_pyrochlore(Lx, Ly, Lz, cyclic=False, cells=None) Return the graph edges of a finite 3D pyorchlore lattice. There are four sites per cell, and note the cells do not form a cubic tiling. The nodes (sites) are labelled like ``(i, j, k, s)`` for ``s`` in ``'ABCD'``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param Lz: The number of cells along the z-direction. :type Lz: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly), range(Lz))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int, int, str), (int, int, int, str))] .. py:function:: edges_3d_diamond(Lx, Ly, Lz, cyclic=False, cells=None) Return the graph edges of a finite 3D diamond lattice. There are two sites per cell, and note the cells do not form a cubic tiling. The nodes (sites) are labelled like ``(i, j, k, s)`` for ``s`` in ``'AB'``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param Lz: The number of cells along the z-direction. :type Lz: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly), range(Lz))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int, int, str), (int, int, int, str))] .. py:function:: edges_3d_diamond_cubic(Lx, Ly, Lz, cyclic=False, cells=None) Return the graph edges of a finite 3D diamond lattice tiled in a cubic geometry. There are eight sites per cubic cell. The nodes (sites) are labelled like ``(i, j, k, s)`` for ``s`` in ``'ABCDEFGH'``. :param Lx: The number of cells along the x-direction. :type Lx: int :param Ly: The number of cells along the y-direction. :type Ly: int :param Lz: The number of cells along the z-direction. :type Lz: int :param cyclic: Whether to use periodic boundary conditions. :type cyclic: bool, optional :param cells: A list of cells to use. If not given the cells used are ``itertools.product(range(Lx), range(Ly), range(Lz))``. :type cells: list, optional :returns: **edges** :rtype: list[((int, int, int, str), (int, int, int, str))] .. py:function:: edges_tree_rand(n, max_degree=None, seed=None) Return a random tree with ``n`` nodes. This a convenience function for testing purposes and the trees generated are not guaranteed to be uniformly random (for that see ``networkx.random_labeled_tree``). :param n: The number of nodes. :type n: int :param max_degree: The maximum degree of the nodes. For example ``max_degree=3`` means generate a binary tree. :type max_degree: int, optional :param seed: The random seed. :type seed: int, optional :returns: **edges** :rtype: list[(int, int)]