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
DM21 convergence problem for elongated bonds #316
Comments
I think the scf convergence related issue is related to the wavefunction that pyscf is construting. I ran the DM21 calculations using the same settings that have been posted originally. I see that the SCF oscillates, and does not converge. mol = gto.Mole() Output: I believe that issue with SCF convergence might be solved by switching from DIIS to a second-order method but pyscf results in: File "/home/vsinha/pyscf_tests/pyscf/pyscf/dft/numint.py", line 1889, in cache_xc_kernel when the newton() method is used with DM21. I find it interesting that DM21 kind of beats DFT at predicting the wavefunction state for homolytic cleavage of H2. DFT without Broken-Symmetry formalism, predicts a dissociated H- and H+ (hydride and proton) pair, placing both electrons on one of the H atoms. DM21m and DM21mc should be checked for the S2 they predict. |
I also noted that the energy predicted by DM21 is quite high compared to FCI, DM21m and D21mc |
I used the broken-symmetry method by flipping spin on one of the H atoms in pyscf. For B3LYP it works fine and gives energy and S^2 values similar to Orca. mol = gto.Mole() converge high-spin calculation firstmf = scf.UKS(mol) run low spin calc nowmf = scf.UKS(mol) DM21#dm0 = mf.make_rdm1() mol.spin = 0 ... |
btw I also tried to first converge triplet state using DM21 and then flip the spin and do a singlet calculation. But there perhaps the vaues inthe 1e- RDM are very small and the initial energy is NaN, and the pyscf run raises: |
Fraction occupation does not give the Broken-Symmetry slution for B3LYP. Without level-shifting fractional occupation calculation diverges for DM21. mol = gto.Mole() DM21dm0 = mf.make_rdm1() |
with level shifting with DM21, I also noticed that the difference in SCF energy in the last SCF cycle, and in the extra scf cycle which is performed to check convergence is rather large.: cycle= 19 E= -0.976695381817214 delta_E= 3.87e-09 |g|= 1.19e-06 |ddm|= 5.3e-06 |
Thanks for the interest. H2 can be tricky to converge, especially for DM21 as its trained on fractional spin data. If you look at the orbital occupancies during SCF, they frequently switch between the A1g and A1u orbitals. This causes problems with DIIS, as @vivhitekro mentioned. One option is to converge using a quasi-Newton (e.g. scipy.optimize.minimize with L-BGFS-B) or Newton approach (not implemented in pyscf for functionals using meta-GGA and local hybrid features). A simpler way, which gives stable convergence is to fix the orbital occupancies by symmetry, e.g. to match those from B3LYP or your intuition:
This converges in around 6 SCF cycles for me and enables fast convergence across the binding curve. Note that the LUMO is lower in energy than the HOMO at this separation -- which is one reason SCF convergence is so problematic and indicates the energy can be further lowered by (partially) occupying the LUMO. This is what led us to investigate fractional occupancies, as described in our paper. |
Thanks for the pointer! Using symmetry adapted RKS indeed leads to stable convergence and the energy value is reasonable. The main issue with convergence, as pointed out by @jsspencer is the oscillation between A1g and A1u states. That being said I am pondering over broken-symmetry calculations using DM21: flipping the spin from a triplet state B3LYP solution gets convegred to a symmetry broken singlet solution. It seems like the 1e- RDM produced by DM21 has some issues. |
Thanks @jsspencer and @vivhitekro. I was able to see DM21 converge with integer occupancy taken from B3LYP as suggested by @jsspencer. However, I am also interested to know how you managed to converge fractional occupancy with DM21 for H2 as given in the paper? That would be very helpful. I see similar errors that @vivhitekro states. |
@soumitribedi We used a custom optimization algorithm for fractional occupation. Please see section S3.2 of the supplementary material for details. @vivhitekro A separate issue would be best. |
Hi @jsspencer, thanks for your explanation, which helps a lot since I just started playing with DM21! I tried your code above for the H2 dissociation curve but I still get a H2 energy of -0.955678 at 3A H-H distance (FCI should be close to -1). Is this observation expected because we need to use fractional occupation optimizations to reproduce the dissociation curve at Figure 2D? If so, is there a code example for doing this? Thanks! Chenru |
Yes, this is expected -- as Fig 2d (data in the Supplementary data files) shows, 3A is close to the maximum energy for DM21 with integer occupations. Fractional occupations improve the energy as described above and in the paper. The algorithm for doing this optimisation is detailed in the Supplementary material. Unfortunately a open source version is not available at this time. |
@jsspencer Thanks so much! The data json is very helpful! I have a naive question then: Will the fractional occupations optimization algorithm improve the dissociation curve at long distance for other conventional functionals (e.g., B3LYP)? |
I wouldn't expect an improvement for most conventional functions (cf comments in our paper and work by Becke on B13 functional) |
I am a PostDoc researcher with Prof. Paul Zimmerman at the University of Michigan. We are particularly interested in exact exchange-correlation potentials. So I became interested in your recent paper and was trying to reproduce some of the results using the DM21 functional. I found strangely, that for H2 dissociation as well as F2 dissociation, the convergence fails precisely 2.3 Angstroms onwards. This problem is invariant to the change of basis or grid size. However, DM21m and DM21mc do not have convergence issues, although the results are not very good. I am attaching the input, the corresponding output (h2_2.3.txt) and a plot of H2 dissociation at the cc-PVQZ basis.
I am wondering whether we are missing any crucial parameter in the input? How do we specify the fractional occupancy?
Below is the input:
import density_functional_approximation_dm21 as dm21
from pyscf import gto
from pyscf import dft
mol = gto.Mole()
mol.atom ='''
H 0.0 0.0 0.0
H 0.0 0.0 2.3
'''
mol.basis = 'cc-pVDZ'
mol.build()
mf = dft.RKS(mol)
mf.xc ='B3LYP'
mf.verbose=0
mf.run()
dm0 = mf.make_rdm1()
mf = dft.RKS(mol)
mf._numint = dm21.NeuralNumInt(dm21.Functional.DM21)
mf.grids.level=5
mf.conv_tol=1E-6
mf.conv_tol_grad=1E-3
mf.verbose=4
mf.kernel(dm0=dm0)
h2_2.3.txt
The text was updated successfully, but these errors were encountered: