Skip to content

Commit

Permalink
Re-adding benzene to the test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
ifilot committed Nov 11, 2023
1 parent 76e643d commit a6fd4bf
Showing 1 changed file with 142 additions and 143 deletions.
285 changes: 142 additions & 143 deletions tests/test_hf_molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,158 +8,157 @@

class TestHFMolecules(unittest.TestCase):

# def testH2(self):
# """
# Test Hartree-Fock calculation for H2
def testH2(self):
"""
Test Hartree-Fock calculation for H2
# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('H', 0.0000, 0.0000, 0.3561150187, unit='angstrom')
# mol.add_atom('H', 0.0000, 0.0000, -0.3561150187, unit='angstrom')
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('H', 0.0000, 0.0000, 0.3561150187, unit='angstrom')
mol.add_atom('H', 0.0000, 0.0000, -0.3561150187, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')
results = HF().rhf(mol, 'sto3g')

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

# def testC2H4(self):
# """
# Test Hartree-Fock calculation for Ethylene
def testC2H4(self):
"""
Test Hartree-Fock calculation for Ethylene
# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('C', -0.6530176758, 0.0000000000 ,0.0000000000, unit='angstrom')
# mol.add_atom('C', 0.6530176758, 0.0000000000 ,0.0000000000, unit='angstrom')
# mol.add_atom('H', -1.2288875372, -0.9156191261 ,0.0000000000, unit='angstrom')
# mol.add_atom('H', -1.2288875372, 0.9156191261 ,0.0000000000, unit='angstrom')
# mol.add_atom('H', 1.2288875372, 0.9156191261 ,0.0000000000, unit='angstrom')
# mol.add_atom('H', 1.2288875372, -0.9156191261 ,0.0000000000, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')

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

# def testBF3(self):
# """
# Test Hartree-Fock calculation for BF3

# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('B', 0.0, 0.0, 0.0, unit='angstrom')
# mol.add_atom('F', -1.1334295832, 0.654385875, 0.0, unit='angstrom')
# mol.add_atom('F', 1.1334295832, 0.654385875, 0.0, unit='angstrom')
# mol.add_atom('F', 0.0, -1.3087717499, 0.0, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')

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

# def testCH4(self):
# """
# Test Hartree-Fock calculation for CH4

# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('C', 0.0, 0.0, 0.0, unit='angstrom')
# mol.add_atom('H', -5.9e-09, -1.6e-09, 1.0830098121, unit='angstrom')
# mol.add_atom('H', 0.0, -1.0210714424, -0.3610032723, unit='angstrom')
# mol.add_atom('H', -0.8842738057, 0.5105357237, -0.3610032748, unit='angstrom')
# mol.add_atom('H', 0.8842738117, 0.5105357203, -0.3610032651, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')

# # check that energy matches
# np.testing.assert_almost_equal(results['energy'], -39.7268637, 1)

# def testCO(self):
# """
# Test Hartree-Fock calculation for CO

# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('O', 0.0, 0.0, 0.4909201273, unit='angstrom')
# mol.add_atom('C', 0.0, 0.0, -0.6545601698, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')

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

# def testCO2(self):
# """
# Test Hartree-Fock calculation for CO2

# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('C', 0.0, 0.0, 0.0, unit='angstrom')
# mol.add_atom('O', 0.0, 0.0, 1.1879700928, unit='angstrom')
# mol.add_atom('O', 0.0, 0.0, -1.1879700928, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')

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

# def testH2O(self):
# """
# Test Hartree-Fock calculation for H2O

# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('O', 0.0, 0.0, -0.1271310707, unit='angstrom')
# mol.add_atom('H', 0.0, -0.7580158822, 0.5085242828, unit='angstrom')
# mol.add_atom('H', 0.0, 0.7580158822, 0.5085242828, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')

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

# def testLIH(self):
# """
# Test Hartree-Fock calculation for LIH

