Skip to content

Conversation

@JaafarMehrez
Copy link
Member

This pull request is supposed to add an SCF convergence criteria called 'ddm_tol' as a threshold for the difference in density matrix between two cycles.

if callable(mf.check_convergence):
scf_conv = mf.check_convergence(locals())
elif abs(e_tot-last_hf_e) < conv_tol or norm_gorb < conv_tol_grad:
elif abs(e_tot-last_hf_e) < conv_tol or norm_gorb < conv_tol_grad or norm_ddm < ddm_tol:
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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.

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