Skip to content

Commit

Permalink
Comment out run_psi4 code
Browse files Browse the repository at this point in the history
Also cleaned up conf.py in the docs
  • Loading branch information
chmwzc committed Dec 20, 2023
1 parent 43d272d commit e39a14d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 90 deletions.
9 changes: 1 addition & 8 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import sys

from recommonmark.transform import AutoStructify
from sphinx.ext.autodoc import between

sys.path.insert(0, os.path.abspath(".."))

Expand All @@ -36,16 +35,14 @@

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"recommonmark",
"sphinxcontrib.katex",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx_copybutton",
"recommonmark",
"nbsphinx",
"sphinxcontrib.katex",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -134,10 +131,6 @@ def setup(app):
app.add_config_value("recommonmark_config", {"enable_eval_rst": True}, True)
app.add_transform(AutoStructify)
app.add_css_file("css/style.css")
# Register a sphinx.ext.autodoc.between listener to ignore everything
# between lines that contain the word IGNORE
app.connect("autodoc-process-docstring", between("^.*IGNORE.*$", exclude=True))
return app


html_show_sourcelink = False
154 changes: 72 additions & 82 deletions src/qibochem/driver/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,88 +169,78 @@ def run_pyscf(self, max_scf_cycles=50):
tei = np.einsum("pqrs->prsq", eri4)
self.tei = tei

"""
IGNORE
def run_psi4(self, output=None):
IGNORE
"""
"""
IGNORE
Run a Hartree-Fock calculation with PSI4 to obtain the molecular quantities and
molecular integrals
Args:
output: Name of PSI4 output file. ``None`` suppresses the output on non-Windows systems,
and uses ``psi4_output.dat`` otherwise
IGNORE
"""
"""
IGNORE
import psi4 # pylint: disable=import-error
# PSI4 input string
chgmul_string = f"{self.charge} {self.multiplicity} \n"
geom_string = "\n".join("{} {:.6f} {:.6f} {:.6f}".format(_atom[0], *_atom[1]) for _atom in self.geometry)
opt1_string = "\n\nunits angstrom\nsymmetry c1\n"
mol_string = f"{chgmul_string}{geom_string}{opt1_string}"
# PSI4 calculation options
opts = {"basis": self.basis, "scf_type": "direct", "reference": "rhf", "save_jk": True}
psi4.core.clean()
psi4.set_memory("500 MB")
psi4.set_options(opts)
# Keep the output file of the PSI4 calculation?
if output is None:
# Doesn't work on Windows!
# See: https://psicode.org/psi4manual/master/api/psi4.core.be_quiet.html
try:
psi4.core.be_quiet()
except RuntimeError:
psi4.core.set_output_file("psi4_output.dat", False)
else:
psi4.core.set_output_file(output, False)
# Run HF calculation with PSI4
psi4_mol = psi4.geometry(mol_string)
ehf, wavefn = psi4.energy("hf", return_wfn=True)
# Save 1- and 2-body integrals
ca = wavefn.Ca() # MO coefficients
self.ca = np.asarray(ca)
# 1- electron integrals
oei = wavefn.H() # 'Core' (potential + kinetic) integrals
# Convert from AO->MO basis
oei = np.einsum("ab,bc->ac", oei, self.ca)
oei = np.einsum("ab,ac->bc", self.ca, oei)
# 2- electron integrals
mints = psi4.core.MintsHelper(wavefn.basisset())
tei = np.asarray(mints.mo_eri(ca, ca, ca, ca)) # Need original C_a array, not a np.array
tei = np.einsum("pqrs->prsq", tei)
# Fill in the class attributes
self.nelec = (wavefn.nalpha(), wavefn.nbeta())
self.nalpha = self.nelec[0]
self.nbeta = self.nelec[1]
self.e_hf = ehf
self.e_nuc = psi4_mol.nuclear_repulsion_energy()
self.norb = wavefn.nmo()
self.nso = 2 * self.norb
self.oei = oei
self.tei = tei
self.aoeri = np.asarray(mints.ao_eri())
self.overlap = np.asarray(wavefn.S())
self.eps = np.asarray(wavefn.epsilon_a())
self.fa = np.asarray(wavefn.Fa())
self.hcore = np.asarray(wavefn.H())
self.ja = np.asarray(wavefn.jk().J()[0])
self.ka = np.asarray(wavefn.jk().K()[0])
ca_occ = self.ca[:, 0 : self.nalpha]
self.pa = ca_occ @ ca_occ.T
self.da = self.ca.T @ self.overlap @ self.pa @ self.overlap @ self.ca
IGNORE
"""
# def run_psi4(self, output=None):
# """
# Run a Hartree-Fock calculation with PSI4 to obtain the molecular quantities and
# molecular integrals

