Permalink
Browse files

Minor changes to docs, imports, and meanfield model (#148)

* import from config

* fix typo in givens rotations doc

* fix description of spinless Hubbard model

* add chemical potential and edit docs

* pep8 lint and remove unittest artifact
  • Loading branch information...
kevinsung authored and idk3 committed Jan 8, 2018
1 parent 124e46c commit 602fd03373a5d45e75465ab8b908358d7362cc42
@@ -20,6 +20,7 @@
from ._version import __version__
from openfermion.config import EQ_TOLERANCE
from openfermion.hamiltonians import *
from openfermion.measurements import *
from openfermion.ops import *
@@ -57,8 +57,7 @@ def fermi_hubbard(x_dimension, y_dimension, tunneling, coulomb,
+ U \sum_{i} a^\dagger_{i, \\uparrow} a_{i, \\uparrow}
a^\dagger_{j, \downarrow} a_{j, \downarrow}
\\\\
&- \mu \sum_i (a^\dagger_{i, \\uparrow} a_{i, \\uparrow} +
a^\dagger_{i, \downarrow} a_{i, \downarrow})
&- \mu \sum_i \sum_{\sigma} a^\dagger_{i, \sigma} a_{i, \sigma}
- h \sum_i (a^\dagger_{i, \\uparrow} a_{i, \\uparrow} -
a^\dagger_{i, \downarrow} a_{i, \downarrow})
\\end{align}
@@ -81,7 +80,6 @@ def fermi_hubbard(x_dimension, y_dimension, tunneling, coulomb,
H = - t \sum_{k=1}^{N-1} (a_k^\dagger a_{k + 1} + a_{k+1}^\dagger a_k)
+ U \sum_{k=1}^{N-1} a_k^\dagger a_k a_{k+1}^\dagger a_{k+1}
+ h \sum_{k=1}^N (-1)^k a_k^\dagger a_k
- \mu \sum_{k=1}^N a_k^\dagger a_k.
Args:
@@ -15,11 +15,12 @@
from openfermion.hamiltonians._hubbard import up_index, down_index
from openfermion.ops import (FermionOperator,
hermitian_conjugated)
hermitian_conjugated,
number_operator)
def mean_field_dwave(x_dimension, y_dimension, tunneling, sc_gap,
periodic=True):
chemical_potential=0., periodic=True):
"""Return symbolic representation of a BCS mean-field d-wave Hamiltonian.
The Hamiltonians of this model live on a grid of dimensions
@@ -33,14 +34,18 @@ def mean_field_dwave(x_dimension, y_dimension, tunneling, sc_gap,
.. math::
H = - t \sum_{\langle i,j \\rangle} \sum_\sigma
\\begin{align}
H = &- t \sum_{\langle i,j \\rangle} \sum_\sigma
(a^\dagger_{i, \sigma} a_{j, \sigma} +
a^\dagger_{j, \sigma} a_{i, \sigma})
- \sum_{\langle i,j \\rangle} \Delta_{ij}
- \mu \sum_i \sum_{\sigma} a^\dagger_{i, \sigma} a_{i, \sigma}
\\\\
&- \sum_{\langle i,j \\rangle} \Delta_{ij}
(a^\dagger_{i, \\uparrow} a^\dagger_{j, \downarrow} -
a^\dagger_{i, \downarrow} a^\dagger_{j, \\uparrow} +
a_{j, \downarrow} a_{i, \\uparrow} -
a_{j, \\uparrow} a_{i, \downarrow})
\\end{align}
where
@@ -52,12 +57,15 @@ def mean_field_dwave(x_dimension, y_dimension, tunneling, sc_gap,
- :math:`\Delta_{ij}` is equal to :math:`+\Delta/2` for
horizontal edges and :math:`-\Delta/2` for vertical edges,
where :math:`\Delta` is the superconducting gap.
- :math:`\mu` is the chemical potential
Args:
x_dimension (int): The width of the grid.
y_dimension (int): The height of the grid.
tunneling (float): The tunneling amplitude :math:`t`.
sc_gap (float): The superconducting gap :math:`\Delta`
chemical_potential (float, optional): The chemical potential
:math:`\mu` at each site. Default value is 0.
periodic (bool, optional): If True, add periodic boundary conditions.
Default is True.
@@ -71,6 +79,12 @@ def mean_field_dwave(x_dimension, y_dimension, tunneling, sc_gap,
# Loop through sites and add terms.
for site in range(n_sites):
# Add chemical potential
mean_field_dwave_model += number_operator(
n_spin_orbitals, up_index(site), -chemical_potential)
mean_field_dwave_model += number_operator(
n_spin_orbitals, down_index(site), -chemical_potential)
# Index coupled orbitals.
right_neighbor = site + 1
bottom_neighbor = site + x_dimension
@@ -23,13 +23,20 @@ class MeanfieldDwaveTest(unittest.TestCase):
def setUp(self):
self.tunneling = 2.
self.sc_gap = 2.
self.chemical_potential = 2.
def test_two_by_two(self):
# Test the 2 by 2 model.
# Initialize the Hamiltonian.
mean_field_dwave_model = mean_field_dwave(
2, 2, self.tunneling, self.sc_gap)
2, 2, self.tunneling, self.sc_gap, self.chemical_potential)
# Check on-site terms.
for site in range(8):
self.assertAlmostEqual(
mean_field_dwave_model.terms[((site, 1), (site, 0))],
-self.chemical_potential)
# Check up right/left hopping terms.
self.assertAlmostEqual(mean_field_dwave_model.terms[((0, 1), (2, 0))],
@@ -662,7 +662,8 @@ def load(self):
# Load charge:
self.charge = int(f["charge"][...])
# Load description:
self.description = f["description"][...].tobytes().decode('utf-8').rstrip(u'\x00')
self.description = f["description"][...].tobytes().decode(
'utf-8').rstrip(u'\x00')
# Load name:
self.name = f["name"][...].tobytes().decode('utf-8')
# Load n_atoms:
@@ -293,6 +293,3 @@ def test_abstract_molecule(self):
correct_name = "Jellium_PlaneWave22_singlet"
self.assertEqual(jellium_molecule.name, correct_name)
os.remove("{}.hdf5".format(jellium_filename))
if __name__ == '__main__':
unittest.main()
@@ -46,8 +46,8 @@ def gaussian_state_preparation_circuit(
- a tuple :math:`(i, j, \\theta, \\varphi)`, indicating the operation
.. math::
\exp[i \\varphi a_q^\dagger a_q]
\exp[\\theta (a_p^\dagger a_q - a_q^\dagger a_p)],
\exp[i \\varphi a_j^\dagger a_j]
\exp[\\theta (a_i^\dagger a_j - a_j^\dagger a_i)],
a Givens rotation of modes :math:`i` and :math:`j` by angles
:math:`\\theta` and :math:`\\varphi`.

0 comments on commit 602fd03

Please sign in to comment.