Exemplo n.º 1
0
 def test_freq_job_too_small(self):
     shutil.copyfile(os.path.join(test_dir, "freq_seg_too_small.qcinp"),
                     os.path.join(scr_dir, "freq_seg_too_small.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "freq_seg_too_small.qcout"),
                     os.path.join(scr_dir, "freq_seg_too_small.qcout"))
     h = QChemErrorHandler(input_file="freq_seg_too_small.qcinp",
                           output_file="freq_seg_too_small.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Exit Code 134',
                                     'Freq Job Too Small'],
                          'actions': ['use 31 segment in CPSCF']})
     with open(os.path.join(test_dir, "freq_seg_too_small_31_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "freq_seg_too_small.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     shutil.copyfile(os.path.join(test_dir, "freq_seg_too_small_31_segments.qcinp"),
                     os.path.join(scr_dir, "freq_seg_too_small_31_segments.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "freq_seg_too_small.qcout"),
                     os.path.join(scr_dir, "freq_seg_too_small.qcout"))
     h = QChemErrorHandler(input_file="freq_seg_too_small_31_segments.qcinp",
                           output_file="freq_seg_too_small.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Exit Code 134',
                                     'Freq Job Too Small'],
                          'actions': None})
Exemplo n.º 2
0
    def test_nan_error(self):
        shutil.copyfile(os.path.join(test_dir, "thiane_nan.inp"), os.path.join(scr_dir, "thiane_nan.inp"))
        shutil.copyfile(os.path.join(test_dir, "thiane_nan.out"), os.path.join(scr_dir, "thiane_nan.out"))
        h = QChemErrorHandler(input_file="thiane_nan.inp", output_file="thiane_nan.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {"errors": ["NAN values"], "actions": ["use tighter grid"]})
        with open(os.path.join(test_dir, "thiane_nan_dense_grid.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "thiane_nan.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)
        shutil.copyfile(
            os.path.join(test_dir, "thiane_nan_dense_grid.inp"), os.path.join(scr_dir, "thiane_nan_dense_grid.inp")
        )
        shutil.copyfile(os.path.join(test_dir, "thiane_nan.out"), os.path.join(scr_dir, "thiane_nan.out"))
        h = QChemErrorHandler(input_file="thiane_nan_dense_grid.inp", output_file="thiane_nan.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {"errors": ["NAN values"], "actions": None})

        shutil.copyfile(os.path.join(test_dir, "h2o_nan.qcinp"), os.path.join(scr_dir, "h2o_nan.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "h2o_nan.qcout"), os.path.join(scr_dir, "h2o_nan.qcout"))
        h = QChemErrorHandler(input_file="h2o_nan.qcinp", output_file="h2o_nan.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {"errors": ["NAN values"], "actions": ["use tighter grid"]})
        with open(os.path.join(test_dir, "h2o_nan_dense_grid.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "h2o_nan.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)
Exemplo n.º 3
0
    def test_autoz_error(self):
        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcinp"),
                        os.path.join(scr_dir, "qunino_vinyl.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcout"),
                        os.path.join(scr_dir, "qunino_vinyl.qcout"))
        h = QChemErrorHandler(input_file="qunino_vinyl.qcinp",
                              output_file="qunino_vinyl.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found',
                                        'autoz error'],
                             'actions': ['disable symmetry']})
        with open(os.path.join(test_dir, "qunino_vinyl_nosymm.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "qunino_vinyl.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl_nosymm.qcinp"),
                        os.path.join(scr_dir, "qunino_vinyl_nosymm.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcout"),
                        os.path.join(scr_dir, "qunino_vinyl.qcout"))
        h = QChemErrorHandler(input_file="qunino_vinyl_nosymm.qcinp",
                              output_file="qunino_vinyl.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found',
                                        'autoz error'],
                             'actions': None})
Exemplo n.º 4
0
 def test_freq_job_too_small(self):
     shutil.copyfile(
         os.path.join(test_dir, "freq_seg_too_small.qcinp"), os.path.join(scr_dir, "freq_seg_too_small.qcinp")
     )
     shutil.copyfile(
         os.path.join(test_dir, "freq_seg_too_small.qcout"), os.path.join(scr_dir, "freq_seg_too_small.qcout")
     )
     h = QChemErrorHandler(input_file="freq_seg_too_small.qcinp", output_file="freq_seg_too_small.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {"errors": ["Exit Code 134", "Freq Job Too Small"], "actions": ["use 31 segment in CPSCF"]})
     with open(os.path.join(test_dir, "freq_seg_too_small_31_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "freq_seg_too_small.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     shutil.copyfile(
         os.path.join(test_dir, "freq_seg_too_small_31_segments.qcinp"),
         os.path.join(scr_dir, "freq_seg_too_small_31_segments.qcinp"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "freq_seg_too_small.qcout"), os.path.join(scr_dir, "freq_seg_too_small.qcout")
     )
     h = QChemErrorHandler(input_file="freq_seg_too_small_31_segments.qcinp", output_file="freq_seg_too_small.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {"errors": ["Exit Code 134", "Freq Job Too Small"], "actions": None})
Exemplo n.º 5
0
 def test_not_enough_total_memory(self):
     old_jobid = os.environ.get("PBS_JOBID", None)
     os.environ["PBS_JOBID"] = "hopque473945"
     shutil.copyfile(
         os.path.join(test_dir, "not_enough_total_memory.qcinp"),
         os.path.join(scr_dir, "not_enough_total_memory.qcinp"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "not_enough_total_memory.qcout"),
         os.path.join(scr_dir, "not_enough_total_memory.qcout"),
     )
     h = QChemErrorHandler(input_file="not_enough_total_memory.qcinp", output_file="not_enough_total_memory.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d, {"errors": ["Exit Code 134", "Not Enough Total Memory"], "actions": ["Use 48 CPSCF segments"]}
     )
     with open(os.path.join(test_dir, "not_enough_total_memory_48_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "not_enough_total_memory.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     shutil.copyfile(
         os.path.join(test_dir, "not_enough_total_memory_48_segments.qcinp"),
         os.path.join(scr_dir, "not_enough_total_memory_48_segments.qcinp"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "not_enough_total_memory.qcout"),
         os.path.join(scr_dir, "not_enough_total_memory.qcout"),
     )
     qchem_job = QchemJob(
         qchem_cmd=["qchem", "-np", "24"],
         alt_cmd={"openmp": ["qchem", "-seq", "-nt", "24"], "half_cpus": ["qchem", "-np", "12"]},
         input_file="not_enough_total_memory_48_segments.qcinp",
     )
     h = QChemErrorHandler(
         input_file="not_enough_total_memory_48_segments.qcinp",
         output_file="not_enough_total_memory.qcout",
         qchem_job=qchem_job,
     )
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d,
         {
             "errors": ["Exit Code 134", "Not Enough Total Memory"],
             "actions": ["Use half CPUs and 60 CPSCF segments"],
         },
     )
     with open(os.path.join(test_dir, "not_enough_total_memory_60_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "not_enough_total_memory_48_segments.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     if old_jobid is None:
         os.environ.pop("PBS_JOBID")
     else:
         os.environ["PBS_JOBID"] = old_jobid
Exemplo n.º 6
0
    def test_autoz_error(self):
        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcinp"),
                        os.path.join(scr_dir, "qunino_vinyl.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcout"),
                        os.path.join(scr_dir, "qunino_vinyl.qcout"))
        h = QChemErrorHandler(input_file="qunino_vinyl.qcinp",
                              output_file="qunino_vinyl.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found',
                                        'autoz error'],
                             'actions': ['disable symmetry']})
        with open(os.path.join(test_dir, "qunino_vinyl_nosymm.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "qunino_vinyl.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl_nosymm.qcinp"),
                        os.path.join(scr_dir, "qunino_vinyl_nosymm.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcout"),
                        os.path.join(scr_dir, "qunino_vinyl.qcout"))
        h = QChemErrorHandler(input_file="qunino_vinyl_nosymm.qcinp",
                              output_file="qunino_vinyl.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found',
                                        'autoz error'],
                             'actions': None})
Exemplo n.º 7
0
    def test_scf_failed_to_converge(self):
        for ii in range(3):
            shutil.copyfile(
                os.path.join(test_dir, "crowd_gradient.qin." + str(ii)),
                os.path.join(scr_dir, "crowd_gradient.qin." + str(ii)),
            )
            shutil.copyfile(
                os.path.join(test_dir, "crowd_gradient.qout." + str(ii)),
                os.path.join(scr_dir, "crowd_gradient.qout." + str(ii)),
            )

        h = QChemErrorHandler(input_file="crowd_gradient.qin.0",
                              output_file="crowd_gradient.qout.0")
        h.check()
        d = h.correct()
        self.assertEqual(d["errors"], ["SCF_failed_to_converge"])
        self.assertEqual(d["actions"], [{"max_scf_cycles": 200}])
        self._check_equivalent_inputs("crowd_gradient.qin.0",
                                      "crowd_gradient.qin.1")

        h = QChemErrorHandler(input_file="crowd_gradient.qin.1",
                              output_file="crowd_gradient.qout.1")
        h.check()
        d = h.correct()
        self.assertEqual(d["errors"], ["SCF_failed_to_converge"])
        self.assertEqual(d["actions"], [{"thresh": "14"}])
Exemplo n.º 8
0
 def test_exit_code_134_after_scf_fix(self):
     shutil.copyfile(os.path.join(test_dir, "exit_134_after_scf_fix.qcinp"),
                     os.path.join(scr_dir, "exit_134_after_scf_fix.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "exit_134_after_scf_fix.qcout"),
                     os.path.join(scr_dir, "exit_134_after_scf_fix.qcout"))
     h = QChemErrorHandler(input_file="exit_134_after_scf_fix.qcinp",
                           output_file="exit_134_after_scf_fix.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d, {
             'errors': [
                 'Bad SCF convergence', 'Exit Code 134',
                 'Geometry optimization failed',
                 'Molecular charge is not found'
             ],
             'actions': ['use tight integral threshold']
         })
     with open(
             os.path.join(
                 test_dir,
                 "exit_134_after_scf_fix_tight_thresh.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "exit_134_after_scf_fix.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     shutil.copyfile(
         os.path.join(test_dir,
                      "exit_134_after_scf_fix_tight_thresh.qcinp"),
         os.path.join(scr_dir, "exit_134_after_scf_fix_tight_thresh.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "exit_134_after_scf_fix.qcout"),
                     os.path.join(scr_dir, "exit_134_after_scf_fix.qcout"))
     qchem_job = QchemJob(
         qchem_cmd=shlex.split("qchem -np 24"),
         input_file="exit_134_after_scf_fix_tight_thresh.qcinp",
         output_file="exit_134_after_scf_fix.qcout",
         alt_cmd={
             "half_cpus": shlex.split("qchem -np 12"),
             "openmp": shlex.split("qchem -nt 24")
         })
     h = QChemErrorHandler(
         input_file="exit_134_after_scf_fix_tight_thresh.qcinp",
         output_file="exit_134_after_scf_fix.qcout",
         qchem_job=qchem_job)
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d, {
             'errors': [
                 'Bad SCF convergence', 'Exit Code 134',
                 'Geometry optimization failed',
                 'Molecular charge is not found'
             ],
             'actions': ['openmp']
         })
Exemplo n.º 9
0
    def test_opt_failed(self):
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcinp"), os.path.join(scr_dir, "hf_opt_failed.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"), os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed.qcinp", output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {"errors": ["Geometry optimization failed"], "actions": ["increase_iter"]})
        with open(os.path.join(test_dir, "hf_opt_failed_tried_0.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_opt_failed.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(
            os.path.join(test_dir, "hf_opt_failed_tried_0.qcinp"), os.path.join(scr_dir, "hf_opt_failed_tried_0.qcinp")
        )
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"), os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed_tried_0.qcinp", output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {"errors": ["Geometry optimization failed"], "actions": ["GDIIS"]})
        with open(os.path.join(test_dir, "hf_opt_failed_tried_1.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_opt_failed_tried_0.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(
            os.path.join(test_dir, "hf_opt_failed_tried_1.qcinp"), os.path.join(scr_dir, "hf_opt_failed_tried_1.qcinp")
        )
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"), os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed_tried_1.qcinp", output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {"errors": ["Geometry optimization failed"], "actions": ["CartCoords"]})
        with open(os.path.join(test_dir, "hf_opt_failed_tried_2.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_opt_failed_tried_1.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(
            os.path.join(test_dir, "hf_opt_failed_tried_2.qcinp"), os.path.join(scr_dir, "hf_opt_failed_tried_2.qcinp")
        )
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"), os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed_tried_2.qcinp", output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {"errors": ["Geometry optimization failed"], "actions": None})
Exemplo n.º 10
0
 def test_json_serializable(self):
     q1 = QChemErrorHandler()
     str1 = json.dumps(q1, cls=MontyEncoder)
     q2 = json.loads(str1, cls=MontyDecoder)
     self.assertEqual(q1.as_dict(), q2.as_dict())
     shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcinp"), os.path.join(scr_dir, "qunino_vinyl.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcout"), os.path.join(scr_dir, "qunino_vinyl.qcout"))
     q3 = QChemErrorHandler(input_file="qunino_vinyl.qcinp", output_file="qunino_vinyl.qcout")
     q3.check()
     q3.correct()
     for od in q3.outdata:
         od.pop("input")
     str3 = json.dumps(q3, cls=MontyEncoder)
     q4 = json.loads(str3, cls=MontyDecoder)
     self.assertEqual(q3.as_dict(), q4.as_dict())
Exemplo n.º 11
0
    def test_nan_error(self):
        shutil.copyfile(os.path.join(test_dir, "thiane_nan.inp"),
                        os.path.join(scr_dir, "thiane_nan.inp"))
        shutil.copyfile(os.path.join(test_dir, "thiane_nan.out"),
                        os.path.join(scr_dir, "thiane_nan.out"))
        h = QChemErrorHandler(input_file="thiane_nan.inp",
                              output_file="thiane_nan.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {
            'errors': ['NAN values'],
            'actions': ['use tighter grid']
        })
        with open(os.path.join(test_dir, "thiane_nan_dense_grid.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "thiane_nan.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)
        shutil.copyfile(os.path.join(test_dir, "thiane_nan_dense_grid.inp"),
                        os.path.join(scr_dir, "thiane_nan_dense_grid.inp"))
        shutil.copyfile(os.path.join(test_dir, "thiane_nan.out"),
                        os.path.join(scr_dir, "thiane_nan.out"))
        h = QChemErrorHandler(input_file="thiane_nan_dense_grid.inp",
                              output_file="thiane_nan.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['NAN values'], 'actions': None})

        shutil.copyfile(os.path.join(test_dir, "h2o_nan.qcinp"),
                        os.path.join(scr_dir, "h2o_nan.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "h2o_nan.qcout"),
                        os.path.join(scr_dir, "h2o_nan.qcout"))
        h = QChemErrorHandler(input_file="h2o_nan.qcinp",
                              output_file="h2o_nan.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {
            'errors': ['NAN values'],
            'actions': ['use tighter grid']
        })
        with open(os.path.join(test_dir, "h2o_nan_dense_grid.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "h2o_nan.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)
Exemplo n.º 12
0
 def test_pcm_solvent_deprecated(self):
     shutil.copyfile(os.path.join(test_dir, "pcm_solvent_deprecated.qcinp"),
                     os.path.join(scr_dir, "pcm_solvent_deprecated.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "pcm_solvent_deprecated.qcout"),
                     os.path.join(scr_dir, "pcm_solvent_deprecated.qcout"))
     h = QChemErrorHandler(input_file="pcm_solvent_deprecated.qcinp",
                           output_file="pcm_solvent_deprecated.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d, {
             'errors': [
                 'Bad SCF convergence', 'Molecular charge is not found',
                 'No input text', 'pcm_solvent deprecated'
             ],
             'actions': ['use keyword solvent instead']
         })
     with open(
             os.path.join(
                 test_dir,
                 "pcm_solvent_deprecated_use_qc42_format.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "pcm_solvent_deprecated.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 13
0
 def test_pcm_solvent_deprecated(self):
     shutil.copyfile(
         os.path.join(test_dir, "pcm_solvent_deprecated.qcinp"),
         os.path.join(scr_dir, "pcm_solvent_deprecated.qcinp"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "pcm_solvent_deprecated.qcout"),
         os.path.join(scr_dir, "pcm_solvent_deprecated.qcout"),
     )
     h = QChemErrorHandler(input_file="pcm_solvent_deprecated.qcinp", output_file="pcm_solvent_deprecated.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d,
         {
             "errors": [
                 "Bad SCF convergence",
                 "Molecular charge is not found",
                 "No input text",
                 "pcm_solvent deprecated",
             ],
             "actions": ["use keyword solvent instead"],
         },
     )
     with open(os.path.join(test_dir, "pcm_solvent_deprecated_use_qc42_format.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "pcm_solvent_deprecated.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 14
0
 def test_unable_to_determine_lambda(self):
     shutil.copyfile(
         os.path.join(test_dir,
                      "unable_to_determine_lambda_in_geom_opt.qcinp"),
         os.path.join(scr_dir,
                      "unable_to_determine_lambda_in_geom_opt.qcinp"))
     shutil.copyfile(
         os.path.join(test_dir,
                      "unable_to_determine_lambda_in_geom_opt.qcout"),
         os.path.join(scr_dir,
                      "unable_to_determine_lambda_in_geom_opt.qcout"))
     h = QChemErrorHandler(
         input_file="unable_to_determine_lambda_in_geom_opt.qcinp",
         output_file="unable_to_determine_lambda_in_geom_opt.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d, {
             'errors':
             ['Geometry optimization failed', 'Lamda Determination Failed'],
             'actions': ['reset']
         })
     with open(
             os.path.join(
                 test_dir,
                 "unable_to_determine_lambda_in_geom_opt_reset.qcinp")
     ) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(
             os.path.join(
                 scr_dir,
                 "unable_to_determine_lambda_in_geom_opt.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 15
0
    def test_out_of_opt_cycles(self):
        shutil.copyfile(
            os.path.join(test_dir, "crowd_gradient.qin.2"),
            os.path.join(scr_dir, "crowd_gradient.qin.2"),
        )
        shutil.copyfile(
            os.path.join(test_dir, "crowd_gradient.qout.2"),
            os.path.join(scr_dir, "crowd_gradient.qout.2"),
        )
        shutil.copyfile(
            os.path.join(test_dir, "crowd_gradient.qin.3"),
            os.path.join(scr_dir, "crowd_gradient.qin.3"),
        )

        h = QChemErrorHandler(input_file="crowd_gradient.qin.2",
                              output_file="crowd_gradient.qout.2")
        h.check()
        d = h.correct()
        self.assertEqual(d["errors"], ["out_of_opt_cycles"])
        self.assertEqual(
            d["actions"],
            [{
                "geom_max_cycles:": 200
            }, {
                "molecule": "molecule_from_last_geometry"
            }],
        )
        self._check_equivalent_inputs("crowd_gradient.qin.2",
                                      "crowd_gradient.qin.3")
Exemplo n.º 16
0
 def test_advanced_out_of_opt_cycles(self):
     shutil.copyfile(
         os.path.join(test_dir, "2564_complete/error1/mol.qin"),
         os.path.join(scr_dir, "mol.qin"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "2564_complete/error1/mol.qout"),
         os.path.join(scr_dir, "mol.qout"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "2564_complete/mol.qin.opt_0"),
         os.path.join(scr_dir, "mol.qin.opt_0"),
     )
     h = QChemErrorHandler(input_file="mol.qin", output_file="mol.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ["out_of_opt_cycles"])
     self.assertEqual(d["actions"],
                      [{
                          "molecule": "molecule_from_last_geometry"
                      }])
     self._check_equivalent_inputs("mol.qin.opt_0", "mol.qin")
     self.assertEqual(h.opt_error_history[0], "more_bonds")
     shutil.copyfile(
         os.path.join(test_dir, "2564_complete/mol.qin.opt_0"),
         os.path.join(scr_dir, "mol.qin"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "2564_complete/mol.qout.opt_0"),
         os.path.join(scr_dir, "mol.qout"),
     )
     h.check()
     self.assertEqual(h.opt_error_history, [])
Exemplo n.º 17
0
 def test_OOS_read_hess(self):
     shutil.copyfile(
         os.path.join(test_dir, "OOS_read_hess.qin"),
         os.path.join(scr_dir, "mol.qin"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "OOS_read_hess.qout"),
         os.path.join(scr_dir, "mol.qout"),
     )
     h = QChemErrorHandler(input_file="mol.qin", output_file="mol.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ["out_of_opt_cycles"])
     self.assertEqual(
         d["actions"],
         [
             {
                 "molecule": "molecule_from_last_geometry"
             },
             {
                 "geom_opt_hessian": "deleted"
             },
         ],
     )
     self._check_equivalent_inputs(
         os.path.join(test_dir, "OOS_read_hess_next.qin"), "mol.qin")
Exemplo n.º 18
0
    def test_unable_to_determine_lamda(self):
        for ii in range(2):
            shutil.copyfile(
                os.path.join(test_dir,
                             "unable_to_determine_lamda.qin." + str(ii)),
                os.path.join(scr_dir,
                             "unable_to_determine_lamda.qin." + str(ii)),
            )
            shutil.copyfile(
                os.path.join(test_dir,
                             "unable_to_determine_lamda.qout." + str(ii)),
                os.path.join(scr_dir,
                             "unable_to_determine_lamda.qout." + str(ii)),
            )

        h = QChemErrorHandler(
            input_file="unable_to_determine_lamda.qin.0",
            output_file="unable_to_determine_lamda.qout.0",
        )
        h.check()
        d = h.correct()
        self.assertEqual(d["errors"], ["unable_to_determine_lamda"])
        self.assertEqual(d["actions"],
                         [{
                             "molecule": "molecule_from_last_geometry"
                         }])
        self._check_equivalent_inputs("unable_to_determine_lamda.qin.0",
                                      "unable_to_determine_lamda.qin.1")
Exemplo n.º 19
0
    def test_linear_dependent_basis(self):
        for ii in range(1, 3):
            shutil.copyfile(
                os.path.join(test_dir,
                             "unable_to_determine_lamda.qin." + str(ii)),
                os.path.join(scr_dir,
                             "unable_to_determine_lamda.qin." + str(ii)))
            shutil.copyfile(
                os.path.join(test_dir,
                             "unable_to_determine_lamda.qout." + str(ii)),
                os.path.join(scr_dir,
                             "unable_to_determine_lamda.qout." + str(ii)))

        h = QChemErrorHandler(input_file="unable_to_determine_lamda.qin.1",
                              output_file="unable_to_determine_lamda.qout.1")
        h.check()
        d = h.correct()
        self.assertEqual(d["errors"], ['linear_dependent_basis'])
        self.assertEqual(d["actions"], [{"scf_algorithm": "rca_diis"}])
        self._check_equivalent_inputs("unable_to_determine_lamda.qin.1",
                                      "unable_to_determine_lamda.qin.2")

        h = QChemErrorHandler(input_file="unable_to_determine_lamda.qin.2",
                              output_file="unable_to_determine_lamda.qout.2")
        self.assertEqual(h.check(), False)
Exemplo n.º 20
0
    def test_failed_to_transform(self):
        for ii in range(2):
            shutil.copyfile(
                os.path.join(test_dir, "qunino_vinyl.qin." + str(ii)),
                os.path.join(scr_dir, "qunino_vinyl.qin." + str(ii)),
            )
            shutil.copyfile(
                os.path.join(test_dir, "qunino_vinyl.qout." + str(ii)),
                os.path.join(scr_dir, "qunino_vinyl.qout." + str(ii)),
            )

        h = QChemErrorHandler(input_file="qunino_vinyl.qin.0",
                              output_file="qunino_vinyl.qout.0")
        h.check()
        d = h.correct()
        self.assertEqual(d["errors"], ["failed_to_transform_coords"])
        self.assertEqual(d["actions"], [{
            "sym_ignore": True
        }, {
            "symmetry": False
        }])
        self._check_equivalent_inputs("qunino_vinyl.qin.0",
                                      "qunino_vinyl.qin.1")

        h = QChemErrorHandler(input_file="qunino_vinyl.qin.1",
                              output_file="qunino_vinyl.qout.1")
        self.assertEqual(h.check(), False)
Exemplo n.º 21
0
 def test_not_enough_total_memory(self):
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory.qcinp"),
                     os.path.join(scr_dir, "not_enough_total_memory.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory.qcout"),
                     os.path.join(scr_dir, "not_enough_total_memory.qcout"))
     qchem_job = QchemJob(qchem_cmd=shlex.split("qchem -np 24"),
                          input_file="not_enough_total_memory.qcinp",
                          output_file="not_enough_total_memory.qcout",
                          alt_cmd={"half_cpus": shlex.split("qchem -np 12"),
                                   "openmp": shlex.split("qchem -nt 24")},
                          total_physical_memory=120)
     h = QChemErrorHandler(input_file="not_enough_total_memory.qcinp",
                           output_file="not_enough_total_memory.qcout", qchem_job=qchem_job)
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Exit Code 134',
                                     'Not Enough Total Memory'],
                          'actions': ['Use 48 CPSCF segments']})
     with open(os.path.join(test_dir, "not_enough_total_memory_48_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "not_enough_total_memory.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory_48_segments.qcinp"),
                     os.path.join(scr_dir, "not_enough_total_memory_48_segments.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory.qcout"),
                     os.path.join(scr_dir, "not_enough_total_memory.qcout"))
     qchem_job = QchemJob(qchem_cmd=["qchem", "-np", "24"],
                          alt_cmd={"openmp": ["qchem", "-seq", "-nt", "24"],
                                   "half_cpus": ["qchem", "-np", "12"]},
                          input_file="not_enough_total_memory_48_segments.qcinp")
     h = QChemErrorHandler(input_file="not_enough_total_memory_48_segments.qcinp",
                           output_file="not_enough_total_memory.qcout",
                           qchem_job=qchem_job)
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Exit Code 134',
                                     'Not Enough Total Memory'],
                          'actions': ['Use half CPUs and 60 CPSCF segments']})
     with open(os.path.join(test_dir, "not_enough_total_memory_60_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "not_enough_total_memory_48_segments.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 22
0
    def test_negative_eigen(self):
        shutil.copyfile(os.path.join(test_dir, "negative_eigen.qcinp"),
                        os.path.join(scr_dir, "negative_eigen.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "negative_eigen.qcout"),
                        os.path.join(scr_dir, "negative_eigen.qcout"))
        h = QChemErrorHandler(input_file="negative_eigen.qcinp",
                              output_file="negative_eigen.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d, {
                'errors': [
                    'Bad SCF convergence', 'Molecular charge is not found',
                    'Negative Eigen'
                ],
                'actions': ['use tight integral threshold']
            })
        with open(os.path.join(test_dir, "negative_eigen_tried_1.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "negative_eigen.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "negative_eigen_tried_1.qcinp"),
                        os.path.join(scr_dir, "negative_eigen_tried_1.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "negative_eigen.qcout"),
                        os.path.join(scr_dir, "negative_eigen.qcout"))
        h = QChemErrorHandler(input_file="negative_eigen_tried_1.qcinp",
                              output_file="negative_eigen.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d, {
                'errors': [
                    'Bad SCF convergence', 'Molecular charge is not found',
                    'Negative Eigen'
                ],
                'actions': ['use even tighter integral threshold']
            })
        with open(os.path.join(test_dir, "negative_eigen_tried_2.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "negative_eigen_tried_1.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)
Exemplo n.º 23
0
 def test_not_enough_total_memory(self):
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory.qcinp"),
                     os.path.join(scr_dir, "not_enough_total_memory.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory.qcout"),
                     os.path.join(scr_dir, "not_enough_total_memory.qcout"))
     qchem_job = QchemJob(qchem_cmd=shlex.split("qchem -np 24"),
                          input_file="not_enough_total_memory.qcinp",
                          output_file="not_enough_total_memory.qcout",
                          alt_cmd={"half_cpus": shlex.split("qchem -np 12"),
                                   "openmp": shlex.split("qchem -nt 24")},
                          total_physical_memory=120)
     h = QChemErrorHandler(input_file="not_enough_total_memory.qcinp",
                           output_file="not_enough_total_memory.qcout", qchem_job=qchem_job)
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Exit Code 134',
                                     'Not Enough Total Memory'],
                          'actions': ['Use 48 CPSCF segments']})
     with open(os.path.join(test_dir, "not_enough_total_memory_48_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "not_enough_total_memory.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory_48_segments.qcinp"),
                     os.path.join(scr_dir, "not_enough_total_memory_48_segments.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "not_enough_total_memory.qcout"),
                     os.path.join(scr_dir, "not_enough_total_memory.qcout"))
     qchem_job = QchemJob(qchem_cmd=["qchem", "-np", "24"],
                          alt_cmd={"openmp": ["qchem", "-seq", "-nt", "24"],
                                   "half_cpus": ["qchem", "-np", "12"]},
                          input_file="not_enough_total_memory_48_segments.qcinp")
     h = QChemErrorHandler(input_file="not_enough_total_memory_48_segments.qcinp",
                           output_file="not_enough_total_memory.qcout",
                           qchem_job=qchem_job)
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Exit Code 134',
                                     'Not Enough Total Memory'],
                          'actions': ['Use half CPUs and 60 CPSCF segments']})
     with open(os.path.join(test_dir, "not_enough_total_memory_60_segments.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "not_enough_total_memory_48_segments.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 24
0
 def test_json_serializable(self):
     q1 = QChemErrorHandler()
     str1 = json.dumps(q1, cls=MontyEncoder)
     q2 = json.loads(str1, cls=MontyDecoder)
     self.assertEqual(q1.as_dict(), q2.as_dict())
     shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcinp"),
                     os.path.join(scr_dir, "qunino_vinyl.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "qunino_vinyl.qcout"),
                     os.path.join(scr_dir, "qunino_vinyl.qcout"))
     q3 = QChemErrorHandler(input_file="qunino_vinyl.qcinp",
                            output_file="qunino_vinyl.qcout")
     q3.check()
     q3.correct()
     for od in q3.outdata:
         od.pop("input")
     str3 = json.dumps(q3, cls=MontyEncoder)
     q4 = json.loads(str3, cls=MontyDecoder)
     self.assertEqual(q3.as_dict(), q4.as_dict())
Exemplo n.º 25
0
 def test_never_called_qchem_error(self):
     shutil.copyfile(os.path.join(test_dir, "mpi_error/mol.qin"),
                     os.path.join(scr_dir, "mol.qin"))
     shutil.copyfile(os.path.join(test_dir, "mpi_error/mol.qout"),
                     os.path.join(scr_dir, "mol.qout"))
     h = QChemErrorHandler(input_file="mol.qin", output_file="mol.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ['never_called_qchem'])
     self.assertEqual(d["actions"], [{"rerun job as-is"}])
     self._check_equivalent_inputs("mol.qin.last", "mol.qin")
Exemplo n.º 26
0
 def test_input_file_error(self):
     shutil.copyfile(os.path.join(test_dir, "bad_input.qin"),
                     os.path.join(scr_dir, "bad_input.qin"))
     shutil.copyfile(os.path.join(test_dir, "bad_input.qout"),
                     os.path.join(scr_dir, "bad_input.qout"))
     h = QChemErrorHandler(input_file="bad_input.qin",
                           output_file="bad_input.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ['input_file_error'])
     self.assertEqual(d["actions"], None)
Exemplo n.º 27
0
    def test_negative_eigen(self):
        shutil.copyfile(os.path.join(test_dir, "negative_eigen.qcinp"), os.path.join(scr_dir, "negative_eigen.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "negative_eigen.qcout"), os.path.join(scr_dir, "negative_eigen.qcout"))
        h = QChemErrorHandler(input_file="negative_eigen.qcinp", output_file="negative_eigen.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Molecular charge is not found", "Negative Eigen"],
                "actions": ["use tight integral threshold"],
            },
        )
        with open(os.path.join(test_dir, "negative_eigen_tried_1.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "negative_eigen.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(
            os.path.join(test_dir, "negative_eigen_tried_1.qcinp"),
            os.path.join(scr_dir, "negative_eigen_tried_1.qcinp"),
        )
        shutil.copyfile(os.path.join(test_dir, "negative_eigen.qcout"), os.path.join(scr_dir, "negative_eigen.qcout"))
        h = QChemErrorHandler(input_file="negative_eigen_tried_1.qcinp", output_file="negative_eigen.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Molecular charge is not found", "Negative Eigen"],
                "actions": ["use even tighter integral threshold"],
            },
        )
        with open(os.path.join(test_dir, "negative_eigen_tried_2.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "negative_eigen_tried_1.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)
Exemplo n.º 28
0
 def test_exit_code_134_after_scf_fix(self):
     shutil.copyfile(os.path.join(test_dir, "exit_134_after_scf_fix.qcinp"),
                     os.path.join(scr_dir, "exit_134_after_scf_fix.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "exit_134_after_scf_fix.qcout"),
                     os.path.join(scr_dir, "exit_134_after_scf_fix.qcout"))
     h = QChemErrorHandler(input_file="exit_134_after_scf_fix.qcinp",
                           output_file="exit_134_after_scf_fix.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                     'Exit Code 134',
                                     'Geometry optimization failed',
                                     'Molecular charge is not found'],
                          'actions': ['use tight integral threshold']})
     with open(os.path.join(test_dir, "exit_134_after_scf_fix_tight_thresh.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "exit_134_after_scf_fix.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
     shutil.copyfile(os.path.join(test_dir, "exit_134_after_scf_fix_tight_thresh.qcinp"),
                     os.path.join(scr_dir, "exit_134_after_scf_fix_tight_thresh.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "exit_134_after_scf_fix.qcout"),
                     os.path.join(scr_dir, "exit_134_after_scf_fix.qcout"))
     qchem_job = QchemJob(qchem_cmd="qchem -np 24",
                          input_file="exit_134_after_scf_fix_tight_thresh.qcinp",
                          output_file="exit_134_after_scf_fix.qcout",
                          alt_cmd={"half_cpus": "qchem -np 12",
                                   "openmp": "qchem -nt 24"})
     h = QChemErrorHandler(input_file="exit_134_after_scf_fix_tight_thresh.qcinp",
                           output_file="exit_134_after_scf_fix.qcout",
                           qchem_job=qchem_job)
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                     'Exit Code 134',
                                     'Geometry optimization failed',
                                     'Molecular charge is not found'],
                          'actions': ['half_cpus']})
Exemplo n.º 29
0
 def test_scf_in_aimd_reset(self):
     shutil.copyfile(os.path.join(test_dir, "h2o_aimd.qcinp"), os.path.join(scr_dir, "h2o_aimd.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "h2o_aimd.qcout"), os.path.join(scr_dir, "h2o_aimd.qcout"))
     h = QChemErrorHandler(input_file="h2o_aimd.qcinp", output_file="h2o_aimd.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {"errors": ["Bad SCF convergence"], "actions": ["reset"]})
     with open(os.path.join(test_dir, "h2o_aimd_reset.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "h2o_aimd.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 30
0
 def test_scf_reset(self):
     shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_1.inp"), os.path.join(scr_dir, "hf_scf_reset.inp"))
     shutil.copyfile(os.path.join(test_dir, "hf_scf_reset.out"), os.path.join(scr_dir, "hf_scf_reset.out"))
     h = QChemErrorHandler(input_file="hf_scf_reset.inp", output_file="hf_scf_reset.out")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {"errors": ["Bad SCF convergence", "Geometry optimization failed"], "actions": ["reset"]})
     with open(os.path.join(test_dir, "hf_scf_reset.inp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "hf_scf_reset.inp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 31
0
 def test_failed_to_read_input(self):
     shutil.copyfile(os.path.join(test_dir, "unable_lamda_weird.qin"),
                     os.path.join(scr_dir, "unable_lamda_weird.qin"))
     shutil.copyfile(os.path.join(test_dir, "unable_lamda_weird.qout"),
                     os.path.join(scr_dir, "unable_lamda_weird.qout"))
     h = QChemErrorHandler(input_file="unable_lamda_weird.qin",
                           output_file="unable_lamda_weird.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ['failed_to_read_input'])
     self.assertEqual(d["actions"], [{"rerun job as-is"}])
     self._check_equivalent_inputs("unable_lamda_weird.qin.last",
                                   "unable_lamda_weird.qin")
Exemplo n.º 32
0
 def test_ts_opt(self):
     shutil.copyfile(os.path.join(test_dir, "ts_cf3_leave.qcinp"), os.path.join(scr_dir, "ts_cf3_leave.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "ts_cf3_leave.qcout"), os.path.join(scr_dir, "ts_cf3_leave.qcout"))
     h = QChemErrorHandler(input_file="ts_cf3_leave.qcinp", output_file="ts_cf3_leave.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {"errors": ["Exit Code 134", "Geometry optimization failed"], "actions": ["increase_iter"]})
     with open(os.path.join(test_dir, "ts_cf3_leave_reset_first_step_mol.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "ts_cf3_leave.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 33
0
 def test_read_error(self):
     shutil.copyfile(
         os.path.join(test_dir, "molecule_read_error/mol.qin"),
         os.path.join(scr_dir, "mol.qin"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "molecule_read_error/mol.qout"),
         os.path.join(scr_dir, "mol.qout"),
     )
     h = QChemErrorHandler(input_file="mol.qin", output_file="mol.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ["read_molecule_error"])
     self.assertEqual(d["actions"], [{"rerun_job_no_changes": True}])
     self._check_equivalent_inputs("mol.qin.last", "mol.qin")
Exemplo n.º 34
0
 def test_NLebdevPts(self):
     shutil.copyfile(
         os.path.join(test_dir, "lebdevpts.qin"),
         os.path.join(scr_dir, "lebdevpts.qin"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "lebdevpts.qout"),
         os.path.join(scr_dir, "lebdevpts.qout"),
     )
     h = QChemErrorHandler(input_file="lebdevpts.qin",
                           output_file="lebdevpts.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ["NLebdevPts"])
     self.assertEqual(d["actions"], [{"esp_surface_density": "250"}])
Exemplo n.º 35
0
 def test_basis_not_supported(self):
     shutil.copyfile(
         os.path.join(test_dir, "basis_not_supported.qin"),
         os.path.join(scr_dir, "basis_not_supported.qin"),
     )
     shutil.copyfile(
         os.path.join(test_dir, "basis_not_supported.qout"),
         os.path.join(scr_dir, "basis_not_supported.qout"),
     )
     h = QChemErrorHandler(input_file="basis_not_supported.qin",
                           output_file="basis_not_supported.qout")
     h.check()
     d = h.correct()
     self.assertEqual(d["errors"], ["basis_not_supported"])
     self.assertEqual(d["actions"], None)
Exemplo n.º 36
0
 def test_scf_in_aimd_reset(self):
     shutil.copyfile(os.path.join(test_dir, "h2o_aimd.qcinp"),
                     os.path.join(scr_dir, "h2o_aimd.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "h2o_aimd.qcout"),
                     os.path.join(scr_dir, "h2o_aimd.qcout"))
     h = QChemErrorHandler(input_file="h2o_aimd.qcinp",
                           output_file="h2o_aimd.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Bad SCF convergence'],
                          'actions': ['reset']})
     with open(os.path.join(test_dir, "h2o_aimd_reset.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "h2o_aimd.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 37
0
 def test_scf_reset(self):
     shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_1.inp"),
                     os.path.join(scr_dir, "hf_scf_reset.inp"))
     shutil.copyfile(os.path.join(test_dir, "hf_scf_reset.out"),
                     os.path.join(scr_dir, "hf_scf_reset.out"))
     h = QChemErrorHandler(input_file="hf_scf_reset.inp",
                           output_file="hf_scf_reset.out")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                     'Geometry optimization failed'],
                          'actions': ['reset']})
     with open(os.path.join(test_dir, "hf_scf_reset.inp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "hf_scf_reset.inp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 38
0
 def test_ts_opt(self):
     shutil.copyfile(os.path.join(test_dir, "ts_cf3_leave.qcinp"),
                     os.path.join(scr_dir, "ts_cf3_leave.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "ts_cf3_leave.qcout"),
                     os.path.join(scr_dir, "ts_cf3_leave.qcout"))
     h = QChemErrorHandler(input_file="ts_cf3_leave.qcinp",
                           output_file="ts_cf3_leave.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Exit Code 134',
                                     'Geometry optimization failed'],
                          'actions': ['increase_iter']})
     with open(os.path.join(test_dir, "ts_cf3_leave_reset_first_step_mol.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "ts_cf3_leave.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 39
0
 def test_unable_to_determine_lambda(self):
     shutil.copyfile(os.path.join(test_dir, "unable_to_determine_lambda_in_geom_opt.qcinp"),
                     os.path.join(scr_dir, "unable_to_determine_lambda_in_geom_opt.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "unable_to_determine_lambda_in_geom_opt.qcout"),
                     os.path.join(scr_dir, "unable_to_determine_lambda_in_geom_opt.qcout"))
     h = QChemErrorHandler(input_file="unable_to_determine_lambda_in_geom_opt.qcinp",
                           output_file="unable_to_determine_lambda_in_geom_opt.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Geometry optimization failed',
                                     'Lamda Determination Failed'],
                          'actions': ['reset']})
     with open(os.path.join(test_dir, "unable_to_determine_lambda_in_geom_opt_reset.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "unable_to_determine_lambda_in_geom_opt.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 40
0
 def test_exit_code_134(self):
     shutil.copyfile(os.path.join(test_dir, "exit_code_134.qcinp"), os.path.join(scr_dir, "exit_code_134.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "exit_code_134.qcout"), os.path.join(scr_dir, "exit_code_134.qcout"))
     h = QChemErrorHandler(input_file="exit_code_134.qcinp", output_file="exit_code_134.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d,
         {
             "errors": ["Bad SCF convergence", "Exit Code 134", "Molecular charge is not found"],
             "actions": ["use tight integral threshold"],
         },
     )
     with open(os.path.join(test_dir, "exit_code_134_tight_thresh.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "exit_code_134.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 41
0
 def test_no_input_text(self):
     shutil.copyfile(os.path.join(test_dir, "no_reading.qcinp"), os.path.join(scr_dir, "no_reading.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "no_reading.qcout"), os.path.join(scr_dir, "no_reading.qcout"))
     h = QChemErrorHandler(input_file="no_reading.qcinp", output_file="no_reading.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d,
         {
             "errors": ["Bad SCF convergence", "Exit Code 134", "Molecular charge is not found", "No input text"],
             "actions": ["disable symmetry"],
         },
     )
     with open(os.path.join(test_dir, "no_reading_nosymm.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "no_reading.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 42
0
 def test_scf_fon(self):
     shutil.copyfile(os.path.join(test_dir, "hf_rca_hit_5.inp"),
                     os.path.join(scr_dir, "hf_rca_hit_5.inp"))
     shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                     os.path.join(scr_dir, "hf_rca.out"))
     h = QChemErrorHandler(input_file="hf_rca_hit_5.inp",
                           output_file="hf_rca.out")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                     'Geometry optimization failed',
                                     'Molecular charge is not found'],
                          'actions': ['fon']})
     with open(os.path.join(test_dir, "hf_rca_hit_5_fon.inp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "hf_rca_hit_5.inp")) as f:
         ans = [line.strip() for line in f.readlines()]
     ans = self._revert_scf_fix_strategy_to_version(ans, fix_version="2.0")
     self.assertEqual(ref, ans)
Exemplo n.º 43
0
 def test_no_input_text(self):
     shutil.copyfile(os.path.join(test_dir, "no_reading.qcinp"),
                     os.path.join(scr_dir, "no_reading.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "no_reading.qcout"),
                     os.path.join(scr_dir, "no_reading.qcout"))
     h = QChemErrorHandler(input_file="no_reading.qcinp",
                           output_file="no_reading.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                     'Exit Code 134',
                                     'Molecular charge is not found',
                                     'No input text'],
                          'actions': ['disable symmetry']})
     with open(os.path.join(test_dir, "no_reading_nosymm.qcinp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "no_reading.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 44
0
 def test_exit_code_134(self):
     shutil.copyfile(os.path.join(test_dir, "exit_code_134.qcinp"),
                     os.path.join(scr_dir, "exit_code_134.qcinp"))
     shutil.copyfile(os.path.join(test_dir, "exit_code_134.qcout"),
                     os.path.join(scr_dir, "exit_code_134.qcout"))
     h = QChemErrorHandler(input_file="exit_code_134.qcinp",
                           output_file="exit_code_134.qcout")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                     'Exit Code 134',
                                     'Molecular charge is not found'],
                          'actions': ['use tight integral threshold']})
     with open(os.path.join(test_dir, "exit_code_134_tight_thresh.qcinp"))\
             as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "exit_code_134.qcinp")) as f:
         ans = [line.strip() for line in f.readlines()]
     self.assertEqual(ref, ans)
Exemplo n.º 45
0
 def test_scf_fon(self):
     shutil.copyfile(os.path.join(test_dir, "hf_rca_hit_5.inp"), os.path.join(scr_dir, "hf_rca_hit_5.inp"))
     shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
     h = QChemErrorHandler(input_file="hf_rca_hit_5.inp", output_file="hf_rca.out")
     has_error = h.check()
     self.assertTrue(has_error)
     d = h.correct()
     self.assertEqual(
         d,
         {
             "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
             "actions": ["fon"],
         },
     )
     with open(os.path.join(test_dir, "hf_rca_hit_5_fon.inp")) as f:
         ref = [line.strip() for line in f.readlines()]
     with open(os.path.join(scr_dir, "hf_rca_hit_5.inp")) as f:
         ans = [line.strip() for line in f.readlines()]
     ans = self._revert_scf_fix_strategy_to_version(ans, fix_version="2.0")
     self.assertEqual(ref, ans)
Exemplo n.º 46
0
    def test_linear_dependent_basis_and_FileMan(self):
        for ii in range(1, 3):
            shutil.copyfile(
                os.path.join(test_dir,
                             "unable_to_determine_lamda.qin." + str(ii)),
                os.path.join(scr_dir,
                             "unable_to_determine_lamda.qin." + str(ii)))
            shutil.copyfile(
                os.path.join(test_dir,
                             "unable_to_determine_lamda.qout." + str(ii)),
                os.path.join(scr_dir,
                             "unable_to_determine_lamda.qout." + str(ii)))

        h = QChemErrorHandler(
            input_file="unable_to_determine_lamda.qin.1",
            output_file="unable_to_determine_lamda.qout.1")
        h.check()
        d = h.correct()
        self.assertEqual(d["errors"], ['premature_end_FileMan_error'])
        self.assertEqual(d["warnings"]["linear_dependence"], True)
        self.assertEqual(d["actions"], [{"thresh": "14"}])
Exemplo n.º 47
0
    def test_scf_rca(self):
        shutil.copyfile(os.path.join(test_dir, "hf_rca.inp"), os.path.join(scr_dir, "hf_rca.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca.inp", output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
                "actions": ["increase_iter"],
            },
        )
        with open(os.path.join(test_dir, "hf_rca_tried_0.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        ans = self._revert_scf_fix_strategy_to_version(ans, fix_version="1.0")
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_0.inp"), os.path.join(scr_dir, "hf_rca_tried_0.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_0.inp", output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
                "actions": ["rca_diis"],
            },
        )
        with open(os.path.join(test_dir, "hf_rca_tried_1.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_0.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_1.inp"), os.path.join(scr_dir, "hf_rca_tried_1.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_1.inp", output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
                "actions": ["gwh"],
            },
        )
        with open(os.path.join(test_dir, "hf_rca_tried_2.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_1.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_2.inp"), os.path.join(scr_dir, "hf_rca_tried_2.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_2.inp", output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
                "actions": ["gdm"],
            },
        )
        with open(os.path.join(test_dir, "hf_rca_tried_3.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_2.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_3.inp"), os.path.join(scr_dir, "hf_rca_tried_3.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_3.inp", output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
                "actions": ["rca"],
            },
        )
        with open(os.path.join(test_dir, "hf_rca_tried_4.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_3.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_4.inp"), os.path.join(scr_dir, "hf_rca_tried_4.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_4.inp", output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
                "actions": ["core+rca"],
            },
        )
        with open(os.path.join(test_dir, "hf_rca_tried_5.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_4.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_5.inp"), os.path.join(scr_dir, "hf_rca_tried_5.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"), os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_5.inp", output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d,
            {
                "errors": ["Bad SCF convergence", "Geometry optimization failed", "Molecular charge is not found"],
                "actions": None,
            },
        )
Exemplo n.º 48
0
    def test_opt_failed(self):
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcinp"),
                        os.path.join(scr_dir, "hf_opt_failed.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"),
                        os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed.qcinp",
                              output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(
            d, {
                'errors': ['Geometry optimization failed'],
                'actions': ['increase_iter']
            })
        with open(os.path.join(test_dir, "hf_opt_failed_tried_0.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_opt_failed.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed_tried_0.qcinp"),
                        os.path.join(scr_dir, "hf_opt_failed_tried_0.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"),
                        os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed_tried_0.qcinp",
                              output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {
            'errors': ['Geometry optimization failed'],
            'actions': ['GDIIS']
        })
        with open(os.path.join(test_dir, "hf_opt_failed_tried_1.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_opt_failed_tried_0.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed_tried_1.qcinp"),
                        os.path.join(scr_dir, "hf_opt_failed_tried_1.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"),
                        os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed_tried_1.qcinp",
                              output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {
            'errors': ['Geometry optimization failed'],
            'actions': ['CartCoords']
        })
        with open(os.path.join(test_dir, "hf_opt_failed_tried_2.qcinp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_opt_failed_tried_1.qcinp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed_tried_2.qcinp"),
                        os.path.join(scr_dir, "hf_opt_failed_tried_2.qcinp"))
        shutil.copyfile(os.path.join(test_dir, "hf_opt_failed.qcout"),
                        os.path.join(scr_dir, "hf_opt_failed.qcout"))
        h = QChemErrorHandler(input_file="hf_opt_failed_tried_2.qcinp",
                              output_file="hf_opt_failed.qcout")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {
            'errors': ['Geometry optimization failed'],
            'actions': None
        })
Exemplo n.º 49
0
    def test_scf_rca(self):
        shutil.copyfile(os.path.join(test_dir, "hf_rca.inp"),
                        os.path.join(scr_dir, "hf_rca.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                        os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca.inp",
                              output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found'],
                             'actions': ['increase_iter']})
        with open(os.path.join(test_dir, "hf_rca_tried_0.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_0.inp"),
                        os.path.join(scr_dir, "hf_rca_tried_0.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                        os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_0.inp",
                              output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found'],
                             'actions': ['rca_diis']})
        with open(os.path.join(test_dir, "hf_rca_tried_1.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_0.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_1.inp"),
                        os.path.join(scr_dir, "hf_rca_tried_1.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                        os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_1.inp",
                              output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found'],
                             'actions': ['gwh']})
        with open(os.path.join(test_dir, "hf_rca_tried_2.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_1.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_2.inp"),
                        os.path.join(scr_dir, "hf_rca_tried_2.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                        os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_2.inp",
                              output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found'],
                             'actions': ['gdm']})
        with open(os.path.join(test_dir, "hf_rca_tried_3.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_2.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_3.inp"),
                        os.path.join(scr_dir, "hf_rca_tried_3.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                        os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_3.inp",
                              output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found'],
                             'actions': ['rca']})
        with open(os.path.join(test_dir, "hf_rca_tried_4.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_3.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_4.inp"),
                        os.path.join(scr_dir, "hf_rca_tried_4.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                        os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_4.inp",
                              output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found'],
                             'actions': ['core+rca']})
        with open(os.path.join(test_dir, "hf_rca_tried_5.inp")) as f:
            ref = [line.strip() for line in f.readlines()]
        with open(os.path.join(scr_dir, "hf_rca_tried_4.inp")) as f:
            ans = [line.strip() for line in f.readlines()]
        self.assertEqual(ref, ans)

        shutil.copyfile(os.path.join(test_dir, "hf_rca_tried_5.inp"),
                        os.path.join(scr_dir, "hf_rca_tried_5.inp"))
        shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
                        os.path.join(scr_dir, "hf_rca.out"))
        h = QChemErrorHandler(input_file="hf_rca_tried_5.inp",
                              output_file="hf_rca.out")
        has_error = h.check()
        self.assertTrue(has_error)
        d = h.correct()
        self.assertEqual(d, {'errors': ['Bad SCF convergence',
                                        'Geometry optimization failed',
                                        'Molecular charge is not found'],
                             'actions': None})