Example #1
0
    def test_read_zmatrix(self):
        contents = '''$moLEcule

 1 2

 S
 C  1 1.726563
 H  2 1.085845 1 119.580615
 C  2 1.423404 1 114.230851 3 -180.000000 0
 H  4 1.084884 2 122.286346 1 -180.000000 0
 C  4 1.381259 2 112.717365 1 0.000000 0
 H  6 1.084731 4 127.143779 2 -180.000000 0
 C  6 1.415867 4 110.076147 2 0.000000 0
 F  8 1.292591 6 124.884374 4 -180.000000 0
$end

$reM
   BASIS  =  6-31+G*
   EXCHANGE  =  B3LYP
   jobtype  =  freq
$end

'''
        qctask = QcTask.from_string(contents)
        ans = '''$molecule
 1  2
 S           0.00000000        0.00000000        0.00000000
 C           0.00000000        0.00000000        1.72656300
 H          -0.94431813        0.00000000        2.26258784
 C           1.29800105       -0.00000002        2.31074808
 H           1.45002821       -0.00000002        3.38492732
 C           2.30733813       -0.00000003        1.36781908
 H           3.37622632       -0.00000005        1.55253338
 C           1.75466906       -0.00000003        0.06427152
 F           2.44231414       -0.00000004       -1.03023099
$end


$rem
   jobtype = freq
  exchange = b3lyp
     basis = 6-31+g*
$end

'''
        ans_tokens = ans.split('\n')
        ans_text_part = ans_tokens[:2] + ans_tokens[11:]
        ans_coords_part = ans_tokens[2:11]
        converted_tokens = str(qctask).split('\n')
        converted_text_part = converted_tokens[:2] + converted_tokens[11:]
        converted_coords_part = converted_tokens[2:11]
        self.assertEqual(ans_text_part, converted_text_part)
        for ans_coords, converted_coords in zip(ans_coords_part,
                                                converted_coords_part):
            ans_coords_tokens = ans_coords.split()
            converted_coords_tokens = converted_coords.split()
            self.assertEqual(ans_coords_tokens[0], converted_coords_tokens[0])
            xyz1 = ans_coords_tokens[1:]
            xyz2 = converted_coords_tokens[1:]
            for t1, t2 in zip(xyz1, xyz2):
                self.assertTrue(abs(float(t1)-float(t2)) < 0.0001)
Example #2
0
 def from_string_verify(self, contents, ref_dict):
     qctask = QcTask.from_string(contents)
     d2 = qctask.to_dict
     self.assertEqual(ref_dict, d2)