symmray.fermionic_local_operators ================================= .. py:module:: symmray.fermionic_local_operators .. autoapi-nested-parse:: Helper functions for building local fermionic operators, with 'internal' signs pre-computed. Classes ------- .. autoapisummary:: symmray.fermionic_local_operators.FermionicOperator Functions --------- .. autoapisummary:: symmray.fermionic_local_operators.labels_lt symmray.fermionic_local_operators._dagger_basis symmray.fermionic_local_operators._ensure_fermionic_operator symmray.fermionic_local_operators._parse_terms symmray.fermionic_local_operators._parse_bases symmray.fermionic_local_operators.build_local_fermionic_elements symmray.fermionic_local_operators.build_local_fermionic_dense symmray.fermionic_local_operators.build_local_fermionic_array symmray.fermionic_local_operators.get_spinless_charge_indexmap symmray.fermionic_local_operators.get_spinful_charge_indexmap symmray.fermionic_local_operators.fermi_hubbard_spinless_local_array symmray.fermionic_local_operators.fermi_hubbard_local_array symmray.fermionic_local_operators.fermi_number_operator_spinless_local_array symmray.fermionic_local_operators.fermi_number_operator_spinful_local_array symmray.fermionic_local_operators.fermi_number_up_local_array symmray.fermionic_local_operators.fermi_number_down_local_array symmray.fermionic_local_operators.fermi_spin_operator_local_array Module Contents --------------- .. py:function:: labels_lt(labela, labelb) .. py:class:: FermionicOperator(label, dual=False, parity=1) Simple class to represent a fermionic operator with a label, a dual flag, and a parity 'switch' indicating whether the fermion is present. .. py:attribute:: __slots__ :value: ('_label', '_dual', '_parity') .. py:attribute:: _label .. py:attribute:: _dual :value: False .. py:attribute:: _parity :value: 1 .. py:method:: to_pytree() Convert this fermionic operator to a pytree purely of non-symmray containers and objects. .. py:method:: from_pytree(data) :classmethod: Create a fermionic operator from a pytree purely of non-symmray containers and objects. .. py:property:: label .. py:property:: dual .. py:property:: parity .. py:property:: dag .. py:method:: __eq__(other) .. py:method:: __lt__(other) .. py:method:: __repr__() .. py:function:: _dagger_basis(basis) Return the conjugate basis of a given basis. .. py:function:: _ensure_fermionic_operator(op) Possibly convert a tuple of (label, symbol) to a FermionicOperator. .. py:function:: _parse_terms(terms) Allow ops to be specified as tuples of (site, symbol) in addition to FermionicOperator instances. E.g. ``(-t, [('a', '+'), ('b', '-')])``. .. py:function:: _parse_bases(bases) Allow ops to be specified as tuples of (site, symbol) in addition to FermionicOperator instances. .. py:function:: build_local_fermionic_elements(terms, bases) Compute the elements of a local fermionic operator in a given tensor basis, including 'internal' signs. :param terms: The terms in the operator, each a tuple of a coefficient and a tuple of FermionicOperator or tuple[label, op] instances. :type terms: tuple[tuple[float, tuple[FermionicOperator, ...]]] :param bases: The tensor bases to compute the operator elements in. Each basis is a sequence of multiple FermionicOperator instancess acting on the vacuum. :type bases: tuple[tuple[tuple[FermionicOperator]]] :returns: A list of tuples of tensor indices and the corresponding tensor element, including phases. :rtype: list[tuple[tuple[int], float]] .. rubric:: Examples Compute the elements of a local fermionic operator in a tensor basis:: a, b = map(FermionicOperator, "ab") basis_a = [(), (a.dag,)] basis_b = [(), (b.dag,)] bases = (basis_a, basis_b) t = 1.0 U = 8.0 terms = ( (-t, (a.dag, b)), (-t, (b.dag, a)), (U, (a.dag, a, b.dag, b)), ) build_local_fermionic_elements(terms, bases) # {(0, 1, 1, 0): -1.0, (1, 0, 0, 1): -1.0, (1, 1, 1, 1): -8.0} .. py:function:: build_local_fermionic_dense(terms, bases, like='numpy') .. py:function:: build_local_fermionic_array(terms, bases, symmetry, index_maps, like='numpy', flat=False) Compute a local fermionic operator as a `FermionicArray`. :param terms: The terms in the operator, each a tuple of a coefficient and a tuple of FermionicOperator instances. :type terms: tuple[tuple[float, tuple[FermionicOperator, ...]]] :param bases: The tensor bases to compute the operator elements in. Each basis is a sequence of multiple FermionicOperator instances acting on the vacuum. :type bases: tuple[tuple[tuple[FermionicOperator]]] :param symmetry: The symmetry of the model. Either "Z2", "U1", "Z2Z2" or "U1U1". :type symmetry: str :param index_maps: For each basis, the sequence mapping linear index to charge sector. :type index_maps: Sequence[Sequence[hashable]] :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: The local operator in fermionic array form. :rtype: FermionicArray or FermionicArrayFlat .. py:function:: get_spinless_charge_indexmap(symmetry) Get a mapping of linear index to charge sector for a spinless fermion model. :param symmetry: The symmetry of the model. Either "Z2" or "U1". :type symmetry: str :rtype: list[hashable] .. py:function:: get_spinful_charge_indexmap(symmetry) Get a mapping of linear index to charge sector for a spinful fermion model. :param symmetry: The symmetry of the model. Either "Z2", "U1", "Z2Z2", or "U1U1". :type symmetry: str :rtype: list[hashable] .. py:function:: fermi_hubbard_spinless_local_array(symmetry, t=1.0, V=8.0, mu=0.0, delta=0.0, coordinations=(1, 1), like='numpy', flat=False) Construct the fermionic local tensor for the spinless Fermi-Hubbard model. The indices are ordered as (a, b, a', b'). :param symmetry: The symmetry of the model. Either "Z2" or "U1". :type symmetry: str :param t: The hopping parameter, by default 1.0. :type t: float, optional :param V: The nearest-neighbor interaction parameter, by default 8.0. :type V: float, optional :param mu: The chemical potential, by default 0.0. If a tuple, then the chemical potential is different for each site. :type mu: float or (float, float), optional :param delta: The nearest neighbor superconducting pairing parameter, by default 0.0. :type delta: float, optional :param coordinations: The coordinations of the sites, by default (1, 1). If applying this local operator to every edge in a graph, then the single site contributions can be properly accounted for if the coordinations are provided. :type coordinations: tuple[int, int], optional :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: The local operator in fermionic array form. :rtype: FermionicArray or FermionicArrayFlat .. py:function:: fermi_hubbard_local_array(symmetry, t=1.0, U=8.0, mu=0.0, coordinations=(1, 1), like='numpy', flat=False) Construct the fermionic local tensor for the Fermi-Hubbard model. The indices are ordered as (a, b, a', b'), with the local basis like (|00>, ad+|00>, au+|00>, au+ad+|00>) for site a with up (au) and down (ad) spin respectively and similar for site b. :param symmetry: The symmetry of the model. Either "Z2", "U1", "Z2Z2", or "U1U1". :type symmetry: str :param t: The hopping parameter, by default 1.0. :type t: float, optional :param U: The interaction parameter, by default 8.0. If a tuple, then the interaction parameter is different for each site. :type U: float or (float, float), optional :param mu: The chemical potential, by default 0.0. If a tuple, then the chemical potential is different for each site. :type mu: float or (float, float), optional :param coordinations: The coordinations of the sites, by default (1, 1). If applying this local operator to every edge in a graph, then the single site contributions can be properly accounted for if the coordinations are provided. :type coordinations: tuple[int, int], optional :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: The local operator in fermionic array form. :rtype: FermionicArray or FermionicArrayFlat .. py:function:: fermi_number_operator_spinless_local_array(symmetry, like='numpy', flat=False) Construct the fermionic number operator for the spinless Fermi-Hubbard model. The indices are ordered as (a, a'). The local basis is like (|0>, a+|0>) for single site a. :param symmetry: The symmetry of the model. Either "Z2" or "U1". :type symmetry: str :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: The local operator in fermionic array form. :rtype: FermionicArray or FermionicArrayFlat .. py:function:: fermi_number_operator_spinful_local_array(symmetry, like='numpy', flat=False) Construct the fermionic number operator for the Fermi-Hubbard model. The indices are ordered as (a, a'), with the local basis like (|00>, ad+|00>, au+|00>, au+ad+|00>) for site a with up (au) and down (ad) spin respectively for single site `a`. :param symmetry: The symmetry of the model. Either "Z2", "U1", "Z2Z2", or "U1U1". :type symmetry: str :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: **array** -- The local operator in fermionic array form. :rtype: FermionicArray .. py:function:: fermi_number_up_local_array(symmetry, like='numpy', flat=False) Construct the 'up' fermionic number operator for the Fermi-Hubbard model. The indices are ordered as (a, a'), with the local basis like (|00>, ad+|00>, au+|00>, au+ad+|00>) for site a with up (au) and down (ad) spin respectively for single site `a`. :param symmetry: The symmetry of the model. Either "Z2", "U1", "Z2Z2", or "U1U1". :type symmetry: str :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: The local operator in fermionic array form. :rtype: FermionicArray or FermionicArrayFlat .. py:function:: fermi_number_down_local_array(symmetry, like='numpy', flat=False) Construct the 'down' fermionic number operator for the Fermi-Hubbard model. The indices are ordered as (a, a'), with the local basis like (|00>, ad+|00>, au+|00>, au+ad+|00>) for site a with up (au) and down (ad) spin respectively for single site `a`. :param symmetry: The symmetry of the model. Either "Z2", "U1", "Z2Z2", or "U1U1". :type symmetry: str :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: The local operator in fermionic array form. :rtype: FermionicArray or FermionicArrayFlat .. py:function:: fermi_spin_operator_local_array(symmetry, like='numpy', flat=False) Construct the fermionic spin operator for the Fermi-Hubbard model. The indices are ordered as (a, a'), with the local basis like (|00>, ad+|00>, au+|00>, au+ad+|00>) for site a with up (au) and down (ad) spin respectively for single site `a`. :param symmetry: The symmetry of the model. Either "Z2", "U1", "Z2Z2", or "U1U1". :type symmetry: str :param like: The backend to use, by default "numpy". :type like: str, optional :param flat: Whether to return a flat array, by default False. :type flat: bool, optional :returns: The local operator in fermionic array form. :rtype: FermionicArray or FermionicArrayFlat