-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from all commits
d60e1b7
121cd53
148ec49
d4fcd13
7018ca5
e920c2b
41e8bb6
cbf7b13
2648772
e54ed1c
7199a87
893b32e
2d76cda
a6e3550
3c0f392
f1bb2ab
ae9c7ad
010efb3
8a4afee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -120,6 +120,71 @@ def get_greens_function(self): | |||||||
return self.gf.copy(chempot=self.chempot, deep=False) | ||||||||
|
||||||||
|
||||||||
class AufbauPrincipleBisect(AufbauPrinciple): | ||||||||
""" | ||||||||
Fill a series of orbitals according to the Aufbau principle using a bisection algorithim. | ||||||||
|
||||||||
Parameters | ||||||||
---------- | ||||||||
*args : tuple | ||||||||
Input arguments. Either `(gf, nelec)` or `(fock, se, nelec)` | ||||||||
where `gf` is the Lehmann representation of the Green's | ||||||||
function, `fock` is the Fock matrix, `se` is the Lehmann | ||||||||
representation of the self-energy and `nelec` is the number | ||||||||
of electrons in the physical space. | ||||||||
occupancy : int, optional | ||||||||
Occupancy of each state, i.e. `2` for a restricted reference | ||||||||
and `1` for other references. Default value is `2`. | ||||||||
""" | ||||||||
|
||||||||
def _kernel(self): | ||||||||
energies = self.gf.energies | ||||||||
weights = self.gf.weights() | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this is a stupid question, but There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||
low, high = 0, self.gf.naux | ||||||||
mid = high // 2 | ||||||||
for iter in range(100): | ||||||||
sum = self.occupancy * weights[:mid].sum() | ||||||||
self.log.debug("Number of electrons [0:%d] = %.6f", iter + 1, sum) | ||||||||
if sum < self.nelec: | ||||||||
low = mid | ||||||||
mid = mid + (high - low) // 2 | ||||||||
else: | ||||||||
high = mid | ||||||||
mid = mid - (high - low) // 2 | ||||||||
|
||||||||
if low == mid or high == mid: | ||||||||
break | ||||||||
|
||||||||
n_low, n_high = self.occupancy * weights[:low].sum(), self.occupancy * weights[:high].sum() | ||||||||
|
||||||||
if abs(n_low - self.nelec) < abs(n_high - self.nelec): | ||||||||
homo = low - 1 | ||||||||
error = self.nelec - n_low | ||||||||
else: | ||||||||
homo = high - 1 | ||||||||
error = self.nelec - n_high | ||||||||
|
||||||||
try: | ||||||||
lumo = homo + 1 | ||||||||
chempot = 0.5 * (energies[homo] + energies[lumo]) | ||||||||
except: | ||||||||
raise ValueError("Failed to find Fermi energy.") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
self.log.info("HOMO LUMO %s %s" % (homo, lumo)) | ||||||||
self.log.info("HOMO = %.6f", energies[homo]) | ||||||||
self.log.info("LUMO = %.6f", energies[lumo]) | ||||||||
self.log.info("Chemical potential = %.6f", chempot) | ||||||||
self.log.info("Error in nelec = %.3g", error) | ||||||||
|
||||||||
self.converged = True | ||||||||
self.homo = energies[homo] | ||||||||
self.lumo = energies[lumo] | ||||||||
self.chempot = chempot | ||||||||
self.error = error | ||||||||
|
||||||||
return chempot, error | ||||||||
|
||||||||
|
||||||||
class AuxiliaryShift(BaseSolver): | ||||||||
""" | ||||||||
Shift the self-energy auxiliaries with respect to the Green's | ||||||||
|
There was a problem hiding this comment.
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