quimb.tensor.tensor_3d_tebd =========================== .. py:module:: quimb.tensor.tensor_3d_tebd .. autoapi-nested-parse:: Tools for performing TEBD like algorithms on a 3D lattice. Classes ------- .. autoapisummary:: quimb.tensor.tensor_3d_tebd.LocalHamGen quimb.tensor.tensor_3d_tebd.LocalHam3D Functions --------- .. autoapisummary:: quimb.tensor.tensor_3d_tebd.gen_3d_bonds Module Contents --------------- .. py:function:: gen_3d_bonds(Lx, Ly, Lz, steppers=None, coo_filter=None, cyclic=False) Convenience function for tiling pairs of bond coordinates on a 3D lattice given a function like ``lambda i, j, k: (i + 1, j + 1, k + 1)``. :param Lx: The number of x-slices. :type Lx: int :param Ly: The number of y-slices. :type Ly: int :param Lz: The number of z-slices. :type Lz: int :param steppers: Function(s) that take args ``(i, j, k)`` and generate another coordinate, thus defining a bond. Only valid steps are taken. If not given, defaults to nearest neighbor bonds. :type steppers: callable or sequence of callable :param coo_filter: Function that takes args ``(i, j, k)`` and only returns ``True`` if this is to be a valid starting coordinate. :type coo_filter: callable :Yields: **bond** (*tuple[tuple[int, int, int], tuple[int, int, int]]*) -- A pair of coordinates. .. rubric:: Examples Generate nearest neighbor bonds: >>> for bond in gen_3d_bonds(2, 2, 2, [lambda i, j, k: (i + 1, j, k), ... lambda i, j, k: (i, j + 1, k), ... lambda i, j, k: (i, j, k + 1)]): ... print(bond) ((0, 0, 0), (1, 0, 0)) ((0, 0, 0), (0, 1, 0)) ((0, 0, 0), (0, 0, 1)) ((0, 0, 1), (1, 0, 1)) ((0, 0, 1), (0, 1, 1)) ((0, 1, 0), (1, 1, 0)) ((0, 1, 0), (0, 1, 1)) ((0, 1, 1), (1, 1, 1)) ((1, 0, 0), (1, 1, 0)) ((1, 0, 0), (1, 0, 1)) ((1, 0, 1), (1, 1, 1)) ((1, 1, 0), (1, 1, 1)) .. py:class:: LocalHamGen(H2, H1=None) Representation of a local hamiltonian defined on a general graph. This combines all two site and one site terms into a single interaction per lattice pair, and caches operations on the terms such as getting their exponential. The sites (nodes) should be hashable and comparable. :param H2: The interaction terms, with each key being an tuple of nodes defining an edge and each value the local hamilotonian term for those two nodes. :type H2: dict[tuple[node], array_like] :param H1: The one site term(s). If a single array is given, assume to be the default onsite term for all terms. If a dict is supplied, the keys should represent specific coordinates like ``(i, j)`` with the values the array representing the local term for that site. A default term for all remaining sites can still be supplied with the key ``None``. :type H1: array_like or dict[node, array_like], optional .. attribute:: terms The total effective local term for each interaction (with single site terms appropriately absorbed). Each key is a pair of coordinates ``site_a, site_b`` with ``site_a < site_b``. :type: dict[tuple, array_like] .. py:property:: nsites The number of sites in the system. .. py:method:: items() Iterate over all terms in the hamiltonian. This is mostly for convenient compatibility with ``compute_local_expectation``. .. py:method:: _convert_from_qarray_cached(x) .. py:method:: _flip_cached(x) .. py:method:: _add_cached(x, y) .. py:method:: _div_cached(x, y) .. py:method:: _op_id_cached(x) .. py:method:: _id_op_cached(x) .. py:method:: _expm_cached(x, y) .. py:method:: get_gate(where) Get the local term for pair ``where``, cached. .. py:method:: get_gate_expm(where, x) Get the local term for pair ``where``, matrix exponentiated by ``x``, and cached. .. py:method:: apply_to_arrays(fn) Apply the function ``fn`` to all the arrays representing terms. .. py:method:: _nx_color_ordering(strategy='smallest_first', interchange=True) Generate a term ordering based on a coloring on the line graph. .. py:method:: get_auto_ordering(order='sort', **kwargs) Get an ordering of the terms to use with TEBD, for example. The default is to sort the coordinates then greedily group them into commuting sets. :param order: How to order the terms *before* greedily grouping them into commuting (non-coordinate overlapping) sets: - ``'sort'`` will sort the coordinate pairs first. - ``None`` will use the current order of terms which should match the order they were supplied to this ``LocalHam2D`` instance. - ``'random'`` will randomly shuffle the coordinate pairs before grouping them - *not* the same as returning a completely random order. - ``'random-ungrouped'`` will randomly shuffle the coordinate pairs but *not* group them at all with respect to commutation. Any other option will be passed as a strategy to ``networkx.coloring.greedy_color`` to generate the ordering. :type order: {'sort', None, 'random', str} :returns: Sequence of coordinate pairs. :rtype: list[tuple[node]] .. py:method:: __repr__() Return repr(self). .. py:method:: draw(ordering='sort', show_norm=True, figsize=None, fontsize=8, legend=True, ax=None, **kwargs) Plot this Hamiltonian as a network. :param ordering: An ordering of the termns, or an argument to be supplied to :meth:`quimb.tensor.tensor_arbgeom_tebd.LocalHamGen.get_auto_ordering` to generate this automatically. :type ordering: {'sort', None, 'random'}, optional :param show_norm: Show the norm of each term as edge labels. :type show_norm: bool, optional :param figsize: Size of the figure, defaults to size of Hamiltonian. :type figsize: None or tuple[int], optional :param fontsize: Font size for norm labels. :type fontsize: int, optional :param legend: Whether to show the legend of which terms are in which group. :type legend: bool, optional :param ax: Add to a existing set of axes. :type ax: None or matplotlib.Axes, optional .. py:attribute:: graph .. py:class:: LocalHam3D(Lx, Ly, Lz, H2, H1=None, cyclic=False) Bases: :py:obj:`quimb.tensor.tensor_arbgeom_tebd.LocalHamGen` Representation of a local hamiltonian defined on a general graph. This combines all two site and one site terms into a single interaction per lattice pair, and caches operations on the terms such as getting their exponential. The sites (nodes) should be hashable and comparable. :param H2: The interaction terms, with each key being an tuple of nodes defining an edge and each value the local hamilotonian term for those two nodes. :type H2: dict[tuple[node], array_like] :param H1: The one site term(s). If a single array is given, assume to be the default onsite term for all terms. If a dict is supplied, the keys should represent specific coordinates like ``(i, j)`` with the values the array representing the local term for that site. A default term for all remaining sites can still be supplied with the key ``None``. :type H1: array_like or dict[node, array_like], optional .. attribute:: terms The total effective local term for each interaction (with single site terms appropriately absorbed). Each key is a pair of coordinates ``site_a, site_b`` with ``site_a < site_b``. :type: dict[tuple, array_like] .. py:property:: nsites The number of sites in the system. .. py:method:: __repr__() Return repr(self).