Skip to content

Commit

Permalink
Tuning geometry optimization tolerances
Browse files Browse the repository at this point in the history
  • Loading branch information
ifilot committed Dec 6, 2023
1 parent f77c46b commit 03bde55
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyqint/geometry_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, verbose=False):
self.coordinates_history = []
self.coord = None

def run(self, mol, basis):
def run(self, mol, basis, gtol=1e-4):
"""
Perform geometry optimization
"""
Expand All @@ -39,7 +39,7 @@ def run(self, mol, basis):
self.__print_break(newline=True)

res_opt = scipy.optimize.minimize(self.energy, x0, args=(mol, basis), method='CG',
jac=self.jacobian)
jac=self.jacobian, options={'gtol':gtol})

res = {
'opt': res_opt,
Expand Down
2 changes: 1 addition & 1 deletion pyqint/hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HF:
Routines to perform a restricted Hartree-Fock calculations
"""
def rhf(self, mol, basis, calc_forces=False, itermax=100,
use_diis=True, verbose=False, tolerance=1e-7,
use_diis=True, verbose=False, tolerance=1e-9,
orbc_init=None, ortho='canonical'):
"""
Performs a Hartree-Fock type calculation
Expand Down
2 changes: 1 addition & 1 deletion tests/test_geometry_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_optimization_h2_p321(self):
mol.add_atom('H', 0.9, 0.0, 0.0)
mol.add_atom('H', -0.9, 0.0, 0.0)

res = GeometryOptimization(verbose=False).run(mol, 'p321', tolerance=1e-10)
res = GeometryOptimization(verbose=False).run(mol, 'p321')
np.testing.assert_almost_equal(res['opt'].fun, -1.1232790915, decimal=4)

self.assertEqual(len(res['energies']), len(res['forces']))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_hf_molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def testBF3(self):
results = HF().rhf(mol, 'sto3g')

# check that energy matches
np.testing.assert_almost_equal(results['energy'], -318.6619373, 5)
np.testing.assert_almost_equal(results['energy'], -318.6619373, 4)

def testCH4(self):
"""
Expand Down Expand Up @@ -90,7 +90,7 @@ def testCO(self):
results = HF().rhf(mol, 'sto3g')

# check that energy matches
np.testing.assert_almost_equal(results['energy'], -111.2254495, 5)
np.testing.assert_almost_equal(results['energy'], -111.2254495, 4)

def testCO2(self):
"""
Expand Down Expand Up @@ -122,7 +122,7 @@ def testH2O(self):
results = HF().rhf(mol, 'sto3g')

# check that energy matches
np.testing.assert_almost_equal(results['energy'], -74.9659012, 5)
np.testing.assert_almost_equal(results['energy'], -74.9659012, 4)

def testLIH(self):
"""
Expand Down

0 comments on commit 03bde55

Please sign in to comment.