Skip to content

Commit 2093129

Browse files
sunqmbabbush
authored andcommitted
Fix import error (#41)
* Update psycf interface * Efficient integral transformation function * Fixed n_orbitals * Extending MolecularData to hold pyscf objects * Bugfix for index convention of eri and 2-pdm * Renamed _molecular_data module and MolecularData class * Removing the DEBUG flag * Updated installation requirements and tests * Updated Author lists * More sanity checks in pyscf_molecular_data * Fix error in PySCFMolecularData.__init__ * Temporarily removed dependence to pyscf in requirements.txt * Name convention of test files. * Updated Author list * A pyscf-1.4.3 compatibility issue * Added travis (for issue #28) * Fix import error (issue #40)
1 parent afe7959 commit 2093129

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

openfermionpyscf/_run_pyscf.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import numpy
2020
import pyscf
21+
from pyscf import gto, scf, ao2mo, ci, cc, fci, mp
2122

2223
from openfermion import MolecularData
2324
from openfermionpyscf import PyscfMolecularData
@@ -33,7 +34,7 @@ def prepare_pyscf_molecule(molecule):
3334
Returns:
3435
pyscf_molecule: A pyscf molecule instance.
3536
"""
36-
pyscf_molecule = pyscf.gto.Mole()
37+
pyscf_molecule = gto.Mole()
3738
pyscf_molecule.atom = molecule.geometry
3839
pyscf_molecule.basis = molecule.basis
3940
pyscf_molecule.spin = molecule.multiplicity - 1
@@ -55,9 +56,9 @@ def compute_scf(pyscf_molecule):
5556
pyscf_scf: A PySCF "SCF" calculation object.
5657
"""
5758
if pyscf_molecule.spin:
58-
pyscf_scf = pyscf.scf.ROHF(pyscf_molecule)
59+
pyscf_scf = scf.ROHF(pyscf_molecule)
5960
else:
60-
pyscf_scf = pyscf.scf.RHF(pyscf_molecule)
61+
pyscf_scf = scf.RHF(pyscf_molecule)
6162
return pyscf_scf
6263

6364

@@ -82,10 +83,10 @@ def compute_integrals(pyscf_molecule, pyscf_scf):
8283
n_orbitals, n_orbitals).astype(float)
8384

8485
# Get two electron integrals in compressed format.
85-
two_electron_compressed = pyscf.ao2mo.kernel(pyscf_molecule,
86-
pyscf_scf.mo_coeff)
86+
two_electron_compressed = ao2mo.kernel(pyscf_molecule,
87+
pyscf_scf.mo_coeff)
8788

88-
two_electron_integrals = pyscf.ao2mo.restore(
89+
two_electron_integrals = ao2mo.restore(
8990
1, # no permutation symmetry
9091
two_electron_compressed, n_orbitals)
9192
# See PQRS convention in OpenFermion.hamiltonians._molecular_data
@@ -157,7 +158,7 @@ def run_pyscf(molecule,
157158
if molecule.multiplicity != 1:
158159
print("WARNING: RO-MP2 is not available in PySCF.")
159160
else:
160-
pyscf_mp2 = pyscf.mp.MP2(pyscf_scf)
161+
pyscf_mp2 = mp.MP2(pyscf_scf)
161162
pyscf_mp2.verbose = 0
162163
pyscf_mp2.run()
163164
# molecule.mp2_energy = pyscf_mp2.e_tot # pyscf-1.4.4 or higher
@@ -169,7 +170,7 @@ def run_pyscf(molecule,
169170

170171
# Run CISD.
171172
if run_cisd:
172-
pyscf_cisd = pyscf.ci.CISD(pyscf_scf)
173+
pyscf_cisd = ci.CISD(pyscf_scf)
173174
pyscf_cisd.verbose = 0
174175
pyscf_cisd.run()
175176
molecule.cisd_energy = pyscf_cisd.e_tot
@@ -180,7 +181,7 @@ def run_pyscf(molecule,
180181

181182
# Run CCSD.
182183
if run_ccsd:
183-
pyscf_ccsd = pyscf.cc.CCSD(pyscf_scf)
184+
pyscf_ccsd = cc.CCSD(pyscf_scf)
184185
pyscf_ccsd.verbose = 0
185186
pyscf_ccsd.run()
186187
molecule.ccsd_energy = pyscf_ccsd.e_tot
@@ -191,7 +192,7 @@ def run_pyscf(molecule,
191192

192193
# Run FCI.
193194
if run_fci:
194-
pyscf_fci = pyscf.fci.FCI(pyscf_molecule, pyscf_scf.mo_coeff)
195+
pyscf_fci = fci.FCI(pyscf_molecule, pyscf_scf.mo_coeff)
195196
pyscf_fci.verbose = 0
196197
molecule.fci_energy = pyscf_fci.kernel()[0]
197198
pyscf_data['fci'] = pyscf_fci

0 commit comments

Comments
 (0)