forked from pyscf/pyscf
-
Notifications
You must be signed in to change notification settings - Fork 4
Add ddm_tol as convergence threshold for density matrix #4
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
Open
JaafarMehrez
wants to merge
1
commit into
HPQC-LABS:master
Choose a base branch
from
JaafarMehrez:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 see that we are using norm_ddm which is numpy.linalg.norm(ddm - ddm_last), which is the Frobenius norm of "ddm - ddm_last". This is different from CFOUR which prints the largest density difference.
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 suppose that the (largest density difference) printed out in CFOUR is the largest element-wise change in the density matrix between iterations. Is that what you are referring to? In this case we could define 'max_ddm = numpy.max(numpy.abs(ddm))' and add that to the convergence criteria instead of norm_ddm.
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 should mention that I have previously tried using the RMS of the density difference with 'rms_ddm = numpy.sqrt(numpy.mean(numpy.square(ddm)))'.
Compared to 'max_ddm' and 'norm_ddm', I was able to achieve tighter convergence using rms_ddm.
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.
@JaafarMehrez yes, when I saw "largest density difference" printed, I always assumed that it was the largest element-wise change in the density matrix between the current iteration and the previous one.
I don't know what you mean by "tighter convergence using rms_ddm". How are you measuring how tight the convergence is? Do you mean that rms_ddm converged to a smaller number than max_ddm did when you tried max_ddm? If max_ddm is 10^-16, then all the other ddm elements will be smaller than 10^-16, which means that rms_ddm will also be small.
The main suggestion I had for you here, was to ensure that PySCF can converge SCF calculations in the same way that more established software such as CFOUR can do it. I recall that you had mentioned on Discord that we can already use the same criterion as MRCC uses.
I have found that in CFOUR, the "largest density difference" cannot be converged as much when we use bigger and bigger basis sets, and this makes it very hard to do the types of calculations that I like to do. However, "largest density difference" seems to be an extremely good criterion because if the "largest density difference" is small, then all other elements of ddm must also be small, meaning that rms and other measures are also likely to be small. Often it took me thousands or tens of thousands of iterations to get the "largest density difference" to be as small as I wanted it to be, but when you do get "largest density difference" converged to a small value, I think you can be very sure that the SCF is very well-converged.
I think a combination of these convergence criteria will be the best thing to use in the long run. Maybe we can try to converge the "largest density difference" until a certain number of iterations is reached, then switch to another traditional convergence criterion if "largest density difference" is not converging after a certain point. These thresholds can be defined by the user, but can also be set to decent default values by the programmer.
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.
Unfortunately there are now "conflicts" that need to be resolved in order for this pull request to get merged into its upstream branch. Since 4 months have passed since this pull request was made, it is not too surprising that scf/hf.py has changed.