Skip to content

Commit

Permalink
delete some hubbard tests (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung authored Aug 30, 2024
1 parent 1df0b58 commit 7c04f9f
Showing 1 changed file with 8 additions and 230 deletions.
238 changes: 8 additions & 230 deletions tests/python/operators/fermi_hubbard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,153 +481,8 @@ def test_fermi_hubbard_2d_2x2_periodic():
}


def test_non_interacting_fermi_hubbard_1d_eigenvalue():
"""Test ground-state eigenvalue of the non-interacting one-dimensional Fermi-Hubbard
model Hamiltonian."""

# open boundary conditions
op = fermi_hubbard_1d(norb=4, tunneling=1, interaction=0)
ham = ffsim.linear_operator(op, norb=4, nelec=(2, 2))
eigs, _ = scipy.sparse.linalg.eigsh(ham, which="SA", k=1)
np.testing.assert_allclose(eigs[0], -4.472135955000)

# periodic boundary conditions
op_periodic = fermi_hubbard_1d(norb=4, tunneling=1, interaction=0, periodic=True)
ham_periodic = ffsim.linear_operator(op_periodic, norb=4, nelec=(2, 2))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -4.000000000000)

# periodic boundary conditions (edge case)
op_periodic_edge = fermi_hubbard_1d(
norb=2, tunneling=1, interaction=0, periodic=True
)
ham_periodic = ffsim.linear_operator(op_periodic_edge, norb=2, nelec=(1, 1))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -4.000000000000)


def test_non_interacting_fermi_hubbard_2d_eigenvalue():
"""Test ground-state eigenvalue of the non-interacting two-dimensional Fermi-Hubbard
model Hamiltonian."""

# open boundary conditions
op = fermi_hubbard_2d(norb_x=2, norb_y=2, tunneling=1, interaction=0)
ham = ffsim.linear_operator(op, norb=4, nelec=(2, 2))
eigs, _ = scipy.sparse.linalg.eigsh(ham, which="SA", k=1)
np.testing.assert_allclose(eigs[0], -4.000000000000)

# periodic boundary conditions (edge case)
op_periodic_edge = fermi_hubbard_2d(
norb_x=2, norb_y=2, tunneling=1, interaction=0, periodic=True
)
ham_periodic = ffsim.linear_operator(op_periodic_edge, norb=4, nelec=(2, 2))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
print(eigs_periodic)
np.testing.assert_allclose(eigs_periodic[0], -8.000000000000)


def test_fermi_hubbard_1d_with_interaction_eigenvalue():
"""Test ground-state eigenvalue of the one-dimensional Fermi-Hubbard model
Hamiltonian with onsite interaction."""

# open boundary conditions
op = fermi_hubbard_1d(norb=4, tunneling=1, interaction=2)
ham = ffsim.linear_operator(op, norb=4, nelec=(2, 2))
eigs, _ = scipy.sparse.linalg.eigsh(ham, which="SA", k=1)
np.testing.assert_allclose(eigs[0], -2.875942809005)

# periodic boundary conditions
op_periodic = fermi_hubbard_1d(norb=4, tunneling=1, interaction=2, periodic=True)
ham_periodic = ffsim.linear_operator(op_periodic, norb=4, nelec=(2, 2))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -2.828427124746)

# periodic boundary conditions (edge case)
op_periodic_edge = fermi_hubbard_1d(
norb=2, tunneling=1, interaction=2, periodic=True
)
ham_periodic = ffsim.linear_operator(op_periodic_edge, norb=2, nelec=(1, 1))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -3.123105625618)


def test_fermi_hubbard_2d_with_interaction_eigenvalue():
"""Test ground-state eigenvalue of the two-dimensional Fermi-Hubbard model
Hamiltonian with onsite interaction."""

# open boundary conditions
op = fermi_hubbard_2d(norb_x=2, norb_y=2, tunneling=1, interaction=2)
ham = ffsim.linear_operator(op, norb=4, nelec=(2, 2))
eigs, _ = scipy.sparse.linalg.eigsh(ham, which="SA", k=1)
np.testing.assert_allclose(eigs[0], -2.828427124746)

