Skip to content

Commit

Permalink
Some commenting in response to #70. Minor fix in the type hinting inc…
Browse files Browse the repository at this point in the history
…luded.
  • Loading branch information
shiozaki committed Feb 26, 2021
1 parent e1e565f commit bb02451
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
20 changes: 18 additions & 2 deletions src/fqe/hamiltonians/diagonal_coulomb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,30 @@
class DiagonalCoulomb(hamiltonian.Hamiltonian):
"""The diagonal coulomb Hamiltonian is characterized as being a two-body
operator with a specific structure such that it is the product of two
number operators.
number operators. It is generally written as
.. math::
\\hat{H} = E_0 + \\sum_r f_r \\hat{n}_r
+ \\sum_{rs} v_{rs} \\hat{n}_r \\hat{n}_s
where n is a number operator. Note that this Hamiltonian is diagonal
in the Slater determinant space,
.. math::
\\langle I|\\hat{H}|J\\rangle = p \\delta_{IJ}
where p is an appropriate factor.
"""

def __init__(self, h2e: np.ndarray, e_0: complex = 0.0 + 0.0j) -> None:
"""Initialize a DiagonalCoulomb Hamiltonian.
Args:
h2e: Dense two-body tensor that contains DiagonalCoulomb elements.
h2e: either (1) a dense rank-2 array that contains the diagonal
elements :math:`|v_{rs}|` above, or (2) a dense rank-4 array
in the format used for two-body operator in the dense
Hamiltonian code.
e_0: Scalar potential associated with the Hamiltonian.
"""

Expand Down
27 changes: 20 additions & 7 deletions src/fqe/hamiltonians/diagonal_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,36 @@
"""Defines the DiagonalHamiltonian class."""

import copy
from typing import Tuple
from typing import TYPE_CHECKING

import numpy as np

from fqe.hamiltonians import hamiltonian

if TYPE_CHECKING:
from numpy import ndarray as Nparray


class Diagonal(hamiltonian.Hamiltonian):
"""Diagonal Hamiltonian class."""
"""
One-body diagonal Hamiltonian class. Diagonal Hamiltonians are defined as
those that are diagonal in the Slater determinant space, namely,
.. math::
\\langle I|\\hat{H}|J\\rangle = p \\delta_{IJ}
where I and J are Slater determinants, and p is some phase. Generally
such Hamiltonians can be written as
.. math::
\\hat{H} = = E_0 + \\sum_r h_{rr} a_r^\\dagger a_r
"""

def __init__(self, hdiag: np.array, e_0: complex = 0.0 + 0.0j) -> None:
def __init__(self, hdiag: 'Nparray', e_0: complex = 0.0 + 0.0j) -> None:
"""
Args:
hdiag: A variable length tuple containing between one and four
numpy.arrays of increasing rank. The tensors contain the n-body
Hamiltonian elements. Tensors up to the highest order must be
included even if the lower terms are full of zeros.
hdiag: A rank-1 numpy.array that contains the diagonal part of the
1-body Hamiltonian elements.
e_0: Scalar potential associated with the Hamiltonian.
"""

Expand Down

0 comments on commit bb02451

Please sign in to comment.