# Data is compared to results obtained from Gaussian
# """
# mol = Molecule()
# mol.add_atom('Li', 0.0, 0.0, 0.377702853, unit='angstrom')
# mol.add_atom('H', 0.0, 0.0, -1.1331085589, unit='angstrom')
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('C', -0.6530176758, 0.0000000000 ,0.0000000000, unit='angstrom')
mol.add_atom('C', 0.6530176758, 0.0000000000 ,0.0000000000, unit='angstrom')
mol.add_atom('H', -1.2288875372, -0.9156191261 ,0.0000000000, unit='angstrom')
mol.add_atom('H', -1.2288875372, 0.9156191261 ,0.0000000000, unit='angstrom')
mol.add_atom('H', 1.2288875372, 0.9156191261 ,0.0000000000, unit='angstrom')
mol.add_atom('H', 1.2288875372, -0.9156191261 ,0.0000000000, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')
results = HF().rhf(mol, 'sto3g')

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

def testBF3(self):
"""
Test Hartree-Fock calculation for BF3
# # check that energy matches
# np.testing.assert_almost_equal(results['energy'], -7.8633821, 5)
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('B', 0.0, 0.0, 0.0, unit='angstrom')
mol.add_atom('F', -1.1334295832, 0.654385875, 0.0, unit='angstrom')
mol.add_atom('F', 1.1334295832, 0.654385875, 0.0, unit='angstrom')
mol.add_atom('F', 0.0, -1.3087717499, 0.0, unit='angstrom')

results = HF().rhf(mol, 'sto3g')

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

def testCH4(self):
"""
Test Hartree-Fock calculation for CH4
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('C', 0.0, 0.0, 0.0, unit='angstrom')
mol.add_atom('H', -5.9e-09, -1.6e-09, 1.0830098121, unit='angstrom')
mol.add_atom('H', 0.0, -1.0210714424, -0.3610032723, unit='angstrom')
mol.add_atom('H', -0.8842738057, 0.5105357237, -0.3610032748, unit='angstrom')
mol.add_atom('H', 0.8842738117, 0.5105357203, -0.3610032651, unit='angstrom')

results = HF().rhf(mol, 'sto3g')

# check that energy matches
np.testing.assert_almost_equal(results['energy'], -39.7268637, 1)

def testCO(self):
"""
Test Hartree-Fock calculation for CO
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('O', 0.0, 0.0, 0.4909201273, unit='angstrom')
mol.add_atom('C', 0.0, 0.0, -0.6545601698, unit='angstrom')

results = HF().rhf(mol, 'sto3g')

# def testNH3(self):
# """
# Test Hartree-Fock calculation for NH3
# check that energy matches
np.testing.assert_almost_equal(results['energy'], -111.2254495, 5)

def testCO2(self):
"""
Test Hartree-Fock calculation for CO2
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('C', 0.0, 0.0, 0.0, unit='angstrom')
mol.add_atom('O', 0.0, 0.0, 1.1879700928, unit='angstrom')
mol.add_atom('O', 0.0, 0.0, -1.1879700928, unit='angstrom')

results = HF().rhf(mol, 'sto3g')

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

def testH2O(self):
"""
Test Hartree-Fock calculation for H2O
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('O', 0.0, 0.0, -0.1271310707, unit='angstrom')
mol.add_atom('H', 0.0, -0.7580158822, 0.5085242828, unit='angstrom')
mol.add_atom('H', 0.0, 0.7580158822, 0.5085242828, unit='angstrom')

results = HF().rhf(mol, 'sto3g')

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

def testLIH(self):
"""
Test Hartree-Fock calculation for LIH
Data is compared to results obtained from Gaussian
"""
mol = Molecule()
mol.add_atom('Li', 0.0, 0.0, 0.377702853, unit='angstrom')
mol.add_atom('H', 0.0, 0.0, -1.1331085589, unit='angstrom')

results = HF().rhf(mol, 'sto3g')

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

def testNH3(self):
"""
Test Hartree-Fock calculation for NH3
# Note: a lower energy is found here as compared to Gaussian, so I reckon
# (might be wrong!) that this result is better.
# Using Gaussian: EHF = -55.7433617 Ht is found
# """
# mol = Molecule()
# mol.add_atom('H', -3.4e-09, -2.6e-09, 1.1944430032, unit='angstrom')
# mol.add_atom('H', 1e-10, -1.1261316622, -0.3981476702, unit='angstrom')
# mol.add_atom('H', -0.9752586265, 0.5630658334, -0.3981476693, unit='angstrom')
# mol.add_atom('H', 0.9752586299, 0.5630658315, -0.3981476637, unit='angstrom')
# mol.add_atom('N', 0.0, 0.0, 0.0, unit='angstrom')

# results = HF().rhf(mol, 'sto3g')

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

# @nottest
Note: a lower energy is found here as compared to Gaussian, so I reckon
(might be wrong!) that this result is better.
Using Gaussian: EHF = -55.7433617 Ht is found
"""
mol = Molecule()
mol.add_atom('H', -3.4e-09, -2.6e-09, 1.1944430032, unit='angstrom')
mol.add_atom('H', 1e-10, -1.1261316622, -0.3981476702, unit='angstrom')
mol.add_atom('H', -0.9752586265, 0.5630658334, -0.3981476693, unit='angstrom')
mol.add_atom('H', 0.9752586299, 0.5630658315, -0.3981476637, unit='angstrom')
mol.add_atom('N', 0.0, 0.0, 0.0, unit='angstrom')

results = HF().rhf(mol, 'sto3g')

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

def testC6H6(self):
"""
Test Hartree-Fock calculation for Ethylene
Expand Down

0 comments on commit a6fd4bf

Please sign in to comment.