def test_disable_symmetry(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* sym_ignore = True symmetry = False $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.disable_symmetry() self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_use_cosmo(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* solvent_dielectric = 35.0 solvent_method = cosmo $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.use_cosmo(dielectric_constant=35.0) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_scale_geom_opt_threshold(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* geom_opt_tol_displacement = 120 geom_opt_tol_energy = 10 geom_opt_tol_gradient = 30 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.scale_geom_opt_threshold(gradient=0.1, displacement=0.1, energy=0.1) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_set_geom_opt_use_gdiis(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* geom_opt_max_diis = -1 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.set_geom_opt_use_gdiis() self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_set_dft_grid(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* xc_grid = 000110000590 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.set_dft_grid(radical_points=110, angular_points=590) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_geom_opt_max_cycles(self): ans = '''$comments Test Methane $end $molecule 1 2 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* geom_opt_max_cycles = 100 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", charge=1, spin_multiplicity=2, basis_set="6-31+G*") qctask.set_geom_max_iterations(100) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_set_scf_initial_guess(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* scf_guess = gwh $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.set_scf_initial_guess("GWH") self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_set_max_scf_iterations(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* max_scf_cycles = 100 scf_algorithm = diis_gdm $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.set_scf_algorithm_and_iterations(algorithm="diis_gdm", iterations=100) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_set_memory(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* mem_static = 500 mem_total = 18000 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.set_memory(total=18000, static=500) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_set_integral_threshold(self): ans = '''$comment Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* thresh = 14 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.set_integral_threshold(thresh=14) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def test_set_max_num_of_scratch_files(self): ans = '''$comment Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* max_sub_file_num = 500 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.set_max_num_of_scratch_files(500) self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
def to_and_from_dict_verify(self, qctask): """ Helper function. This function should be called in each specific test. """ d1 = qctask.to_dict qc2 = QcTask.from_dict(d1) d2 = qc2.to_dict self.assertEqual(d1, d2)
def from_dict(cls, d): h = QChemErrorHandler(input_file=d["input_file"], output_file=d["output_file"], ex_backup_list=d["ex_backup_list"], rca_gdm_thresh=d["rca_gdm_thresh"], scf_max_cycles=d["scf_max_cycles"], geom_max_cycles=d["geom_max_cycles"]) h.outdata = d["outdata"] h.qcinp = QcInput.from_dict(d["qcinp"]) if d["qcinp"] else None h.error_step_id = d["error_step_id"] h.errors = d["errors"] h.fix_step = QcTask.from_dict(d["fix_step"]) if d["fix_step"] else None return h
def test_use_pcm(self): ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* solvent_method = pcm $end $pcm radii uff theory ssvpe vdwscale 1.1 $end $pcm_solvent dielectric 78.3553 $end ''' qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.use_pcm() self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask) qctask = QcTask(mol, title="Test Methane", exchange="B3LYP", jobtype="SP", basis_set="6-31+G*") qctask.use_pcm(pcm_params={"Radii": "FF", "Theory": "CPCM", "SASrad": 1.5, "HPoints": 1202}, solvent_params={"Dielectric": 20.0, "Temperature": 300.75, "NSolventAtoms": 2, "SolventAtom": [[8, 1, 186, 1.30], [1, 2, 187, 1.01]]}, radii_force_field="OPLSAA") ans = '''$comments Test Methane $end $molecule 0 1 C 0.00000000 0.00000000 0.00000000 H 0.00000000 0.00000000 1.08900000 H 1.02671900 0.00000000 -0.36300000 H -0.51336000 -0.88916500 -0.36300000 Cl -0.51336000 0.88916500 -0.36300000 $end $rem jobtype = sp exchange = b3lyp basis = 6-31+g* force_fied = oplsaa solvent_method = pcm $end $pcm hpoints 1202 radii bondi sasrad 1.5 theory cpcm vdwscale 1.1 $end $pcm_solvent dielectric 20.0 nsolventatoms 2 solventatom 8 1 186 1.30 solventatom 1 2 187 1.01 temperature 300.75 $end ''' self.assertEqual(str(qctask), ans) self.elementary_io_verify(ans, qctask)
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)
def from_string_verify(self, contents, ref_dict): qctask = QcTask.from_string(contents) d2 = qctask.to_dict self.assertEqual(ref_dict, d2)