quimb.operator.models

Predefined hamiltonians for various models:

  • Heisenberg model

  • Fermi-Hubbard model

  • Spinless Fermi-Hubbard model

  • Random operators

Functions

make_edge_factory(coeff)

Ensure coeff is a function that takes two sites and returns an edge

make_node_factory(coeff)

Ensure coeff is a function that takes a site and returns a node

heisenberg_from_edges(edges[, j, b, order, sector, ...])

Create a Heisenberg Hamiltonian on the graph defined by edges.

fermi_hubbard_from_edges(edges[, t, U, mu, order, ...])

Create a Fermi-Hubbard Hamiltonian on the graph defined by edges.

fermi_hubbard_spinless_from_edges(edges[, t, V, mu, ...])

Create a spinless Fermi-Hubbard Hamiltonian on the graph defined by

rand_operator(n, m, k[, kmin, seed, ops])

Generate a random operator with n qubits and m terms.

Module Contents

quimb.operator.models.make_edge_factory(coeff)[source]

Ensure coeff is a function that takes two sites and returns an edge coeff.

quimb.operator.models.make_node_factory(coeff)[source]

Ensure coeff is a function that takes a site and returns a node coeff.

quimb.operator.models.heisenberg_from_edges(edges, j=1.0, b=0.0, order=None, sector=None, symmetry=None, hilbert_space=None, dtype=None)[source]

Create a Heisenberg Hamiltonian on the graph defined by edges.

\[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 \(\{i,j\}\) are the edges of the graph, and \(S^x_i\) is the spin-1/2 operator acting on site \(i\) in the x-direction, etc. Note positive values of \(J\) correspond to antiferromagnetic coupling here, and the magnetic field is in the z-direction by default.

Parameters:
  • edges (Iterable[tuple[hashable, hashable]]) – The edges, as pairs of hashable ‘sites’, that define the graph. Multiple edges are allowed, and will be treated as a single edge.

  • j (float or tuple[float, float, float] or dict or callable, optional) – 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.

  • b (float or tuple[float, float, float] or dict or callable, optional) – 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.

  • order (callable or sequence of hashable objects, optional) – 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.

  • sector ({None, str, int, ((int, int), (int, int))}, optional) – The sector of the Hilbert space. If None, no sector is assumed.

  • symmetry ({None, "Z2", "U1", "U1U1"}, optional) – 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.

  • hilbert_space (HilbertSpace, optional) – The Hilbert space to use. If not given, one will be constructed automatically from the edges. This overrides the order, symmetry, and sector parameters.

  • dtype ({None, str, type}, optional) – The data type of the Hamiltonian. If None, a default dtype will be used, np.float64 for real and np.complex128 for complex.

Returns:

H – The Hamiltonian as a SparseOperatorBuilder object.

Return type:

SparseOperatorBuilder

quimb.operator.models.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)[source]

Create a Fermi-Hubbard Hamiltonian on the graph defined by edges. The Hamiltonian is given by:

\[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 \(\{i,j\}\) are the edges of the graph, and \(c_{\sigma,i}\) is the fermionic annihilation operator acting on site \(i\) with spin \(\sigma\). The Jordan-Wigner transformation is used to implement fermionic statistics.

Parameters:
  • edges (Iterable[tuple[hashable, hashable]]) – The edges, as pairs of hashable ‘sites’, that define the graph. Multiple edges are allowed, but will be treated as a single edge.

  • t (float or tuple[float, float] or dict or callable, optional) – 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.

  • U (float or dict or callable, optional) – The on-site interaction strength. Default is 1.0. A dict or callable can be supplied to have site-dependent interactions.

  • mu (float or tuple[float, float] or dict or callable, optional) – 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.

  • order (callable or sequence of hashable objects, optional) – 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.

  • sector ({None, str, int, ((int, int), (int, int))}, optional) – The sector of the Hilbert space. If None, no sector is assumed.

  • symmetry ({None, "Z2", "U1", "U1U1"}, optional) – 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.

  • hilbert_space (HilbertSpace, optional) – The Hilbert space to use. If not given, one will be constructed automatically from the edges. This overrides the order, symmetry, and sector parameters.

  • dtype ({None, str, type}, optional) – The data type of the Hamiltonian. If None, a default dtype will be used, np.float64 for real and np.complex128 for complex.

  • pauli_decompose (bool, optional) – Whether to decompose the Hamiltonian into Pauli strings after Jordan-Wigner transforming. Default is False.

Returns:

H – The Hamiltonian as a SparseOperatorBuilder object.

Return type:

SparseOperatorBuilder

quimb.operator.models.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)[source]

Create a spinless Fermi-Hubbard Hamiltonian on the graph defined by edges. The Hamiltonian is given by:

\[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 \(\{i,j\}\) are the edges of the graph, and \(c_i\) is the fermionic annihilation operator acting on site \(i\). The Jordan-Wigner transformation is used to implement fermionic statistics.

Parameters:
  • edges (Iterable[tuple[hashable, hashable]]) – The edges, as pairs of hashable ‘sites’, that define the graph. Multiple edges are allowed, but will be treated as a single edge.

  • t (float or dict or callable, optional) – The hopping amplitude. Default is 1.0. A dict or callable can be supplied to have edge-dependent hoppings.

  • V (float or dict or callable, optional) – The nearest neighbor interaction strength. Default is 0.0. A dict or callable can be supplied to have edge-dependent interactions.

  • mu (float or dict or callable, optional) – The chemical potential. Default is 0.0. A dict or callable can be supplied to have site-dependent chemical potentials.

  • delta (float or dict or callable, optional) – The superconducting pairing strength. Default is 0.0. A dict or callable can be supplied to have edge-dependent pairings.

  • order (callable or sequence of hashable objects, optional) – 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.

  • sector ({None, str, int, ((int, int), (int, int))}, optional) – The sector of the Hilbert space. If None, no sector is assumed.

  • symmetry ({None, "Z2", "U1", "U1U1"}, optional) – 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.

  • hilbert_space (HilbertSpace, optional) – The Hilbert space to use. If not given, one will be constructed automatically from the edges. This overrides the order, symmetry, and sector parameters.

  • dtype ({None, str, type}, optional) – The data type of the Hamiltonian. If None, a default dtype will be used, np.float64 for real and np.complex128 for complex.

  • pauli_decompose (bool, optional) – Whether to decompose the Hamiltonian into Pauli strings after Jordan-Wigner transforming. Default is False.

Returns:

H – The Hamiltonian as a SparseOperatorBuilder object.

Return type:

SparseOperatorBuilder

quimb.operator.models.rand_operator(n, m, k, kmin=None, seed=None, ops='XYZ')[source]

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.

Parameters:
  • n (int) – The number of qubits.

  • m (int) – The number of terms in the operator.

  • k (int) – The number of operators in each term.

  • kmin (int, optional) – The minimum number of operators in each term. If not given, kmin = k.

  • seed (int, optional) – The random seed for reproducibility.

  • ops (str, optional) – The set of operators to choose from.

Returns:

The random operator as a SparseOperatorBuilder object.

Return type:

SparseOperatorBuilder