I am trying to perform a CISD calculation in PySCF using the starting orbitals from an old DFT result.
The DFT result was saved on a chkfile, mf.hdf5
. The code that generate this file is the following:
import pyscf.gto, pyscf.dft
bz_geom="""\
C -1.21225309 0.69989455 0.00000000;
C -1.21225309 -0.69989455 0.00000000;
C -0.00000000 -1.39978909 0.00000000;
C 1.21225309 -0.69989455 0.00000000;
C 1.21225309 0.69989455 0.00000000;
C 0.00000000 1.39978909 0.00000000;
H -2.15365863 1.24341536 0.00000000;
H -2.15365863 -1.24341536 0.00000000;
H -0.00000000 -2.48683071 0.00000000;
H 2.15365863 -1.24341536 0.00000000;
H 2.15365863 1.24341536 0.00000000;
H 0.00000000 2.48683071 0.00000000"""
mol = pyscf.gto.M(atom=bz_geom, basis='bfd_vtz', ecp='bfd')
mf = pyscf.dft.RKS(mol)
mf.xc='b3lyp'
mf.chkfile="mf.hdf5"
mf.kernel()
It was very difficult to me finding documentation about how to load information from a chkfile. I came across with the function pyscf.scf.chkfile.load_scf
. However, when I try to use it to perform the CI calculation, I get an error:
import pyscf.gto, pyscf.dft, pyscf.ci, pyscf.scf
mf = pyscf.scf.chkfile.load_scf('mf.hdf5')
# CISD calculation
cisolver = pyscf.ci.CISD(mf)
cisolver.kernel()
The full error message is:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
/tmp/ipykernel_20980/4228492657.py in <module>
22
23 # CISD calculation
---> 24 cisolver = pyscf.ci.CISD(mf)
25 cisolver.kernel()
26
~/.local/lib/python3.10/site-packages/pyscf/ci/__init__.py in CISD(mf, frozen, mo_coeff, mo_occ)
31 return UCISD(mf, frozen, mo_coeff, mo_occ)
32 else:
---> 33 return RCISD(mf, frozen, mo_coeff, mo_occ)
34 CISD.__doc__ = cisd.CISD.__doc__
35
~/.local/lib/python3.10/site-packages/pyscf/ci/__init__.py in RCISD(mf, frozen, mo_coeff, mo_occ)
38
39 if isinstance(mf, newton_ah._CIAH_SOSCF) or not isinstance(mf, scf.hf.RHF):
---> 40 mf = scf.addons.convert_to_rhf(mf)
41
42 if getattr(mf, 'with_df', None):
~/.local/lib/python3.10/site-packages/pyscf/scf/addons.py in convert_to_rhf(mf, out, remove_df)
692 from pyscf import scf
693 from pyscf import dft
--> 694 assert (isinstance(mf, hf.SCF))
695
696 logger.debug(mf, 'Converting %s to RHF', mf.__class__)
AssertionError:
It seems to me that the error is because the mf object is from a DFT calculation and not from a HF calculation. I get a similar error before (if I try to start the CI calculation directly from the DFT mf
object, instead of with the chkfile). In that case, I got a helpful error message:
RuntimeError: CISD Warning: The first argument mf is a DFT object. CISD calculation should be initialized with HF object.
DFT object can be converted to HF object with the code below:
mf_hf = scf.RHF(mol)
if getattr(mf_dft, "with_x2c", False):
mf_hf = mf_hf.x2c()
mf_hf.__dict__.update(mf_dft.__dict__)
So I should try to do something similar with the mf
object obtained from pyscf.scf.chkfile.load_scf
. The problem is I do not have the mol
object in that case.
I probably am doing something wrong. What is the correct procedure to start a CI calculation from a previous chkfile from a DFT or HF calculation?
.chk
file instead of a.h5
or.hdf5
file. Also, please show your input and full output. The fact that you deleted everything after " AssertionError:" is surprising to me. $\endgroup$Assertion Error:
? It would be helpful if you could provide the whole output file. Questions can have up to 30,000 characters and if you exceed that limit, there's a GitHub repository for input/output files related to MMSE posts: mattermodeling.meta.stackexchange.com/q/393/5 $\endgroup$