quimb.operator.models ===================== .. py:module:: quimb.operator.models .. autoapi-nested-parse:: Predefined hamiltonians for various models: - Heisenberg model - Fermi-Hubbard model - Spinless Fermi-Hubbard model - Random operators Functions --------- .. autoapisummary:: quimb.operator.models.make_edge_factory quimb.operator.models.make_node_factory quimb.operator.models.heisenberg_from_edges quimb.operator.models.fermi_hubbard_from_edges quimb.operator.models.fermi_hubbard_spinless_from_edges quimb.operator.models.rand_operator Module Contents --------------- .. py:function:: make_edge_factory(coeff) Ensure `coeff` is a function that takes two sites and returns an edge coeff. .. py:function:: make_node_factory(coeff) Ensure `coeff` is a function that takes a site and returns a node coeff. .. py:function:: heisenberg_from_edges(edges, j=1.0, b=0.0, order=None, sector=None, symmetry=None, hilbert_space=None, dtype=None) Create a Heisenberg Hamiltonian on the graph defined by ``edges``. .. math:: H = \sum_{\{i,j\}}^{|E|} \left( J_x S^x_i S^x_j + J_y S^y_i S^y_j + J_z S^z_i S^z_j \right) - \sum_{i}^{|V|} \left( B_x S^x_i + B_y S^y_i + B_z S^z_i \right) where :math:`\{i,j\}` are the edges of the graph, and :math:`S^x_i` is the spin-1/2 operator acting on site :math:`i` in the x-direction, etc. Note positive values of :math:`J` correspond to antiferromagnetic coupling here, and the magnetic field is in the z-direction by default. :param edges: The edges, as pairs of hashable 'sites', that define the graph. Multiple edges are allowed, and will be treated as a single edge. :type edges: Iterable[tuple[hashable, hashable]] :param j: The Heisenberg exchange coupling constant(s). If a single float is given, it is used for all three terms. If a tuple of three floats is given, they are used for the xx, yy, and zz terms respectively. Note that positive values of ``j`` correspond to antiferromagnetic coupling. A dict or callable can be supplied to have edge-dependent couplings. :type j: float or tuple[float, float, float] or dict or callable, optional :param b: The magnetic field strength(s). If a single float is given, it is used taken as a z-field. If a tuple of three floats is given, they are used for the x, y, and z fields respectively. A dict or callable can be supplied to have site-dependent fields. :type b: float or tuple[float, float, float] or dict or callable, optional :param order: If provided, use this to order the sites. If a callable, it should be a sorting key. If a sequence, it should be a permutation of the sites, and ``key=order.index`` will be used. :type order: callable or sequence of hashable objects, optional :param sector: The sector of the Hilbert space. If None, no sector is assumed. :type sector: {None, str, int, ((int, int), (int, int))}, optional :param symmetry: The symmetry of the Hilbert space if any. If `None` and a `sector` is provided, the symmetry will be inferred from the sector if possible. :type symmetry: {None, "Z2", "U1", "U1U1"}, optional :param hilbert_space: The Hilbert space to use. If not given, one will be constructed automatically from the edges. This overrides the ``order``, ``symmetry``, and ``sector`` parameters. :type hilbert_space: HilbertSpace, optional :param dtype: The data type of the Hamiltonian. If None, a default dtype will be used, np.float64 for real and np.complex128 for complex. :type dtype: {None, str, type}, optional :returns: **H** -- The Hamiltonian as a SparseOperatorBuilder object. :rtype: SparseOperatorBuilder .. py:function:: fermi_hubbard_from_edges(edges, t=1.0, U=1.0, mu=0.0, order=None, sector=None, symmetry=None, hilbert_space=None, dtype=None, pauli_decompose=False) Create a Fermi-Hubbard Hamiltonian on the graph defined by ``edges``. The Hamiltonian is given by: .. math:: H = -t \sum_{\{i,j\}}^{|E|} \sum_{\sigma \in \uparrow, \downarrow} \left( c_{\sigma,i}^\dagger c_{\sigma,j} + c_{\sigma,j}^\dagger c_{\sigma,i} \right) + U \sum_{i}^{|V|} n_{\uparrow,i} n_{\downarrow,i} - \mu \sum_{i}^{|V|} \left( n_{\uparrow,i} + n_{\downarrow,i} \right) where :math:`\{i,j\}` are the edges of the graph, and :math:`c_{\sigma,i}` is the fermionic annihilation operator acting on site :math:`i` with spin :math:`\sigma`. The Jordan-Wigner transformation is used to implement fermionic statistics. :param edges: The edges, as pairs of hashable 'sites', that define the graph. Multiple edges are allowed, but will be treated as a single edge. :type edges: Iterable[tuple[hashable, hashable]] :param t: The hopping amplitude. Default is 1.0. If a tuple it specifies the up and down spin hoppings respectively. A dict or callable can be supplied to have edge-dependent hoppings. :type t: float or tuple[float, float] or dict or callable, optional :param U: The on-site interaction strength. Default is 1.0. A dict or callable can be supplied to have site-dependent interactions. :type U: float or dict or callable, optional :param mu: The chemical potential. Default is 0.0. If a tuple it specifies the up and down spin chemical potentials respectively. A dict or callable can be supplied to have site-dependent chemical potentials. :type mu: float or tuple[float, float] or dict or callable, optional :param order: If provided, use this to order the sites. If a callable, it should be a sorting key. If a sequence, it should be a permutation of the sites, and ``key=order.index`` will be used. :type order: callable or sequence of hashable objects, optional :param sector: The sector of the Hilbert space. If None, no sector is assumed. :type sector: {None, str, int, ((int, int), (int, int))}, optional :param symmetry: The symmetry of the Hilbert space if any. If `None` and a `sector` is provided, the symmetry will be inferred from the sector if possible. :type symmetry: {None, "Z2", "U1", "U1U1"}, optional :param hilbert_space: The Hilbert space to use. If not given, one will be constructed automatically from the edges. This overrides the ``order``, ``symmetry``, and ``sector`` parameters. :type hilbert_space: HilbertSpace, optional :param dtype: The data type of the Hamiltonian. If None, a default dtype will be used, np.float64 for real and np.complex128 for complex. :type dtype: {None, str, type}, optional :param pauli_decompose: Whether to decompose the Hamiltonian into Pauli strings after Jordan-Wigner transforming. Default is False. :type pauli_decompose: bool, optional :returns: **H** -- The Hamiltonian as a SparseOperatorBuilder object. :rtype: SparseOperatorBuilder .. py:function:: fermi_hubbard_spinless_from_edges(edges, t=1.0, V=0.0, mu=0.0, delta=0.0, order=None, sector=None, symmetry=None, hilbert_space=None, dtype=None, pauli_decompose=False) Create a spinless Fermi-Hubbard Hamiltonian on the graph defined by ``edges``. The Hamiltonian is given by: .. math:: H = -t \sum_{\{i,j\}}^{|E|} \left( c_i^\dagger c_j + c_j^\dagger c_i \right) + V \sum_{\{i,j\}}^{|E|} n_i n_j - \mu \sum_{i}^{|V|} n_i + \Delta \sum_{\{i,j\}}^{|E|} \left( c_i^\dagger c_j^\dagger + c_j c_i \right) where :math:`\{i,j\}` are the edges of the graph, and :math:`c_i` is the fermionic annihilation operator acting on site :math:`i`. The Jordan-Wigner transformation is used to implement fermionic statistics. :param edges: The edges, as pairs of hashable 'sites', that define the graph. Multiple edges are allowed, but will be treated as a single edge. :type edges: Iterable[tuple[hashable, hashable]] :param t: The hopping amplitude. Default is 1.0. A dict or callable can be supplied to have edge-dependent hoppings. :type t: float or dict or callable, optional :param V: The nearest neighbor interaction strength. Default is 0.0. A dict or callable can be supplied to have edge-dependent interactions. :type V: float or dict or callable, optional :param mu: The chemical potential. Default is 0.0. A dict or callable can be supplied to have site-dependent chemical potentials. :type mu: float or dict or callable, optional :param delta: The superconducting pairing strength. Default is 0.0. A dict or callable can be supplied to have edge-dependent pairings. :type delta: float or dict or callable, optional :param order: If provided, use this to order the sites. If a callable, it should be a sorting key. If a sequence, it should be a permutation of the sites, and ``key=order.index`` will be used. :type order: callable or sequence of hashable objects, optional :param sector: The sector of the Hilbert space. If None, no sector is assumed. :type sector: {None, str, int, ((int, int), (int, int))}, optional :param symmetry: The symmetry of the Hilbert space if any. If `None` and a `sector` is provided, the symmetry will be inferred from the sector if possible. :type symmetry: {None, "Z2", "U1", "U1U1"}, optional :param hilbert_space: The Hilbert space to use. If not given, one will be constructed automatically from the edges. This overrides the ``order``, ``symmetry``, and ``sector`` parameters. :type hilbert_space: HilbertSpace, optional :param dtype: The data type of the Hamiltonian. If None, a default dtype will be used, np.float64 for real and np.complex128 for complex. :type dtype: {None, str, type}, optional :param pauli_decompose: Whether to decompose the Hamiltonian into Pauli strings after Jordan-Wigner transforming. Default is False. :type pauli_decompose: bool, optional :returns: **H** -- The Hamiltonian as a SparseOperatorBuilder object. :rtype: SparseOperatorBuilder .. py:function:: rand_operator(n, m, k, kmin=None, seed=None, ops='XYZ') Generate a random operator with n qubits and m terms. Each term is a sum of k operators acting on different qubits. The operators are chosen randomly from the set {X, Y, Z, +, -, n}. The coefficients are drawn from a normal distribution. :param n: The number of qubits. :type n: int :param m: The number of terms in the operator. :type m: int :param k: The number of operators in each term. :type k: int :param kmin: The minimum number of operators in each term. If not given, kmin = k. :type kmin: int, optional :param seed: The random seed for reproducibility. :type seed: int, optional :param ops: The set of operators to choose from. :type ops: str, optional :returns: The random operator as a SparseOperatorBuilder object. :rtype: SparseOperatorBuilder