# periodic boundary conditions (edge case)
op_periodic_edge = fermi_hubbard_2d(
norb_x=2, norb_y=2, tunneling=1, interaction=2, periodic=True
)
ham_periodic = ffsim.linear_operator(op_periodic_edge, norb=4, nelec=(2, 2))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -6.681695234497)


def test_fermi_hubbard_1d_with_chemical_potential_eigenvalue():
"""Test ground-state eigenvalue of the one-dimensional Fermi-Hubbard model
Hamiltonian with onsite interaction and chemical potential."""

# open boundary conditions
op = fermi_hubbard_1d(norb=4, tunneling=1, interaction=2, chemical_potential=3)
ham = ffsim.linear_operator(op, norb=4, nelec=(2, 2))
eigs, _ = scipy.sparse.linalg.eigsh(ham, which="SA", k=1)
np.testing.assert_allclose(eigs[0], -14.875942809005)

# periodic boundary conditions
op_periodic = fermi_hubbard_1d(
norb=4, tunneling=1, interaction=2, chemical_potential=3, periodic=True
)
ham_periodic = ffsim.linear_operator(op_periodic, norb=4, nelec=(2, 2))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -14.828427124746)

# periodic boundary conditions (edge case)
op_periodic_edge = fermi_hubbard_1d(
norb=2, tunneling=1, interaction=2, chemical_potential=3, periodic=True
)
ham_periodic = ffsim.linear_operator(op_periodic_edge, norb=2, nelec=(1, 1))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -9.123105625618)


def test_fermi_hubbard_2d_with_chemical_potential_eigenvalue():
"""Test ground-state eigenvalue of the two-dimensional Fermi-Hubbard model
Hamiltonian with onsite interaction and chemical potential."""

# open boundary conditions
op = fermi_hubbard_2d(
norb_x=2, norb_y=2, tunneling=1, interaction=2, chemical_potential=3
)
ham = ffsim.linear_operator(op, norb=4, nelec=(2, 2))
eigs, _ = scipy.sparse.linalg.eigsh(ham, which="SA", k=1)
np.testing.assert_allclose(eigs[0], -14.828427124746)

# periodic boundary conditions (edge case)
op_periodic_edge = fermi_hubbard_2d(
norb_x=2,
norb_y=2,
tunneling=1,
interaction=2,
chemical_potential=3,
periodic=True,
)
ham_periodic = ffsim.linear_operator(op_periodic_edge, norb=4, nelec=(2, 2))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], -18.681695234497)


def test_fermi_hubbard_1d_with_nearest_neighbor_interaction_eigenvalue():
"""Test ground-state eigenvalue of the one-dimensional Fermi-Hubbard model
Hamiltonian with onsite interaction, chemical potential, and nearest-neighbor
interaction."""

