Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support periodic supercell CCSD and add bisection based Aufbau #8

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

basilib
Copy link
Contributor

@basilib basilib commented Nov 3, 2024

This PR adds:

  • Fix for periodic supercell MFs used to initialise the CCSD expression
  • A faster Aufbau solver, with tests
  • Use lib.einsum instead of np.einsum to calculate moments from a Lehmann object

Copy link

codecov bot commented Nov 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 66 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (8500e7f) to head (2d76cda).

Files with missing lines Patch % Lines
dyson/solvers/chempot.py 0.00% 39 Missing ⚠️
dyson/expressions/ccsd.py 0.00% 25 Missing ⚠️
dyson/lehmann.py 0.00% 1 Missing ⚠️
dyson/solvers/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master      #8   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files          27      27           
  Lines        2400    2451   +51     
======================================
- Misses       2400    2451   +51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@obackhouse obackhouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comments to address and then you can merge, lgtm, nice addition

@@ -120,6 +120,56 @@ def get_greens_function(self):
return self.gf.copy(chempot=self.chempot, deep=False)


class AufbauPrincipleBisect(AufbauPrinciple):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy the doc string for aesthetics (i know it inherits __doc__ but nicer to be able to read it in the source code). Maybe add another line saying this uses bisection

def _kernel(self):
energies = self.gf.energies
couplings_l, couplings_r = self.gf._unpack_couplings()
weights = self.gf.weights()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this is a stupid question, but self.gf.weight() is already O(nmo * naux), so is bisection only faster by virtue of vectorisation in calculating the weights? In the non-bisected algo you need O(nocc * naux) to calculate the weights but they're done one at a time so i can see how it would be less efficient in practice

lumo = homo + 1
chempot = 0.5 * (energies[homo] + energies[lumo])
except:
raise ValueError("Failed to find Fermi energy.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError("Failed to find Fermi energy.")
raise ValueError("Failed to find Fermi energy.")

@@ -9,7 +9,7 @@
from pyscf import gto, scf, agf2, lib
from dyson import CPGF, util

ncheb = 50 # Number of Chebyshev moments
ncheb = 100 # Number of Chebyshev moments
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this a mistake? not that it really matters but which value is best for the example?

solver_bisect.kernel()

assert np.allclose(solver.chempot, solver_bisect.chempot)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

gf = mblgf.get_greens_function()
nelec = 25

solver = AufbauPrinciple(gf, nelec, occupancy=2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
solver = AufbauPrinciple(gf, nelec, occupancy=2)
solver = AufbauPrinciple(gf, nelec, occupancy=2, log=NullLogger())

solver = AufbauPrinciple(gf, nelec, occupancy=2)
solver.kernel()

solver_bisect = AufbauPrincipleBisect(gf, nelec, occupancy=2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
solver_bisect = AufbauPrincipleBisect(gf, nelec, occupancy=2)
solver_bisect = AufbauPrincipleBisect(gf, nelec, occupancy=2, log=NullLogger())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants