Skip to content
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
5 changes: 1 addition & 4 deletions dyson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@
* - :data:`~dyson.expressions.adc.ADC2x`
- Algebraic diagrammatic construction extended second order excited states, based on a
mean-field ground state.
* - :data:`~dyson.expressions.gw.TDAGW`
- GW theory with the Tamm--Dancoff approximation for the excited states, based on a
mean-field ground state.
* - :data:`~dyson.expressions.hamiltonian.Hamiltonian`
- General Hamiltonian expression, which accepts an array representing the supermatrix of the
self-energy, and supports :mod:`scipy.sparse` matrices.
Expand Down Expand Up @@ -139,4 +136,4 @@
CorrectionVector,
CPGF,
)
from dyson.expressions import HF, CCSD, FCI, ADC2, ADC2x, TDAGW, Hamiltonian
from dyson.expressions import HF, CCSD, FCI, ADC2, ADC2x, Hamiltonian
2 changes: 0 additions & 2 deletions dyson/expressions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
ccsd
fci
adc
gw
hamiltonian

"""
Expand All @@ -90,5 +89,4 @@
from dyson.expressions.ccsd import CCSD
from dyson.expressions.fci import FCI
from dyson.expressions.adc import ADC2, ADC2x
from dyson.expressions.gw import TDAGW
from dyson.expressions.hamiltonian import Hamiltonian
2 changes: 1 addition & 1 deletion dyson/expressions/adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def mol(self) -> Mole:
@property
def non_dyson(self) -> bool:
"""Whether the expression produces a non-Dyson Green's function."""
return False
return True


class BaseADC_1h(BaseADC):
Expand Down
31 changes: 22 additions & 9 deletions dyson/expressions/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from pyscf.gto.mole import Mole
from pyscf.scf.hf import RHF
from typing_extensions import Self

from dyson.typing import Array

Expand All @@ -33,7 +34,7 @@ class BaseExpression(ABC):

@classmethod
@abstractmethod
def from_mf(cls, mf: RHF) -> BaseExpression:
def from_mf(cls, mf: RHF) -> Self:
"""Create an expression from a mean-field object.

Args:
Expand Down Expand Up @@ -398,6 +399,25 @@ def build_se_moments(self, nmom: int, reduction: Reduction = Reduction.NONE) ->
"""
pass

def build_overlap(self, reduction: Reduction = Reduction.NONE) -> Array:
"""Build the matrix representing the overlap of the excitation vectors.

Args:
reduction: Reduction to apply to the overlap.

Returns:
Overlap matrix.

Notes:
The overlap matrix is equal to the zeroth moment of the Green's function.
"""
return self.build_gf_moments(
1,
store_vectors=True,
left=False,
reduction=reduction,
)[0]

@property
@abstractmethod
def mol(self) -> Mole:
Expand Down Expand Up @@ -464,10 +484,6 @@ def __getattr__(cls, key: str) -> type[BaseExpression]:
if cls._particle is None:
raise ValueError("Particle expression is not set.")
return cls._particle
elif key in {"central", "dyson"}:
if cls._dyson is None:
raise ValueError("Central (Dyson) expression is not set.")
return cls._dyson
elif key in {"neutral", "ee", "ph"}:
if cls._neutral is None:
raise ValueError("Neutral expression is not set.")
Expand All @@ -480,9 +496,7 @@ def __getattr__(cls, key: str) -> type[BaseExpression]:
@property
def _classes(cls) -> set[type[BaseExpression]]:
"""Get all classes in the collection."""
return {
cls for cls in [cls._hole, cls._particle, cls._dyson, cls._neutral] if cls is not None
}
return {cls for cls in [cls._hole, cls._particle, cls._neutral] if cls is not None}

def __contains__(cls, key: str) -> bool:
"""Check if an expression exists by its name."""
Expand All @@ -498,7 +512,6 @@ class ExpressionCollection(metaclass=_ExpressionCollectionMeta):

_hole: type[BaseExpression] | None = None
_particle: type[BaseExpression] | None = None
_dyson: type[BaseExpression] | None = None
_neutral: type[BaseExpression] | None = None
_name: str | None = None

Expand Down
252 changes: 0 additions & 252 deletions dyson/expressions/gw.py

This file was deleted.

Loading