Skip to content

Commit

Permalink
Merge pull request #71 from BoothGroup/nuke_moments
Browse files Browse the repository at this point in the history
Remove moments
  • Loading branch information
obackhouse authored Aug 9, 2024
2 parents c4c4133 + f25d921 commit 7a06aba
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 1,201 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
fail-fast: false
matrix:
include:
- {python-version: "3.9", os: ubuntu-latest, documentation: True}
- {python-version: "3.10", os: ubuntu-latest, documentation: False}
- {python-version: "3.11", os: ubuntu-latest, documentation: False}
- {python-version: "3.12", os: ubuntu-latest, documentation: False}
- {python-version: "3.9", os: ubuntu-latest, documentation: True, coverage: True}
- {python-version: "3.10", os: ubuntu-latest, documentation: False, coverage: True}
- {python-version: "3.11", os: ubuntu-latest, documentation: False, coverage: True}
- {python-version: "3.12", os: ubuntu-latest, documentation: False, coverage: False}

steps:
- uses: actions/checkout@v2
Expand All @@ -39,12 +39,19 @@ jobs:
python -m isort ebcc/ --diff --check-only --verbose
python -m flake8 ebcc/ --verbose
python -m mypy ebcc/ --verbose
- name: Run unit tests
- name: Run unit tests with coverage
run: |
python -m pip install pytest pytest-cov
pytest --cov ebcc/
if: matrix.coverage
- name: Run unit tests
run: |
python -m pip install pytest
pytest
if: ${{ ! matrix.coverage }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
if: matrix.coverage
150 changes: 0 additions & 150 deletions ebcc/cc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,156 +875,6 @@ def hbar_matvec_ee(
res = util.Namespace(**{key.rstrip("new"): val for key, val in res.items()})
return res

def make_ip_mom_bras(
self,
eris: Optional[ERIsInputType] = None,
amplitudes: Optional[Namespace[SpinArrayType]] = None,
lambdas: Optional[Namespace[SpinArrayType]] = None,
) -> tuple[SpinArrayType, ...]:
"""Get the bra vectors to construct IP-EOM moments.
Args:
eris: Electron repulsion integrals.
amplitudes: Cluster amplitudes.
lambdas: Cluster lambda amplitudes.
Returns:
Bra vectors for IP-EOM moments.
"""
func, kwargs = self._load_function(
"make_ip_mom_bras",
eris=eris,
amplitudes=amplitudes,
lambdas=lambdas,
)
res: tuple[SpinArrayType, ...] = func(**kwargs)
return res

def make_ea_mom_bras(
self,
eris: Optional[ERIsInputType] = None,
amplitudes: Optional[Namespace[SpinArrayType]] = None,
lambdas: Optional[Namespace[SpinArrayType]] = None,
) -> tuple[SpinArrayType, ...]:
"""Get the bra vectors to construct EA-EOM moments.
Args:
eris: Electron repulsion integrals.
amplitudes: Cluster amplitudes.
lambdas: Cluster lambda amplitudes.
Returns:
Bra vectors for EA-EOM moments.
"""
func, kwargs = self._load_function(
"make_ea_mom_bras",
eris=eris,
amplitudes=amplitudes,
lambdas=lambdas,
)
res: tuple[SpinArrayType, ...] = func(**kwargs)
return res

def make_ee_mom_bras(
self,
eris: Optional[ERIsInputType] = None,
amplitudes: Optional[Namespace[SpinArrayType]] = None,
lambdas: Optional[Namespace[SpinArrayType]] = None,
) -> tuple[SpinArrayType, ...]:
"""Get the bra vectors to construct EE-EOM moments.
Args:
eris: Electron repulsion integrals.
amplitudes: Cluster amplitudes.
lambdas: Cluster lambda amplitudes.
Returns:
Bra vectors for EE-EOM moments.
"""
func, kwargs = self._load_function(
"make_ee_mom_bras",
eris=eris,
amplitudes=amplitudes,
lambdas=lambdas,
)
res: tuple[SpinArrayType, ...] = func(**kwargs)
return res

def make_ip_mom_kets(
self,
eris: Optional[ERIsInputType] = None,
amplitudes: Optional[Namespace[SpinArrayType]] = None,
lambdas: Optional[Namespace[SpinArrayType]] = None,
) -> tuple[SpinArrayType, ...]:
"""Get the ket vectors to construct IP-EOM moments.
Args:
eris: Electron repulsion integrals.
amplitudes: Cluster amplitudes.
lambdas: Cluster lambda amplitudes.
Returns:
Ket vectors for IP-EOM moments.
"""
func, kwargs = self._load_function(
"make_ip_mom_kets",
eris=eris,
amplitudes=amplitudes,
lambdas=lambdas,
)
res: tuple[SpinArrayType, ...] = func(**kwargs)
return res

def make_ea_mom_kets(
self,
eris: Optional[ERIsInputType] = None,
amplitudes: Optional[Namespace[SpinArrayType]] = None,
lambdas: Optional[Namespace[SpinArrayType]] = None,
) -> tuple[SpinArrayType, ...]:
"""Get the ket vectors to construct EA-EOM moments.
Args:
eris: Electron repulsion integrals.
amplitudes: Cluster amplitudes.
lambdas: Cluster lambda amplitudes.
Returns:
Ket vectors for EA-EOM moments.
"""
func, kwargs = self._load_function(
"make_ea_mom_kets",
eris=eris,
amplitudes=amplitudes,
lambdas=lambdas,
)
res: tuple[SpinArrayType, ...] = func(**kwargs)
return res

def make_ee_mom_kets(
self,
eris: Optional[ERIsInputType] = None,
amplitudes: Optional[Namespace[SpinArrayType]] = None,
lambdas: Optional[Namespace[SpinArrayType]] = None,
) -> tuple[SpinArrayType, ...]:
"""Get the ket vectors to construct EE-EOM moments.
Args:
eris: Electron repulsion integrals.
amplitudes: Cluster amplitudes.
lambdas: Cluster lambda amplitudes.
Returns:
Ket vectors for EE-EOM moments.
"""
func, kwargs = self._load_function(
"make_ee_mom_kets",
eris=eris,
amplitudes=amplitudes,
lambdas=lambdas,
)
res: tuple[SpinArrayType, ...] = func(**kwargs)
return res

@abstractmethod
def energy_sum(self, *args: str, signs_dict: Optional[dict[str, str]] = None) -> NDArray[float]:
"""Get a direct sum of energies.
Expand Down
51 changes: 1 addition & 50 deletions ebcc/eom/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ebcc.core.precision import types

if TYPE_CHECKING:
from typing import Any, Callable, Optional, Union
from typing import Any, Callable, Optional

from ebcc.cc.base import BaseEBCC, ERIsInputType, SpaceType, SpinArrayType
from ebcc.core.ansatz import Ansatz
Expand Down Expand Up @@ -171,34 +171,6 @@ def diag(self, eris: Optional[ERIsInputType] = None) -> NDArray[float]:
"""
pass

@abstractmethod
def bras(self, eris: Optional[ERIsInputType] = None) -> Namespace[SpinArrayType]:
"""Get the bra vectors.
Args:
eris: Electronic repulsion integrals.
Returns:
Bra vectors.
"""
pass

@abstractmethod
def kets(self, eris: Optional[ERIsInputType] = None) -> Namespace[SpinArrayType]:
"""Get the ket vectors.
Args:
eris: Electronic repulsion integrals.
Returns:
Ket vectors.
"""
pass

def dot_braket(self, bra: NDArray[float], ket: NDArray[float]) -> Union[float, NDArray[float]]:
"""Compute the dot product of a bra and ket."""
return np.dot(bra, ket)

def get_pick(
self, guesses: Optional[NDArray[float]] = None, real_system: bool = True
) -> PickFunctionType:
Expand Down Expand Up @@ -353,27 +325,6 @@ def davidson(

kernel = davidson

@abstractmethod
def moments(
self,
nmom: int,
eris: Optional[ERIsInputType] = None,
amplitudes: Optional[Namespace[SpinArrayType]] = None,
hermitise: bool = True,
) -> SpinArrayType:
"""Construct the moments of the EOM Hamiltonian.
Args:
nmom: Number of moments.
eris: Electronic repulsion integrals.
amplitudes: Cluster amplitudes.
hermitise: Hermitise the moments.
Returns:
Moments of the EOM Hamiltonian.
"""
pass

@property
def nmo(self) -> Any:
"""Get the number of MOs."""
Expand Down
Loading

0 comments on commit 7a06aba

Please sign in to comment.