Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung committed Nov 7, 2023
1 parent fdd35bc commit 688a5b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions python/ffsim/hamiltonians/double_factorized_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@dataclasses.dataclass(frozen=True)
class DoubleFactorizedHamiltonian:
r"""A Hamiltonian in the double-factorized form of the low rank decomposition.
r"""A Hamiltonian in the double-factorized representation.
The double-factorized form of the molecular Hamiltonian is
Expand Down Expand Up @@ -70,13 +70,21 @@ class DoubleFactorizedHamiltonian:
where the asterisk denotes summation over indices :math:`\sigma\tau, ij`
where :math:`\sigma \neq \tau` or :math:`i \neq j`.
References:
- `Low rank representations for quantum simulation of electronic structure`_
- `Quantum Filter Diagonalization with Double-Factorized Hamiltonians`_
Attributes:
one_body_tensor (np.ndarray): The one-body tensor :math:`\kappa`.
diag_coulomb_mats (np.ndarray): The diagonal Coulomb matrices.
orbital_rotations (np.ndarray): The orbital rotations.
constant (float): The constant.
z_representation (bool): Whether the Hamiltonian is in the "Z" representation
rather than the "number" representation.
.. _Low rank representations for quantum simulation of electronic structure: https://arxiv.org/abs/1808.02625
.. _Quantum Filter Diagonalization with Double-Factorized Hamiltonians: https://arxiv.org/abs/2104.08957
.. _scipy.optimize.minimize: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
"""

one_body_tensor: np.ndarray
Expand Down Expand Up @@ -155,7 +163,7 @@ def from_molecular_hamiltonian(
coefficients stored in the tensor to achieve a "compressed" factorization.
This option is enabled by setting the `optimize` parameter to `True`.
The optimization attempts to minimize a least-squares objective function
quantifying the error in the low rank decomposition.
quantifying the error in the decomposition.
It uses `scipy.optimize.minimize`_, passing both the objective function
and its gradient. The diagonal coulomb matrices returned by the optimization
can be optionally constrained to have only certain elements allowed to be
Expand All @@ -171,7 +179,7 @@ def from_molecular_hamiltonian(
hamiltonian: The Hamiltonian whose double-factorized representation to
compute.
z_representation: Whether to use the "Z" representation of the
low rank decomposition.
decomposition.
tol: Tolerance for error in the decomposition.
The error is defined as the maximum absolute difference between
an element of the original tensor and the corresponding element of
Expand All @@ -197,14 +205,6 @@ def from_molecular_hamiltonian(
Returns:
The double-factorized Hamiltonian.
References:
- `arXiv:1808.02625`_
- `arXiv:2104.08957`_
.. _arXiv:1808.02625: https://arxiv.org/abs/1808.02625
.. _arXiv:2104.08957: https://arxiv.org/abs/2104.08957
.. _scipy.optimize.minimize: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
"""
one_body_tensor = hamiltonian.one_body_tensor - 0.5 * np.einsum(
"prqr", hamiltonian.two_body_tensor
Expand Down
2 changes: 1 addition & 1 deletion python/ffsim/linalg/double_factorized_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def double_factorized(
coefficients stored in the tensor to achieve a "compressed" factorization.
This option is enabled by setting the `optimize` parameter to `True`.
The optimization attempts to minimize a least-squares objective function
quantifying the error in the low rank decomposition.
quantifying the error in the decomposition.
It uses `scipy.optimize.minimize`, passing both the objective function
and its gradient. The core tensors returned by the optimization can be optionally
constrained to have only certain elements allowed to be nonzero. This is achieved by
Expand Down
6 changes: 3 additions & 3 deletions tests/linalg/double_factorized_decomposition_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_modified_cholesky(dim: int):
"dim, cholesky", [(4, True), (4, False), (5, True), (5, False)]
)
def test_double_factorized_random(dim: int, cholesky: bool):
"""Test low rank two-body decomposition on a random tensor."""
"""Test double-factorized decomposition on a random tensor."""
two_body_tensor = random_two_body_tensor_real(dim, seed=9825)
diag_coulomb_mats, orbital_rotations = double_factorized(
two_body_tensor, cholesky=cholesky
Expand All @@ -87,7 +87,7 @@ def test_double_factorized_random(dim: int, cholesky: bool):

@pytest.mark.parametrize("cholesky", [True, False])
def test_double_factorized_tol_max_vecs(cholesky: bool):
"""Test low rank decomposition error threshold and max vecs."""
"""Test double-factorized decomposition error threshold and max vecs."""
mol = gto.Mole()
mol.build(
verbose=0,
Expand Down Expand Up @@ -282,7 +282,7 @@ def test_double_factorized_t2_amplitudes_random(norb: int, nocc: int):


def test_double_factorized_t2_tol_max_vecs():
"""Test low rank decomposition error threshold and max vecs."""
"""Test double-factorized decomposition error threshold and max vecs."""
mol = gto.Mole()
mol.build(
verbose=0,
Expand Down

0 comments on commit 688a5b5

Please sign in to comment.