Skip to content

Commit

Permalink
small change to avoid zero operators
Browse files Browse the repository at this point in the history
  • Loading branch information
idk3 committed Dec 22, 2017
1 parent db676ff commit 1ce08e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/openfermion/hamiltonians/_hubbard.py
Expand Up @@ -142,12 +142,12 @@ def fermi_hubbard(x_dimension, y_dimension, tunneling, coulomb,
for site in range(n_sites):
# Add chemical potential to the spinless case. The magnetic field
# doesn't contribute.
if spinless:
if spinless and chemical_potential:
hubbard_model += number_operator(
n_spin_orbitals, site, -chemical_potential)

# Add the chemical potential and magnetic field terms.
else:
# With spin, add the chemical potential and magnetic field terms.
elif not spinless:
hubbard_model += number_operator(
n_spin_orbitals, up_index(site),
-chemical_potential - magnetic_field)
Expand Down

0 comments on commit 1ce08e0

Please sign in to comment.