# Args:
# output: Name of PSI4 output file. ``None`` suppresses the output on non-Windows systems,
# and uses ``psi4_output.dat`` otherwise
# """
# import psi4 # pylint: disable=import-error

# # PSI4 input string
# chgmul_string = f"{self.charge} {self.multiplicity} \n"
# geom_string = "\n".join("{} {:.6f} {:.6f} {:.6f}".format(_atom[0], *_atom[1]) for _atom in self.geometry)
# opt1_string = "\n\nunits angstrom\nsymmetry c1\n"
# mol_string = f"{chgmul_string}{geom_string}{opt1_string}"
# # PSI4 calculation options
# opts = {"basis": self.basis, "scf_type": "direct", "reference": "rhf", "save_jk": True}
# psi4.core.clean()
# psi4.set_memory("500 MB")
# psi4.set_options(opts)
# # Keep the output file of the PSI4 calculation?
# if output is None:
# # Doesn't work on Windows!
# # See: https://psicode.org/psi4manual/master/api/psi4.core.be_quiet.html
# try:
# psi4.core.be_quiet()
# except RuntimeError:
# psi4.core.set_output_file("psi4_output.dat", False)
# else:
# psi4.core.set_output_file(output, False)

# # Run HF calculation with PSI4
# psi4_mol = psi4.geometry(mol_string)
# ehf, wavefn = psi4.energy("hf", return_wfn=True)

# # Save 1- and 2-body integrals
# ca = wavefn.Ca() # MO coefficients
# self.ca = np.asarray(ca)
# # 1- electron integrals
# oei = wavefn.H() # 'Core' (potential + kinetic) integrals
# # Convert from AO->MO basis
# oei = np.einsum("ab,bc->ac", oei, self.ca)
# oei = np.einsum("ab,ac->bc", self.ca, oei)

# # 2- electron integrals
# mints = psi4.core.MintsHelper(wavefn.basisset())
# tei = np.asarray(mints.mo_eri(ca, ca, ca, ca)) # Need original C_a array, not a np.array
# tei = np.einsum("pqrs->prsq", tei)

# # Fill in the class attributes
# self.nelec = (wavefn.nalpha(), wavefn.nbeta())
# self.nalpha = self.nelec[0]
# self.nbeta = self.nelec[1]
# self.e_hf = ehf
# self.e_nuc = psi4_mol.nuclear_repulsion_energy()
# self.norb = wavefn.nmo()
# self.nso = 2 * self.norb
# self.oei = oei
# self.tei = tei
# self.aoeri = np.asarray(mints.ao_eri())
# self.overlap = np.asarray(wavefn.S())
# self.eps = np.asarray(wavefn.epsilon_a())
# self.fa = np.asarray(wavefn.Fa())
# self.hcore = np.asarray(wavefn.H())

# self.ja = np.asarray(wavefn.jk().J()[0])
# self.ka = np.asarray(wavefn.jk().K()[0])

# ca_occ = self.ca[:, 0 : self.nalpha]
# self.pa = ca_occ @ ca_occ.T
# self.da = self.ca.T @ self.overlap @ self.pa @ self.overlap @ self.ca

# HF embedding functions
def _inactive_fock_matrix(self, frozen):
Expand Down

0 comments on commit e39a14d

Please sign in to comment.