sanshar / Dice

Other
43 stars 18 forks source link

SHCI for molecules with symmetries #8

Open jfraxanet opened 1 year ago

jfraxanet commented 1 year ago

Dear contributors,

I am encountering problems when trying to run the stochastic heat bath CI algorithm (SHCI) for molecules with symmetries. I have installed Release v1.0 of Dice together with the PySCF extension from https://github.com/pyscf/shciscf. When I run the algorithm for a simple molecule such as $O_2$, the code works well:

from pyscf import gto, scf, mcscf, dmrgscf
from pyscf.shciscf import shci

# Define molecule
mol = gto.M(verbose=4, atom="O 0 0 0; O 0 0 1.208", symmetry=0, basis="ccpvdz")

# Run HF
mf = scf.RHF(mol).run()

# Active space
ncas = 8
nelecas = 12

# Run CASCI
casci = mcscf.CASSCF(mf, ncas, nelecas)
e_CASSCF = casci.mc1step()[0]

# Define params SHCI
hciscf = shci.SHCISCF(mf, ncas, nelecas)
hciscf.fcisolver.mpiprefix = ""
hciscf.fcisolver.stochastic = True
hciscf.fcisolver.nPTiter = 0  # Turn off perturbative calc.
hciscf.fcisolver.sweep_iter = [10]
# Setting large epsilon1 thresholds highlights improvement from perturbation.
hciscf.fcisolver.sweep_epsilon = [5e-3]
hciscf.fcisolver.outputFile = '/home/output_O2.dat'

# Run SHCI
e_noPT = hciscf.mc1step()[0]

But if, when defining the molecule, I add symmetries: mol = gto.M(verbose=4, atom="O 0 0 0; O 0 0 1.208", symmetry=1, basis="ccpvdz")

I get the following error:

File ~/anaconda3/envs/p4dev/lib/python3.9/site-packages/pyscf/shciscf/shci.py:1356, in readEnergy(SHCI)
   1355 def readEnergy(SHCI):
-> 1356     file1 = open(os.path.join(SHCI.runtimeDir, "%s/shci.e" % (SHCI.scratchDirectory)), "rb")
   1357     format = ["d"] * SHCI.nroots
   1358     format = "".join(format)
FileNotFoundError: [Errno 2] No such file or directory: '/home/joana/Dice-1.0/tmp/shci.e' 

so basically it looks like the code is not creating de shci.e file anymore. Do you have any idea why this happens?

Thank you so much,

Joana

ankit76 commented 1 year ago

Hi Joana,

It seems to work okay for me with the current code on the master branch. Would it be possible for you to try this code instead of the older version? Let me also say that, usually, shci does not require explicit specification of point group symmetry, because the method uses it through the integrals and the initial determinant.