Пример #1
0
    def test_unit_conversion_accuracy(self):
        """ 
        1.0 Angstrom is approximately 1.889725989 Bohr. Is this conversion (and its reverse) carried out correctly?
        """

        with open('../../extra-files/molecule.xyz', 'r') as file1:
            mol1 = Molecule(file1.read())
        mol2 = mol1.copy()
        mol2.to_bohr()
        for i in range(mol1.natom) :
            self.assertAlmostEqual(mol1.geom[i][0] * 1.889725989, mol2.geom[i][0])
            self.assertAlmostEqual(mol1.geom[i][1] * 1.889725989, mol2.geom[i][1])
            self.assertAlmostEqual(mol1.geom[i][2] * 1.889725989, mol2.geom[i][2])
Пример #2
0
 def test_unit_conversion_symmetry(self):
     """ 
     Does converting back and forth between bohrs and angstroms introduce and compound rounding errors? Each 
     operation should exactly reverse its counterpart.
     """
             
     with open('../../extra-files/molecule.xyz', 'r') as file1:
         mol1 = Molecule(file1.read())
     mol2 = mol1.copy()
     for count in range(10000) :
         mol2.to_bohr()
         mol2.to_angstrom()
     self.assertEqual(mol1.geom, mol2.geom)
Пример #3
0
    def test_unit_conversion_symmetry(self):
        """ 
        Does converting back and forth between bohrs and angstroms introduce and compound rounding errors? Each 
        operation should exactly reverse its counterpart.
        """

        with open('../../extra-files/molecule.xyz', 'r') as file1:
            mol1 = Molecule(file1.read())
        mol2 = mol1.copy()
        for count in range(10000):
            mol2.to_bohr()
            mol2.to_angstrom()
        self.assertEqual(mol1.geom, mol2.geom)
Пример #4
0
    def test_unit_conversion_accuracy(self):
        """ 
        1.0 Angstrom is approximately 1.889725989 Bohr. Is this conversion (and its reverse) carried out correctly?
        """

        with open('../../extra-files/molecule.xyz', 'r') as file1:
            mol1 = Molecule(file1.read())
        mol2 = mol1.copy()
        mol2.to_bohr()
        for i in range(mol1.natom):
            self.assertAlmostEqual(mol1.geom[i][0] * 1.889725989,
                                   mol2.geom[i][0])
            self.assertAlmostEqual(mol1.geom[i][1] * 1.889725989,
                                   mol2.geom[i][1])
            self.assertAlmostEqual(mol1.geom[i][2] * 1.889725989,
                                   mol2.geom[i][2])
Пример #5
0
    def test_copy_function(self):
        """ 
        Does the copy function correctly initialize all variables of a new molecule? Also, is the new molecule
        truly a different object? (ie: changing properties of the original does not affect the copy and vice versa)?
        """
                
        with open('../../extra-files/molecule.xyz', 'r') as file1:
            mol1 = Molecule(file1.read())
        mol2 = mol1.copy()
        self.assertEqual(mol1.units, mol2.units, 'checking units')
        self.assertEqual(mol1.natom, mol2.natom, 'checking natom')
        self.assertEqual(mol1.labels, mol2.labels, 'checking labels')
        self.assertEqual(mol1.masses, mol2.masses, 'checking masses')
        self.assertEqual(mol1.charges, mol2.charges, 'checking charges')
        self.assertEqual(mol1.geom, mol2.geom, 'checking geometry')

        mol2.to_bohr()
        self.assertNotEqual(mol1.units, mol2.units)
        self.assertNotEqual(mol1.geom, mol2.geom)
Пример #6
0
    def test_copy_function(self):
        """ 
        Does the copy function correctly initialize all variables of a new molecule? Also, is the new molecule
        truly a different object? (ie: changing properties of the original does not affect the copy and vice versa)?
        """

        with open('../../extra-files/molecule.xyz', 'r') as file1:
            mol1 = Molecule(file1.read())
        mol2 = mol1.copy()
        self.assertEqual(mol1.units, mol2.units, 'checking units')
        self.assertEqual(mol1.natom, mol2.natom, 'checking natom')
        self.assertEqual(mol1.labels, mol2.labels, 'checking labels')
        self.assertEqual(mol1.masses, mol2.masses, 'checking masses')
        self.assertEqual(mol1.charges, mol2.charges, 'checking charges')
        self.assertEqual(mol1.geom, mol2.geom, 'checking geometry')

        mol2.to_bohr()
        self.assertNotEqual(mol1.units, mol2.units)
        self.assertNotEqual(mol1.geom, mol2.geom)
Пример #7
0
        out = float(match[0].split()[-1])
    return out


####  Run reference configuration    ####

make_input("X0X0_00",mol.atoms,mol.geom)
run_input("X0X0_00")


####   Run single displacements   ####

for i in range(3*N):
   forward = "X%dX0_10" % i
   reverse = "X%dX0_-10" % i
   geom_copy = mol.copy().geom
   geom_copy[i/3,i%3] +=h

   make_input(forward,mol.atoms,geom_copy)

   geom_copy[i/3,i%3] -= 2*h
   make_input(reverse,mol.atoms,geom_copy)

   run_input(forward)
   run_input(reverse)


####   Run double displacements    ######

for i in range(3*N):
    for j in range(i):