question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NEVPT2 Energies Depend on nroots from CASCI

See original GitHub issue

Problem

I’m seeing some unexpected behavior while running NEVPT2 on a system we’re studying. I follow a procedure analogous to the one shown in the PySCF example below:

https://github.com/pyscf/pyscf/blob/adbdcbdd426356485d9a249d7461f668d19d6f9e/examples/mrpt/41-for_state_average.py#L31-L47

We’ve noticed that there is a slight dependence ~ 0.8 mHa of the final NEVPT2 energies on the number of roots we set for the CASCI (line 39 above) calculation. We’ve kept the number of states in the SA-CASSCF calculation the same so I wouldn’t expect the NEVPT2 energies to change at all.

Possible explanation

Is this related to the Davidson solver in CASCI where you typically want to keep several more states than you’re actually interested in? If that’s the case should I always set nroots to be larger than the number of states I’m targeting in my SA-CASSCF calculation? See below

Reproducing Error: Naphthalene

Since our calculations on the full system we’re studying are expensive I’ve tried to reproduce this behavior with a smaller system. The input script is shown below.

For naphthalene, I can’t see variations as large as 8e-4 Ha, but I do see variations at about 6e-5 Ha. I also looked at benzene and saw variations in the NEVPT2 energies of about 1e-5 Ha.

If anyone has any knowledge or suggestions about this, let me know!

import sys
import numpy as np

from pyscf import gto, scf, mcscf, mrpt
from pyscf.tools import molden

nstates = 3
nroots = 10

if len(sys.argv) == 1:
    print(f"Setting nstates={nstates} and nroots={nroots}")
elif len(sys.argv) == 3:
    nstates = int(sys.argv[1])
    nroots = int(sys.argv[2])
    print(f"Setting nstates={nstates} and nroots={nroots}")

else:
    raise ValueError("Wrong number of command line arguments")

mol = gto.Mole()
mol.atom = """
 C                 -2.42729600   -0.70070000    0.00000000
 C                 -1.21364800   -1.40140000    0.00000000
 C                 -0.00000000   -0.70070000    0.00000000
 C                 -0.00000000    0.70070000    0.00000000
 C                 -1.21364800    1.40140000   -0.00000000
 C                 -2.42729600    0.70070000   -0.00000000
 H                  1.21364800   -2.47140000    0.00000000
 H                 -3.35394318   -1.23570000    0.00000000
 H                 -1.21364800   -2.47140000    0.00000000
 C                  1.21364800   -1.40140000   -0.00000000
 C                  1.21364800    1.40140000    0.00000000
 H                 -1.21364800    2.47140000    0.00000000
 H                 -3.35394318    1.23570000   -0.00000000
 C                  2.42729600    0.70070000    0.00000000
 C                  2.42729600   -0.70070000   -0.00000000
 H                  1.21364800    2.47140000   -0.00000000
 H                  3.35394318    1.23570000    0.00000000
 H                  3.35394318   -1.23570000   -0.00000000
"""
mol.basis = "ccpvdz"
mol.symmetry = True
mol.max_memory = 80000
mol.verbose = 4
mol.build()
mf = scf.RHF(mol).run()
# molden.from_scf(mf, "_molden/naphtalene_dz.molden")

ncas = 10
nelecas = 10

n_states = nstates
weights = np.ones(n_states) / n_states

mc = mcscf.CASSCF(mf, ncas, nelecas).state_average_(weights)
mo = mcscf.sort_mo(mc, mf.mo_coeff, [27, 31, 32, 33, 34, 35, 36, 37, 45, 48])
mc.kernel(mo)
mo = mc.mo_coeff

# CASCI to prep for NEVPT2
mc = mcscf.CASCI(mf, ncas, nelecas)
mc.fcisolver.nroots = nroots
mc.casci(mo)


e_corr = np.zeros((nstates))
e_tot = np.zeros((nstates))

for i in range(nstates):
    print(f"STATE {i}")
    e_corr[i] = mrpt.NEVPT(mc, root=i).kernel()
    e_tot[i] = mc.e_tot[i] + e_corr[i]
print("Nev", e_tot)


np.savetxt(f"_data/nroots={nroots}.txt", np.array([nroots] + e_tot.tolist()))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jamesETsmithcommented, Jun 18, 2020

For those interested, using a single thread fixes the issue. I’ve included two tables where I break down the effect of using single vs. mutlithreaded NEVPT2.

Listed in the tables are the differences in NEVPT2 components from running the same calculation twice.

Without using a single thread:

Si (+1)’ Sij (+2) Sijr (+1) Sijrs (0) Sir (0)’ Sr (-1)’ Srs (-2) Srsi (-1)
1.16214e-07 -2.2906e-08 -3.35022e-07 2.10412e-08 1.0888e-07 1.51292e-07 -8.94214e-09 -0.0012994

Using a single thread

Si (+1)’ Sij (+2) Sijr (+1) Sijrs (0) Sir (0)’ Sr (-1)’ Srs (-2) Srsi (-1)
4.73266e-08 -2.01128e-08 -1.06267e-05 -2.69257e-09 2.96425e-08 1.17653e-07 -2.18422e-08 3.82372e-05

The Srsi component is the troublesome one and although it’s still not as consistent as the other components it’s still a solid improvement.

0reactions
jamesETsmithcommented, Jun 18, 2020

Ok thanks for the heads up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi-reference perturbation theory (MRPT) - PySCF
The bottleneck in SC-NEVPT2 is the evaluation of the energies of the perturber functions, where up to the 4-particle reduced density matrix (4-RDM)...
Read more >
DMRG for electronic structure calculations — BLOCK 1.5.0 ...
python c2_cas.py converged SCF energy = -108.929838385609 CASCI E ... For Block 1.1.1 version or older, the standard DMRG-NEVPT2 calculation can be carried ......
Read more >
4.2.46. RASSCF — Molcas Manual (version 22.10) - GitLab
These keywords need to be adjusted depending on the chemical system under ... will be performed over the NROOTS lowest states with equal...
Read more >
Magnetic exchange and valence delocalization in a mixed ...
(1) CASSCF/NEVPT2 wave functions/energies of the states split out ... nroots 40” but accounting for dynamical correlation “nevpt2 true”).
Read more >
Time-dependent N-electron valence perturbation theory with ...
turbation formulation, and (ii) yielded the fully uncontracted NEVPT2 energy. Here, we present a combination of t-NEVPT2 with a matrix product state (MPS) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found