def test_fermi_hubbard_1d_eigenvalue_spin_balanced():
"""Test eigenvalue of 1-D Fermi-Hubbard model with balanced spins."""
# open boundary conditions
op = fermi_hubbard_1d(
norb=4,
Expand Down Expand Up @@ -667,11 +522,8 @@ def test_fermi_hubbard_1d_with_nearest_neighbor_interaction_eigenvalue():
np.testing.assert_allclose(eigs_periodic[0], -6.000000000000)


def test_fermi_hubbard_2d_with_nearest_neighbor_interaction_eigenvalue():
"""Test ground-state eigenvalue of the two-dimensional Fermi-Hubbard model
Hamiltonian with onsite interaction, chemical potential, and nearest-neighbor
interaction."""

def test_fermi_hubbard_2d_eigenvalue_spin_balanced():
"""Test eigenvalue of 2-D Fermi-Hubbard model with balanced spins."""
# open boundary conditions
op = fermi_hubbard_2d(
norb_x=2,
Expand Down Expand Up @@ -700,10 +552,8 @@ def test_fermi_hubbard_2d_with_nearest_neighbor_interaction_eigenvalue():
np.testing.assert_allclose(eigs_periodic[0], -9.428197577536)


def test_fermi_hubbard_1d_with_unequal_filling_eigenvalue():
"""Test ground-state eigenvalue of the one-dimensional Fermi-Hubbard model
Hamiltonian with unequal filling."""

def test_fermi_hubbard_1d_eigenvalue_spin_unbalanced():
"""Test eigenvalue of 1-D Fermi-Hubbard model with unbalanced spins."""
# open boundary conditions
op = fermi_hubbard_1d(
norb=4,
Expand All @@ -730,10 +580,8 @@ def test_fermi_hubbard_1d_with_unequal_filling_eigenvalue():
np.testing.assert_allclose(eigs_periodic[0], -0.828427124746)


def test_fermi_hubbard_2d_with_unequal_filling_eigenvalue():
"""Test ground-state eigenvalue of the two-dimensional Fermi-Hubbard model
Hamiltonian with unequal filling."""

def test_fermi_hubbard_2d_eigenvalue_spin_unbalanced():
"""Test eigenvalue of 2-D Fermi-Hubbard model with unbalanced spins."""
# open boundary conditions
op = fermi_hubbard_2d(
norb_x=2,
Expand All @@ -760,73 +608,3 @@ def test_fermi_hubbard_2d_with_unequal_filling_eigenvalue():
ham_periodic = ffsim.linear_operator(op_periodic_edge, norb=4, nelec=(1, 3))
eigs_periodic, _ = scipy.sparse.linalg.eigsh(ham_periodic, which="SA", k=1)
np.testing.assert_allclose(eigs_periodic[0], 8.743352161722)


def test_fermi_hubbard_1d_hermiticity():
"""Test hermiticity of the one-dimensional Fermi-Hubbard model Hamiltonian."""

n_orbitals = 4
n_electrons = (3, 1)
dim = ffsim.dim(n_orbitals, n_electrons)

# open boundary conditions
op = fermi_hubbard_1d(
norb=n_orbitals,
tunneling=1.1,
interaction=1.2,
chemical_potential=1.3,
nearest_neighbor_interaction=1.4,
)
ham = ffsim.linear_operator(op, norb=n_orbitals, nelec=n_electrons)
np.testing.assert_allclose(ham @ np.eye(dim), ham.H @ np.eye(dim))

# periodic boundary conditions
op_periodic = fermi_hubbard_1d(
norb=n_orbitals,
tunneling=1.1,
interaction=1.2,
chemical_potential=1.3,
nearest_neighbor_interaction=1.4,
periodic=True,
)
ham_periodic = ffsim.linear_operator(
op_periodic, norb=n_orbitals, nelec=n_electrons
)
np.testing.assert_allclose(ham_periodic @ np.eye(dim), ham_periodic.H @ np.eye(dim))


def test_fermi_hubbard_2d_hermiticity():
"""Test hermiticity of the two-dimensional Fermi-Hubbard model Hamiltonian."""

n_orbitals_x = 2
n_orbitals_y = 2
n_orbitals = n_orbitals_x * n_orbitals_y
n_electrons = (3, 1)
dim = ffsim.dim(n_orbitals, n_electrons)

# open boundary conditions
op = fermi_hubbard_2d(
norb_x=n_orbitals_x,
norb_y=n_orbitals_y,
tunneling=1.1,
interaction=1.2,
chemical_potential=1.3,
nearest_neighbor_interaction=1.4,
)
ham = ffsim.linear_operator(op, norb=n_orbitals, nelec=n_electrons)
np.testing.assert_allclose(ham @ np.eye(dim), ham.H @ np.eye(dim))

# periodic boundary conditions
op_periodic = fermi_hubbard_2d(
norb_x=n_orbitals_x,
norb_y=n_orbitals_y,
tunneling=1.1,
interaction=1.2,
chemical_potential=1.3,
nearest_neighbor_interaction=1.4,
periodic=True,
)
ham_periodic = ffsim.linear_operator(
op_periodic, norb=n_orbitals, nelec=n_electrons
)
np.testing.assert_allclose(ham_periodic @ np.eye(dim), ham_periodic.H @ np.eye(dim))

0 comments on commit 7c04f9f

Please sign in to comment.