Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of issue 70 #72

Merged
merged 2 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_I \\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_I \\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