1D Fermi-Hubbard Hamiltonian¶
This example shows how to build a 1D Fermi-Hubbard Hamiltonian for analog simulation using
fermi_hubbard_1d() (backed by an MPO internally).
You can also call fermi_hubbard_1d() directly and wrap the result
with from_mpo() for custom workflows.
YAQS supports two representations:
Fermionic sites (default): one site with local dimension 4 per physical lattice site. Ladder operators act on a composite ↑/↓ basis per site; this is not a Jordan–Wigner qubit chain across sites, but matches the standard tensor-product embedding of site Fock spaces.
Jordan-Wigner Pauli chain (
jordan_wigner=True): qubits in the order 1↑, 1↓, 2↑, 2↓, … with local dimension 2 and full JW signs between spin orbitals. Use this mode for Pauli-string / qubit simulators.
The Hamiltonian (open boundaries, no chemical potential) is
1. Fermionic Hamiltonian¶
1from mqt.yaqs import Hamiltonian
2
3num_sites = 4
4t = 1.0
5u = 0.5
6
7H = Hamiltonian.fermi_hubbard_1d(num_sites, t=t, u=u)
8print(f"sites={H.length}, local dim={H.mpo.physical_dimension}, matrix shape={H.mpo.to_matrix().shape}")
sites=4, local dim=4, matrix shape=(256, 256)
The single-site basis is \(|0\rangle, |\!\downarrow\rangle, |\!\uparrow\rangle, |\!\uparrow\downarrow\rangle\) (NumPy kron ordering for \(|\!\uparrow\rangle \otimes |\!\downarrow\rangle\)).
2. Jordan-Wigner Hamiltonian¶
For the same model on \(L\) physical sites, pass length=2 * L spin orbitals:
1num_orbitals = 2 * num_sites
2
3H_jw = Hamiltonian.fermi_hubbard_1d(num_orbitals, t=t, u=u, jordan_wigner=True)
4print(f"orbitals={H_jw.length}, local dim={H_jw.mpo.physical_dimension}, matrix shape={H_jw.mpo.to_matrix().shape}")
orbitals=8, local dim=2, matrix shape=(256, 256)
3. Short analog simulation¶
Evolve a two-site fermionic chain in the vacuum \(|00\rangle\) and track the probability of remaining in that sector. Fermionic sites use local dimension 4, so pass physical_dimensions=[4, 4] on State.
1from mqt.yaqs import AnalogSimParams, Observable, Simulator, State
2
3hubbard_sites = 2
4H_small = Hamiltonian.fermi_hubbard_1d(hubbard_sites, t=1.0, u=0.5)
5psi0 = State(hubbard_sites, initial="zeros", physical_dimensions=[4, 4])
6
7params = AnalogSimParams(
8 observables=[Observable("00"), Observable("11")],
9 elapsed_time=0.2,
10 dt=0.05,
11 preset="fast",
12 sample_timesteps=True,
13)
14
15sim = Simulator(show_progress=False)
16result = sim.run(psi0, H_small, params)
17times = params.times
18p_vacuum = [float(v) for v in result.expectation_values[0]]
19p_down_down = [float(v) for v in result.expectation_values[1]]
20print("P(vacuum |00⟩):", p_vacuum)
21print("P(|↓⟩⊗|↓⟩) basis string '11':", p_down_down)
P(vacuum |00⟩): [1.0, 1.0, 1.0, 1.0, 1.0]
P(|↓⟩⊗|↓⟩) basis string '11': [0.0, 0.0, 0.0, 0.0, 0.0]
/home/docs/checkouts/readthedocs.org/user_builds/mqt-yaqs/checkouts/latest/src/mqt/yaqs/simulator.py:421: ComplexWarning: Casting complex values to real discards the imaginary part
result.trajectories[user_i][traj_index] = sorted_traj_data[sorted_i]
Hopping spreads population out of the vacuum; "11" indexes \(|{\downarrow}\rangle \otimes |{\downarrow}\rangle\), not double occupancy (index 3 = \(|{\uparrow\downarrow}\rangle\) per site).
1import matplotlib.pyplot as plt
2
3fig, ax = plt.subplots(figsize=(5, 3))
4ax.plot(times, p_vacuum, "o-", label=r"$P(|00\rangle)$ vacuum")
5ax.plot(times, p_down_down, "s--", label=r"$P(|\!\downarrow\rangle^{\otimes 2})$ ('11')")
6ax.set_xlabel("time")
7ax.set_ylabel("probability")
8ax.set_title("Two-site Fermi–Hubbard from vacuum")
9ax.legend()
10ax.grid(alpha=0.3)
11plt.tight_layout()
12plt.show()
4. Relation to the Trotter circuit helper¶
create_1d_fermi_hubbard_circuit() builds a digital Trotter circuit on separate ↑ and ↓ registers and can include a chemical potential \(\mu\).
The MPO factories above target the analog Hamiltonian without \(\mu\) and use either fermionic operators or an interleaved JW layout.
For digital simulation of the circuit model, use the circuit API; for tensor-network evolution of the Hubbard Hamiltonian, use Hamiltonian.fermi_hubbard_1d with run().