Skip to content

Commit

Permalink
Merge pull request #6 from BoothGroup/ccsd_lmatvec
Browse files Browse the repository at this point in the history
Support imaginary frequency grids
  • Loading branch information
basilib authored Aug 13, 2024
2 parents 2ac9352 + fb398e9 commit 3e6d6fe
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dyson/expressions/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def build_gf_moments(self, nmom, store_vectors=True, left=False):
u = apply_hamiltonian(u)

if left:
t = t.transpose(1, 2).conj()
t = t.transpose(0, 2, 1).conj()

return t

Expand Down
17 changes: 13 additions & 4 deletions dyson/lehmann.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,21 +447,25 @@ def as_perturbed_mo_energy(self):

return mo_energy

def on_grid(self, grid, eta=1e-1, ordering="time-ordered"):
def on_grid(self, grid, eta=1e-1, ordering="time-ordered", axis="real"):
"""
Return the Lehmann representation realised on a real frequency
Return the Lehmann representation realised on a frequency
grid.
Parameters
----------
grid : numpy.ndarray
Array of real frequency points.
Array of frequency points.
eta : float, optional
Broadening parameter. Default value is `1e-1`.
Only relevant for real axis.
ordering : str, optional
Time ordering. Can be one of `{"time-ordered",
"advanced", "retarded"}`. Default value is
`"time-ordered"`.
axis : str, optional
Frequency axis. Can be one of `{"real", "imag"}`. Default
value is `"real"`.
Returns
-------
Expand All @@ -480,7 +484,12 @@ def on_grid(self, grid, eta=1e-1, ordering="time-ordered"):

couplings_l, couplings_r = self._unpack_couplings()

denom = 1.0 / lib.direct_sum("w+k-k->wk", grid, signs * 1.0j * eta, self.energies)
if axis == "real":
denom = 1.0 / lib.direct_sum("w+k-k->wk", grid, signs * 1.0j * eta, self.energies)
elif axis == "imag":
denom = 1.0 / lib.direct_sum("w-k->wk", 1j * grid, self.energies)
else:
raise ValueError("axis = {}".format(axis))
f = lib.einsum("pk,qk,wk->wpq", couplings_l, couplings_r.conj(), denom)

return f
Expand Down
16 changes: 9 additions & 7 deletions dyson/util/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ def build_block_tridiagonal(on_diagonal, off_diagonal_upper, off_diagonal_lower=
m = np.block(
[
[
on_diagonal[i]
if i == j
else off_diagonal_upper[j]
if j == i - 1
else off_diagonal_lower[i]
if i == j - 1
else zero
(
on_diagonal[i]
if i == j
else (
off_diagonal_upper[j]
if j == i - 1
else off_diagonal_lower[i] if i == j - 1 else zero
)
)
for j in range(len(on_diagonal))
]
for i in range(len(on_diagonal))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ build-backend = "setuptools.build_meta"

[project.optional-dependencies]
dev = [
"black==23.1.0",
"black>=22.6.0",
"isort>=5.10.1",
"coverage[toml]",
"pytest",
Expand Down

0 comments on commit 3e6d6fe

Please sign in to comment.