Skip to content

Commit

Permalink
Merge branch 'master' into bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
obackhouse committed Aug 9, 2024
2 parents 3b3cc9e + bce6305 commit 6b5d316
Show file tree
Hide file tree
Showing 30 changed files with 204 additions and 1,428 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ 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
- uses: actions/cache@v2
with:
key: ${{ github.ref }}
path: .cache
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -39,12 +43,22 @@ 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
- name: Deploy documentation
run: mkdocs gh-deploy --force -f docs/mkdocs.yaml
if: matrix.documentation && github.ref == 'refs/heads/master'
4 changes: 4 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{%
include-markdown "../FEATURES.md"
%}

28 changes: 28 additions & 0 deletions docs/gen_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Generate the code reference pages.
"""

from pathlib import Path

import mkdocs_gen_files


for path in sorted(Path("ebcc").rglob("*.py")):
module_path = path.relative_to("ebcc").with_suffix("")
doc_path = path.relative_to("ebcc").with_suffix(".md")
full_doc_path = Path("reference", doc_path)
parts = ["ebcc", *module_path.parts]

if parts[-1] == "__init__":
parts = parts[:-1]
doc_path = doc_path.with_name("index.md")
full_doc_path = full_doc_path.with_name("index.md")

if not len(parts) or parts[-1] == "__main__" or parts[0] == "codegen":
continue

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
identifier = ".".join(parts)
fd.write("::: " + identifier + "\n")

mkdocs_gen_files.set_edit_path(full_doc_path, path)
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%
include-markdown "../README.md"
%}
71 changes: 71 additions & 0 deletions docs/mkdocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
site_name: ebcc

watch:
- ../ebcc

theme:
name: readthedocs

docs_dir: .

site_dir: ../site

plugins:
- search
- gen-files:
scripts:
- gen_files.py
- section-index
- include-markdown
- mkdocstrings:
default_handler: python
handlers:
python:
rendering:
show_source: false
options:
docstring_style: google
members_order: source
line_length: 100
merge_init_into_class: true
show_if_no_docstring: false
show_root_members_full_path: true
show_object_full_path: true

nav:
- Home: "index.md"
- Features: "features.md"
- Code Reference:
- Coupled cluster:
- Restricted: reference/cc/rebcc.md
- Unrestricted: reference/cc/uebcc.md
- Generalised: reference/cc/gebcc.md
- Base: reference/cc/base.md
- Equation of motion:
- Restricted: reference/eom/reom.md
- Unrestricted: reference/eom/ueom.md
- Generalised: reference/eom/geom.md
- Base: reference/eom/base.md
- Orbital optimisation:
- Brueckner:
- Restricted: reference/opt/rbrueckner.md
- Unrestricted: reference/opt/ubrueckner.md
- Generalised: reference/opt/gbrueckner.md
- Base: reference/opt/base.md
- Core:
- Ansatz: reference/core/ansatz.md
- Damping: reference/core/damping.md
- Dumping: reference/core/dump.md
- Logging: reference/core/logging.md
- Precision: reference/core/precision.md
- Hamiltonian:
- Space: reference/ham/space.md
- Fock: reference/ham/fock.md
- ERIs: reference/ham/eris.md
- CDERIs: reference/ham/cderis.md
- Bosonic: reference/ham/elbos.md
- Base: reference/ham/base.md
- Utility:
- Permutations: reference/util/permutations.md
- Einstein summations: reference/util/einsumfunc.md
- Miscellaneous: reference/util/misc.md
164 changes: 1 addition & 163 deletions ebcc/cc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,7 @@ class BaseOptions:


class BaseEBCC(ABC):
"""Base class for electron-boson coupled cluster.
Attributes:
mf: PySCF mean-field object.
log: Log to write output to.
options: Options for the EBCC calculation.
e_corr: Correlation energy.
amplitudes: Cluster amplitudes.
converged: Convergence flag.
lambdas: Cluster lambda amplitudes.
converged_lambda: Lambda convergence flag.
name: Name of the method.
"""
"""Base class for electron-boson coupled cluster."""

# Types
Options: type[BaseOptions] = BaseOptions
Expand Down Expand Up @@ -875,156 +863,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
14 changes: 1 addition & 13 deletions ebcc/cc/gebcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,7 @@


class GEBCC(BaseEBCC):
"""Restricted electron-boson coupled cluster.
Attributes:
mf: PySCF mean-field object.
log: Log to write output to.
options: Options for the EBCC calculation.
e_corr: Correlation energy.
amplitudes: Cluster amplitudes.
converged: Convergence flag.
lambdas: Cluster lambda amplitudes.
converged_lambda: Lambda convergence flag.
name: Name of the method.
"""
"""Restricted electron-boson coupled cluster."""

# Types
ERIs = GERIs
Expand Down
14 changes: 1 addition & 13 deletions ebcc/cc/rebcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,7 @@


class REBCC(BaseEBCC):
"""Restricted electron-boson coupled cluster.
Attributes:
mf: PySCF mean-field object.
log: Log to write output to.
options: Options for the EBCC calculation.
e_corr: Correlation energy.
amplitudes: Cluster amplitudes.
converged: Convergence flag.
lambdas: Cluster lambda amplitudes.
converged_lambda: Lambda convergence flag.
name: Name of the method.
"""
"""Restricted electron-boson coupled cluster."""

# Types
ERIs = RERIs
Expand Down
14 changes: 1 addition & 13 deletions ebcc/cc/uebcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,7 @@


class UEBCC(BaseEBCC):
"""Unrestricted electron-boson coupled cluster.
Attributes:
mf: PySCF mean-field object.
log: Log to write output to.
options: Options for the EBCC calculation.
e_corr: Correlation energy.
amplitudes: Cluster amplitudes.
converged: Convergence flag.
lambdas: Cluster lambda amplitudes.
converged_lambda: Lambda convergence flag.
name: Name of the method.
"""
"""Unrestricted electron-boson coupled cluster."""

# Types
ERIs = UERIs
Expand Down
Loading

0 comments on commit 6b5d316

Please sign in to comment.