Skip to content

Commit

Permalink
Tolerate error (#28)
Browse files Browse the repository at this point in the history
* Fix tolerate error to work as intended

* two small PEP8 fixes
  • Loading branch information
jarrodmcc authored and babbush committed Mar 20, 2018
1 parent ff61c30 commit 3f86658
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions openfermionpsi4/_psi4_template
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ else:
set globals {
basis &basis
freeze_core false
fail_on_maxiter true
fail_on_maxiter &not_tolerate_error
df_scf_guess false
opdm true
tpdm true
Expand All @@ -73,7 +73,7 @@ if &run_scf:
print('WARNING: SCF calculation failed.')
else:
raise
else:
finally:
# Get orbitals and Fock matrix.
molecule.hf_energy = hf_energy
molecule.nuclear_repulsion = mol.nuclear_repulsion_energy()
Expand Down Expand Up @@ -176,7 +176,7 @@ if &run_fci:
print('WARNING: FCI calculation failed.')
else:
raise
else:
finally:
# For the functions below, "a" and "b" refer to "up and "down" spins.
molecule.fci_energy = fci_energy

Expand Down
6 changes: 5 additions & 1 deletion openfermionpsi4/_run_psi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def generate_psi4_input(molecule,
for line in input_content]
input_content = [re.sub('&tolerate_error', str(tolerate_error), line)
for line in input_content]
input_content = [re.sub('&not_tolerate_error',
str(not tolerate_error), line)
for line in input_content]
input_content = [re.sub('&verbose', str(verbose), line)
for line in input_content]
input_content = [re.sub('&memory', str(memory), line)
Expand Down Expand Up @@ -218,6 +221,7 @@ def run_psi4(molecule,
try:
molecule.load()
except:
warnings.warn('No calculation saved. Psi4 segmentation fault possible.',
warnings.warn('No calculation saved. '
'Psi4 segmentation fault possible.',
Warning)
return molecule

0 comments on commit 3f86658

Please sign in to comment.