symmray.networks ================ .. py:module:: symmray.networks .. autoapi-nested-parse:: Functions to create full tensor networks backed by `symmray`. Attributes ---------- .. autoapisummary:: symmray.networks._DEFAULT_PHYS_CHARGEMAPS Functions --------- .. autoapisummary:: symmray.networks.parse_edges_to_site_info symmray.networks.TN_abelian_from_edges_rand symmray.networks.TN_fermionic_from_edges_rand symmray.networks.MPS_abelian_rand symmray.networks.PEPS_abelian_rand symmray.networks.PEPS3D_abelian_rand symmray.networks.MPS_fermionic_rand symmray.networks.PEPS_fermionic_rand symmray.networks.PEPS3D_fermionic_rand Module Contents --------------- .. py:function:: parse_edges_to_site_info(edges, bond_dim, phys_dim=2, site_ind_id='k{}', bond_ind_id='b{}-{}', site_tag_id='I{}') Given a list of edges, return a dictionary of site information, each specifying the local shape, index identifiers, index dualnesses, and tags. The dualnesses of the bonds are set in a canonical order corresponding to sorting all the sites and the edges. :param edges: The edges of the graph. :type edges: Sequence[Tuple[hashable, hashable]] :param bond_dim: The internal bond dimension. :type bond_dim: int :param phys_dim: The physical dimension of the sites. :type phys_dim: int, optional :param site_ind_id: The identifier for the site indices. :type site_ind_id: str, optional :param bond_ind_id: The identifier for the bond indices. :type bond_ind_id: str, optional :param site_tag_id: The identifier for the site tags. :type site_tag_id: str, optional :rtype: Dict[hashable, Dict[str, Any]] .. py:data:: _DEFAULT_PHYS_CHARGEMAPS .. py:function:: TN_abelian_from_edges_rand(symmetry, edges, bond_dim, phys_dim=None, seed=None, dtype='float64', site_tag_id='I{}', site_ind_id='k{}', fermionic=False, flat=False, site_charge=None, subsizes='maximal', **kwargs) Build a random abelian symmetric `quimb.tensor` amplitude or PEPS from edges. :param symmetry: The symmetry of the PEPS. Currently only "Z2" and "U1" are supported. :type symmetry: {"Z2", "U1", "Z2Z2", "U1U1", ZN} :param edges: The edges of the PEPS. Each edge is a tuple of the form `(cooa, coob)` where cooa and coob are hashable labels of the two sites. :type edges: list of tuples :param bond_dim: The total (sum of charge sizes) bond dimension of the PEPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, all sites have the same dimension. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: None, int or dict, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param fermionic: Whether to generate fermionic tensors. :type fermionic: bool, optional :param flat: Whether to generate 'flat' backend arrays (True) or the default block-sparse backend arrays (False). :type flat: bool, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alternate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.TensorNetworkGen or quimb.tensor.TensorNetworkGenVector .. py:function:: TN_fermionic_from_edges_rand(symmetry, edges, bond_dim, phys_dim=None, seed=None, dtype='float64', site_tag_id='I{}', site_ind_id='k{}', site_charge=None, subsizes='maximal', **kwargs) Create a random fermionic tensor network from edges. This is a wrapper around :func:`TN_abelian_from_edges_rand` with `fermionic=True`. :param symmetry: The symmetry of the PEPS. Currently only "Z2" and "U1" are supported. :type symmetry: {"Z2", "U1", "Z2Z2", "U1U1", ZN} :param edges: The edges of the PEPS. Each edge is a tuple of the form `(cooa, coob)` where cooa and coob are hashable labels of the two sites. :type edges: list of tuples :param bond_dim: The total (sum of charge sizes) bond dimension of the PEPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, all sites have the same dimension. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: None, int or dict, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alernate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.TensorNetworkGen or quimb.tensor.TensorNetworkGenVector .. py:function:: MPS_abelian_rand(symmetry, L, bond_dim, phys_dim=2, cyclic=False, seed=None, dtype='float64', site_tag_id='I{}', site_ind_id='k{}', fermionic=False, flat=False, site_charge=None, subsizes='maximal', **kwargs) Create a random MPS with abelian symmetry. :param symmetry: The symmetry of the MPS. :type symmetry: str or Symmetry :param L: The number of sites. :type L: int :param bond_dim: The total (sum of charge sizes) bond dimension of the MPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, a default charge distribution is chosen. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: int or dict, optional :param cyclic: Whether the MPS is cyclic. :type cyclic: bool, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param fermionic: Whether to generate fermionic tensors. :type fermionic: bool, optional :param flat: Whether to generate 'flat' backend arrays (True) or the default block-sparse backend arrays (False). :type flat: bool, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alernate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.MatrixProductState .. py:function:: PEPS_abelian_rand(symmetry, Lx, Ly, bond_dim, phys_dim=2, cyclic=False, seed=None, dtype='float64', site_tag_id='I{},{}', site_ind_id='k{},{}', x_tag_id='X{}', y_tag_id='Y{}', fermionic=False, flat=False, site_charge=None, subsizes='maximal', **kwargs) Create a random 2D PEPS with abelian symmetry. :param symmetry: The symmetry of the PEPS. :type symmetry: str or Symmetry :param Lx: The number of rows. :type Lx: int :param Ly: The number of columns. :type Ly: int :param bond_dim: The total (sum of charge sizes) bond dimension of the PEPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, a default charge distribution is chosen. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: int or dict, optional :param cyclic: Whether the PEPS is cyclic in the x-direction. :type cyclic: bool, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param fermionic: Whether to generate fermionic tensors. :type fermionic: bool, optional :param flat: Whether to generate 'flat' backend arrays (True) or the default block-sparse backend arrays (False). :type flat: bool, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alernate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.PEPS .. py:function:: PEPS3D_abelian_rand(symmetry, Lx, Ly, Lz, bond_dim, phys_dim=2, cyclic=False, seed=None, dtype='float64', site_tag_id='I{},{},{}', site_ind_id='k{},{},{}', x_tag_id='X{}', y_tag_id='Y{}', z_tag_id='Z{}', fermionic=False, site_charge=None, subsizes='maximal', **kwargs) Create a random 3D PEPS with abelian symmetry. :param symmetry: The symmetry of the PEPS. :type symmetry: str or Symmetry :param Lx: Length of the PEPS in the x-direction. :type Lx: int :param Ly: Length of the PEPS in the y-direction. :type Ly: int :param Lz: Length of the PEPS in the z-direction. :type Lz: int :param bond_dim: The total (sum of charge sizes) bond dimension of the PEPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, a default charge distribution is chosen. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: int or dict, optional :param cyclic: Whether the PEPS is cyclic in the x-direction. :type cyclic: bool, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param fermionic: Whether to generate fermionic tensors. :type fermionic: bool, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alernate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.PEPS3D .. py:function:: MPS_fermionic_rand(symmetry, L, bond_dim, phys_dim=2, cyclic=False, seed=None, dtype='float64', site_tag_id='I{}', site_ind_id='k{}', site_charge=None, subsizes='maximal', **kwargs) Create a random fermionic MPS. This is a wrapper around :func:`MPS_abelian_rand` with `fermionic=True`. :param symmetry: The symmetry of the MPS. :type symmetry: str or Symmetry :param L: The number of sites. :type L: int :param bond_dim: The total (sum of charge sizes) bond dimension of the MPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, a default charge distribution is chosen. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: int or dict, optional :param cyclic: Whether the MPS is cyclic. :type cyclic: bool, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alernate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.MatrixProductState .. py:function:: PEPS_fermionic_rand(symmetry, Lx, Ly, bond_dim, phys_dim=2, cyclic=False, seed=None, dtype='float64', site_tag_id='I{},{}', site_ind_id='k{},{}', x_tag_id='X{}', y_tag_id='Y{}', site_charge=None, subsizes='maximal', **kwargs) Create a random 2D fermionic PEPS. This is a wrapper around :func:`PEPS_abelian_rand` with `fermionic=True`. :param symmetry: The symmetry of the PEPS. :type symmetry: str or Symmetry :param Lx: The number of rows. :type Lx: int :param Ly: The number of columns. :type Ly: int :param bond_dim: The total (sum of charge sizes) bond dimension of the PEPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, a default charge distribution is chosen. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: int or dict, optional :param cyclic: Whether the PEPS is cyclic in the x-direction. :type cyclic: bool, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alernate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.PEPS .. py:function:: PEPS3D_fermionic_rand(symmetry, Lx, Ly, Lz, bond_dim, phys_dim=2, cyclic=False, seed=None, dtype='float64', site_tag_id='I{},{},{}', site_ind_id='k{},{},{}', x_tag_id='X{}', y_tag_id='Y{}', z_tag_id='Z{}', site_charge=None, subsizes='maximal', **kwargs) Create a random 3D fermionic PEPS. This is a wrapper around :func:`PEPS3D_abelian_rand` with `fermionic=True`. :param symmetry: The symmetry of the PEPS. :type symmetry: str or Symmetry :param Lx: Length of the PEPS in the x-direction. :type Lx: int :param Ly: Length of the PEPS in the y-direction. :type Ly: int :param Lz: Length of the PEPS in the z-direction. :type Lz: int :param bond_dim: The total (sum of charge sizes) bond dimension of the PEPS. You can also provide an explicit map of bond charges to sizes. :type bond_dim: int or dict :param phys_dim: The physical dimension of each site. If None, no physical sites are included. If an integer, a default charge distribution is chosen. If a dictionary, a custom map of physical charges to sizes. :type phys_dim: int or dict, optional :param cyclic: Whether the PEPS is cyclic in the x-direction. :type cyclic: bool, optional :param seed: The random seed or generator to use. :type seed: None, int or np.random.Generator, optional :param dtype: The data type of the tensors. :type dtype: str, optional :param site_tag_id: The tag format for each site tensor. :type site_tag_id: str, optional :param site_ind_id: The index format for each site tensor, if physical sites are included. :type site_ind_id: str, optional :param site_charge: A function that takes a site index and returns the charge of that site. By default it will create all even parity tensors if Z2=0 or it will alernate between 0 and 1 for U1. :type site_charge: callable, optional :param subsizes: The sizes of the charge sectors. If None, the sizes are randomly determined. If "equal", the sizes are equal (up to remainders). If "maximal", as many charges as possible will be chosen. :type subsizes: {"maximal", "equal"}, optional :param kwargs: Additional arguments to pass to :func:`symmray.utils.get_rand`. :rtype: quimb.tensor.PEPS3D