-
Notifications
You must be signed in to change notification settings - Fork 21
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
Nuclear Gradients #124
base: master
Are you sure you want to change the base?
Nuclear Gradients #124
Conversation
This pull request introduces 1 alert when merging 6b92a09 into 6e7ac34 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 7136d03 into 6e7ac34 - view on LGTM.com new alerts:
|
Awesome 👍 |
This pull request introduces 1 alert when merging 844cc1c into 6e7ac34 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 10980bf into 6e7ac34 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 3f82618 into 6e7ac34 - view on LGTM.com new alerts:
|
3f82618
to
b92ee1b
Compare
This pull request introduces 1 alert when merging b92ee1b into 041cdcb - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 1a3c802 into 041cdcb - view on LGTM.com new alerts:
|
1717c34
to
54a9181
Compare
This pull request introduces 1 alert when merging 54a9181 into e4ca2ed - view on LGTM.com new alerts:
|
6e67a9d
to
365cd5a
Compare
This pull request introduces 4 alerts when merging 92e7535 into e4ca2ed - view on LGTM.com new alerts:
|
This pull request introduces 4 alerts when merging df675fa into e4ca2ed - view on LGTM.com new alerts:
|
f3cd5f2
to
c16ff2b
Compare
Of course tests need to work and all, but I wonder if a good first aim is to just get the things already implemented merged into master and release a new version? |
The tests are horrible to implement... ensuring highly converged eigenvectors is difficult 😞 but in principle all the implemented gradient methods are correct 👍🏻 |
Not sure if this is a good suggestion, but maybe we could run a couple of small molecules and save the results in a text file for pytest to compare agains (this is more or less how it's done in veloxchem). I can try out the cvs-adc gradients and find an optimal/good enough setup (I guess the question is of comparing analytical vs. numerical gradients) |
The generation of finite-difference reference data works fine already, for both generic and CVS-ADC 😊👍🏻 |
Can't you lower to tolerance or introduce perturbations in the molecule / orbitals to ensure they are sufficiently distinct (to avoid rotations in invariant subspaces etc.) |
You mean the convergence tolerance/ You mean geometry perturbations to break symmetries? Yes, I can try that for sure 👍🏻 |
Yes. It's not amazing, but it will at least catch forgotten factors of two or switched signs. |
c16ff2b
to
d52ac16
Compare
@iubr, the CVS-ADC2-x don't seem to be correct right now, at least I get an error for H2O of ~1e-5 (compared to 5-point finite differences). Maybe I made some mistake while cleaning up the code... Which accuracy could you obtain in your tests? I'll try to run your original branch again at some point to get to the bottom of this. |
The ~1e-5 is similar to what I get with my code (in comparison to the 2-point finite difference numerical gradient). I checked it today with a 5-point finite difference and it is a little smaller, but still same order (1e-5). So if there is a bug, it would be in my module as well. |
I converge the SCF to 1e-12, and the ADC procedure is converged to 1e-10 in the energy. Given the fact that all other gradient methods so far can achieve at least 1e-7 accuracy, I'm convinced that one can achieve the same for CVS-ADC2-x . I'll try to add canonical ADC2-x gradients now and see how accurate one can get. |
Thanks a lot! |
Thanks for the script, I'll have a look. |
Thanks! If you'd like an overview of the density matrices, they are from https://doi.org/10.1063/5.0058221, Appendix C, Table II, 3rd column (ADC matrix terms). |
Hi Max, I just found the bug! It was a sign in one of the terms for the right-hand-side of the CV block, lambda multipliers. See here. /Iulia |
That's great news! I will try it out later. 👍🏻😊 |
Thank you!! Let me know how it goes :D |
I found the reason for the weird factor 2 behavior in this I found some other inconsistencies in the formation of |
06ee1b2
to
51115ed
Compare
Cool! Great work. |
Wonderful ^-^!! Thanks a lot @maxscheurer!! |
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.
Just a few comments ... obviously I have not at all checked the equations.
# with pytest.raises(InputError): | ||
# obtain_guesses_by_inspection(matrix1, n_guesses=40, kind="any") |
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.
Could change this to a test for the warning.
molecules = [ | ||
Molecule("h2o", 0, 1), | ||
] |
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.
molecules = [ | |
Molecule("h2o", 0, 1), | |
] | |
molecules = [Molecule("h2o")] |
g2_ao_1, g2_ao_2: relaxed two-particle density matrices | ||
""" | ||
natoms = self.mol.natom() | ||
Gradient = {} |
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.
Why capitalised?
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.
Shamelessly copied from some psi4numpy
tutorial, will change this 😄
# Build Total OEI Gradient | ||
Gradient["OEI"] = Gradient["T"] + Gradient["V"] + Gradient["S"] | ||
|
||
# Build TE contributions |
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.
TEI contributions?
@dataclass(frozen=True) | ||
class GradientComponents: | ||
natoms: int | ||
nuc: np.ndarray |
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.
Nuc is a bit short, maybe add a comment here to explain
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.
Good idea, I think it would be good to make all attribute names a bit more verbose.
nuc: np.ndarray | ||
overlap: np.ndarray | ||
hcore: np.ndarray | ||
two_electron: np.ndarray |
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.
comment: Two electron integrals?
return self.excitation_or_mp.reference_state | ||
|
||
@property | ||
def _energy(self): |
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.
Why the underscore? If someone uses it it's sort of their fault, no? If you add a warning I think that's fine.
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.
Good point. Will rename it to correlation_energy
or so to make it more clear what exactly is returned.
lam = conjugate_gradient(A, rhs=rhs, x0=x0, Pinv=Pinv, | ||
explicit_symmetrisation=None, | ||
callback=default_print) |
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.
Which tolerance is used and why? Should for sure be related to the convergence used for the ADC excitation vectors ... or maybe aim for relative residual decrease?
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.
I think it should rather be related to the SCF convergence criterion, because we compute the response of the HF ground state (kind of 😄). In addition, MP states don't have an additional convergence criterion, so I will make this depend on the SCF conv tol. 👍
fix dot product issue for bare tensors add working gradient implementation add gradient provider to pyscf flake fix excitation view tests
lgtm and coveralls (hopefully) more fdiff fix
hijacked AmplitudeVector for CVS-ADC orbital response. CVS-ADC0 working! cvs-adc1 working
added cvs-adc2 2PDMs,started orbital response (need to check if the RHS is correct) cvs-adc2 gradient working. cvs-adc2x working
… vs. cvs-adc rhs. fixed 1/sqrt(2) additional comments, RHS switched to using symmetrise and antisymmetrise to construct density matrices
c1c0db5
to
65bfcc3
Compare
Implemented together with @Drrehn.
Features
ToDo
calculations.rst
)add equation numbers from papers (Rehn 2019, Levchenko 2005)