Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openfermionpyscf/_run_pyscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def generate_molecular_hamiltonian(

# Run electronic structure calculations
molecule = run_pyscf(
MolecularData(geometry, basis, multiplicity, charge)
MolecularData(geometry, basis, multiplicity, charge),
save=False
)

# Freeze core orbitals and truncate to active space
Expand Down
21 changes: 16 additions & 5 deletions openfermionpyscf/tests/_run_pyscf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import openfermion.chem.molecular_data
from openfermion.chem import MolecularData
import openfermion.config
from openfermionpyscf import generate_molecular_hamiltonian
from openfermionpyscf import run_pyscf
from openfermionpyscf import PyscfMolecularData

Expand All @@ -27,13 +28,14 @@
basis = '6-31g'
multiplicity = 1
charge = 0
molecule = MolecularData(geometry,
basis,
multiplicity,
charge)


def test_run_pyscf():
def test_run_pyscf(tmp_path):
molecule = MolecularData(geometry,
basis,
multiplicity,
charge,
data_directory=str(tmp_path))
new_mole = run_pyscf(molecule,
run_scf=True,
run_mp2=True,
Expand All @@ -42,6 +44,7 @@ def test_run_pyscf():
run_fci=True,
verbose=1)
assert isinstance(new_mole, PyscfMolecularData)
assert os.path.exists(f'{new_mole.filename}.hdf5')


def test_run_pyscf_without_save(tmp_path):
Expand Down Expand Up @@ -91,3 +94,11 @@ def test_generate_diatomic(tmp_path, monkeypatch):
assert not list(readonly_dir.iterdir())
finally:
readonly_dir.chmod(0o755)


def test_generate_molecular_hamiltonian_does_not_save(tmp_path, monkeypatch):
monkeypatch.setattr(
'openfermion.chem.molecular_data.DATA_DIRECTORY', str(tmp_path))
geometry = [('H', (0., 0., 0.)), ('H', (0., 0., 0.7414))]
generate_molecular_hamiltonian(geometry, 'sto-3g', 1, 0)
assert not any(tmp_path.iterdir())
Loading