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

Merged
merged 19 commits into from
Dec 10, 2024
Merged

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 65 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (8500e7f) to head (8a4afee).
Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
dyson/solvers/chempot.py 0.00% 38 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    2450   +50     
======================================
- Misses       2400    2450   +50     

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

@basilib basilib requested a review from obackhouse November 29, 2024 18:42
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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's just a prefactor improvement. However since the python loop is now log(N) it ends up being quite faster for larger problems. Performance can vary due to the ratio between MOs and couplings as well as where the Fermi level is. I implemented this for embedding where the number of auxiliaries becomes far greater than the number of MOs, particularly in solids.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a mistake. I didn't realize I committed the change.

@basilib basilib merged commit 5ac355d into master Dec 10, 2024
3 checks passed
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