コード例 #1
0
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(
         qchem_command="qchem -slurm",
         max_cores=32,
         input_file="mol.qin",
         output_file="mol.qout",
         linked=True,
         transition_state=True,
         freq_before_opt=True,
     )
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".freq_pre",
         save_scratch=True,
         backup=True,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".ts_0",
         save_scratch=True,
         backup=False,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(os.path.join(test_dir, "fftsopt_freqfirst/mol.qin.ts_0")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict(),
     )
     shutil.copyfile(
         os.path.join(scr_dir, "mol.qin"),
         os.path.join(scr_dir, "mol.qin.ts_0"),
     )
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".freq_0",
         save_scratch=True,
         backup=False,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(os.path.join(test_dir, "fftsopt_freqfirst/mol.qin.freq_0")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict(),
     )
     shutil.copyfile(
         os.path.join(scr_dir, "mol.qin"),
         os.path.join(scr_dir, "mol.qin.freq_0"),
     )
     self.assertRaises(StopIteration, myjob.__next__)
コード例 #2
0
ファイル: test_jobs.py プロジェクト: yimingchen-eng/custodian
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(
         qchem_command="qchem -slurm",
         max_cores=32,
         input_file="mol.qin",
         output_file="mol.qout")
     expected_next = QCJob(qchem_command="qchem -slurm",
                           max_cores=32,
                           multimode="openmp",
                           input_file="mol.qin",
                           output_file="mol.qout",
                           suffix=".opt_0",
                           backup=True).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     expected_next = QCJob(qchem_command="qchem -slurm",
                           max_cores=32,
                           multimode="openmp",
                           input_file="mol.qin",
                           output_file="mol.qout",
                           suffix=".freq_0",
                           backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(
             os.path.join(
                 test_dir,
                 "disconnected_but_converged/mol.qin.freq_0")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict())
     self.assertRaises(StopIteration, myjob.__next__)
コード例 #3
0
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(qchem_command="qchem -slurm", input_file="mol.qin", output_file="mol.qout")
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".opt_0",
                     backup=True).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertRaises(StopIteration,myjob.__next__)
コード例 #4
0
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(qchem_command="qchem -slurm", max_cores=32, input_file="mol.qin", output_file="mol.qout")
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     max_cores=32,
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".opt_0",
                     backup=True).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertRaises(StopIteration,myjob.__next__)
コード例 #5
0
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(qchem_command="qchem", max_cores=32, input_file="test.qin", output_file="test.qout")
     expected_next = QCJob(
                     qchem_command="qchem",
                     max_cores=32,
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".opt_0",
                     backup=True).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     expected_next = QCJob(
                     qchem_command="qchem",
                     max_cores=32,
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".freq_0",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"FF_working/test.qin.freq_0")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"test.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem",
                     max_cores=32,
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".opt_1",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"FF_working/test.qin.opt_1")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"test.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem",
                     max_cores=32,
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".freq_1",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"FF_working/test.qin.freq_1")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"test.qin")).as_dict())
     self.assertRaises(StopIteration,myjob.__next__)
コード例 #6
0
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(qchem_command="qchem", input_file="test.qin", output_file="test.qout")
     expected_next = QCJob(
                     qchem_command="qchem",
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".opt_0",
                     backup=True).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     expected_next = QCJob(
                     qchem_command="qchem",
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".freq_0",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"FF_working/test.qin.freq_0")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"test.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem",
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".opt_1",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"FF_working/test.qin.opt_1")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"test.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem",
                     multimode="openmp",
                     input_file="test.qin",
                     output_file="test.qout",
                     suffix=".freq_1",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"FF_working/test.qin.freq_1")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"test.qin")).as_dict())
     self.assertRaises(StopIteration,myjob.__next__)
コード例 #7
0
ファイル: run_calc.py プロジェクト: yiwang62/atomate
    def run_task(self, fw_spec):

        # initialize variables
        qchem_cmd = env_chk(self["qchem_cmd"], fw_spec)
        multimode = env_chk(self.get("multimode"), fw_spec)
        if multimode == None:
            multimode = "openmp"
        """
        Note that I'm considering hardcoding openmp in the future
        because there is basically no reason anyone should ever run
        QChem on multiple nodes, aka with multimode = mpi.
        """
        input_file = self.get("input_file", "mol.qin")
        output_file = self.get("output_file", "mol.qout")
        max_cores = env_chk(self["max_cores"], fw_spec)
        qclog_file = self.get("qclog_file", "mol.qclog")
        suffix = self.get("suffix", "")
        calc_loc = env_chk(self.get("calc_loc"), fw_spec)
        save_scratch = self.get("save_scratch", False)
        max_errors = self.get("max_errors", 5)
        max_iterations = self.get("max_iterations", 10)
        linked = self.get("linked", True)
        backup = self.get("backup", True)
        max_molecule_perturb_scale = self.get("max_molecule_perturb_scale",
                                              0.3)
        job_type = self.get("job_type", "normal")
        gzipped_output = self.get("gzipped_output", True)

        handler_groups = {
            "default": [
                QChemErrorHandler(input_file=input_file,
                                  output_file=output_file)
            ],
            "no_handler": []
        }

        # construct jobs
        if job_type == "normal":
            jobs = [
                QCJob(qchem_command=qchem_cmd,
                      max_cores=max_cores,
                      multimode=multimode,
                      input_file=input_file,
                      output_file=output_file,
                      qclog_file=qclog_file,
                      suffix=suffix,
                      calc_loc=calc_loc,
                      save_scratch=save_scratch,
                      backup=backup)
            ]
        elif job_type == "opt_with_frequency_flattener":
            if linked:
                jobs = QCJob.opt_with_frequency_flattener(
                    qchem_command=qchem_cmd,
                    multimode=multimode,
                    input_file=input_file,
                    output_file=output_file,
                    qclog_file=qclog_file,
                    max_iterations=max_iterations,
                    linked=linked,
                    save_final_scratch=save_scratch,
                    max_cores=max_cores,
                    calc_loc=calc_loc)
            else:
                jobs = QCJob.opt_with_frequency_flattener(
                    qchem_command=qchem_cmd,
                    multimode=multimode,
                    input_file=input_file,
                    output_file=output_file,
                    qclog_file=qclog_file,
                    max_iterations=max_iterations,
                    max_molecule_perturb_scale=max_molecule_perturb_scale,
                    linked=linked,
                    save_final_scratch=save_scratch,
                    max_cores=max_cores,
                    calc_loc=calc_loc)

        else:
            raise ValueError("Unsupported job type: {}".format(job_type))

        # construct handlers
        handlers = handler_groups[self.get("handler_group", "default")]

        c = Custodian(handlers,
                      jobs,
                      max_errors=max_errors,
                      gzipped_output=gzipped_output)

        c.run()
コード例 #8
0
ファイル: run_calc.py プロジェクト: montoyjh/MatMethods
    def run_task(self, fw_spec):

        # initialize variables
        qchem_cmd = env_chk(self["qchem_cmd"], fw_spec)
        multimode = env_chk(self.get("multimode"), fw_spec)
        if multimode == None:
            multimode = "openmp"
        input_file = self.get("input_file", "mol.qin")
        output_file = self.get("output_file", "mol.qout")
        max_cores = env_chk(self["max_cores"], fw_spec)
        qclog_file = self.get("qclog_file", "mol.qclog")
        suffix = self.get("suffix", "")
        scratch_dir = env_chk(self.get("scratch_dir"), fw_spec)
        if scratch_dir == None:
            scratch_dir = "/dev/shm/qcscratch/"
        save_scratch = self.get("save_scratch", False)
        save_name = self.get("save_name", "default_save_name")
        max_errors = self.get("max_errors", 5)
        max_iterations = self.get("max_iterations", 10)
        max_molecule_perturb_scale = self.get("max_molecule_perturb_scale",
                                              0.3)
        job_type = self.get("job_type", "normal")
        gzipped_output = self.get("gzipped_output", True)

        handler_groups = {
            "default": [
                QChemErrorHandler(
                    input_file=input_file, output_file=output_file)
            ],
            "no_handler": []
        }

        # construct jobs
        if job_type == "normal":
            jobs = [
                QCJob(
                    qchem_command=qchem_cmd,
                    max_cores=max_cores,
                    multimode=multimode,
                    input_file=input_file,
                    output_file=output_file,
                    qclog_file=qclog_file,
                    suffix=suffix,
                    scratch_dir=scratch_dir,
                    save_scratch=save_scratch,
                    save_name=save_name)
            ]
        elif job_type == "opt_with_frequency_flattener":
            jobs = QCJob.opt_with_frequency_flattener(
                qchem_command=qchem_cmd,
                multimode=multimode,
                input_file=input_file,
                output_file=output_file,
                qclog_file=qclog_file,
                max_iterations=max_iterations,
                max_molecule_perturb_scale=max_molecule_perturb_scale,
                scratch_dir=scratch_dir,
                save_scratch=save_scratch,
                save_name=save_name,
                max_cores=max_cores)

        else:
            raise ValueError("Unsupported job type: {}".format(job_type))

        # construct handlers
        handlers = handler_groups[self.get("handler_group", "default")]

        c = Custodian(
            handlers,
            jobs,
            max_errors=max_errors,
            gzipped_output=gzipped_output)

        c.run()
コード例 #9
0
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(
         qchem_command="qchem -slurm",
         max_cores=32,
         input_file="mol.qin",
         output_file="mol.qout",
         linked=False,
     )
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".opt_0",
         backup=True,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".freq_0",
         backup=False,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(os.path.join(test_dir, "5690_frag18/mol.qin.freq_0")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict(),
     )
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".opt_1",
         backup=False,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(os.path.join(test_dir, "5690_frag18/mol.qin.opt_1")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict(),
     )
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".freq_1",
         backup=False,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(os.path.join(test_dir, "5690_frag18/mol.qin.freq_1")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict(),
     )
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".opt_2",
         backup=False,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(os.path.join(test_dir, "5690_frag18/mol.qin.opt_2")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict(),
     )
     expected_next = QCJob(
         qchem_command="qchem -slurm",
         max_cores=32,
         multimode="openmp",
         input_file="mol.qin",
         output_file="mol.qout",
         suffix=".freq_2",
         backup=False,
     ).as_dict()
     self.assertEqual(next(myjob).as_dict(), expected_next)
     self.assertEqual(
         QCInput.from_file(os.path.join(test_dir, "5690_frag18/mol.qin.freq_2")).as_dict(),
         QCInput.from_file(os.path.join(scr_dir, "mol.qin")).as_dict(),
     )
     self.assertRaises(Exception, myjob.__next__)
コード例 #10
0
from custodian import Custodian
from custodian.qchem.jobs import QCJob
from custodian.qchem.handlers import QChemErrorHandler

my_input = "test.qin"
my_output = "test.qout"

myjob = QCJob.opt_with_frequency_flattener(qchem_command="qchem -slurm",multimode="openmp",input_file=my_input,output_file=my_output,max_iterations=10,max_molecule_perturb_scale=0.3,max_cores=12)
myhandler = QChemErrorHandler(input_file=my_input,output_file=my_output)

c = Custodian([myhandler],myjob,max_errors_per_job=10,max_errors=10)

c.run()

コード例 #11
0
 def test_OptFF(self):
     myjob = QCJob.opt_with_frequency_flattener(qchem_command="qchem -slurm", max_cores=32,input_file="mol.qin", output_file="mol.qout", linked=True)
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     max_cores=32,
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".opt_0",
                     scratch_dir=os.getcwd(),
                     save_scratch=True,
                     save_name="chain_scratch",
                     backup=True).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     max_cores=32,
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".freq_0",
                     scratch_dir=os.getcwd(),
                     save_scratch=True,
                     save_name="chain_scratch",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"small_neg_freq/mol.qin.freq_0")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"mol.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     max_cores=32,
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".opt_1",
                     scratch_dir=os.getcwd(),
                     save_scratch=True,
                     save_name="chain_scratch",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"small_neg_freq/mol.qin.opt_1")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"mol.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     max_cores=32,
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".freq_1",
                     scratch_dir=os.getcwd(),
                     save_scratch=True,
                     save_name="chain_scratch",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"small_neg_freq/mol.qin.freq_1")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"mol.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     max_cores=32,
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".opt_2",
                     scratch_dir=os.getcwd(),
                     save_scratch=True,
                     save_name="chain_scratch",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"small_neg_freq/mol.qin.opt_2")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"mol.qin")).as_dict())
     expected_next = QCJob(
                     qchem_command="qchem -slurm",
                     max_cores=32,
                     multimode="openmp",
                     input_file="mol.qin",
                     output_file="mol.qout",
                     suffix=".freq_2",
                     scratch_dir=os.getcwd(),
                     save_scratch=True,
                     save_name="chain_scratch",
                     backup=False).as_dict()
     self.assertEqual(next(myjob).as_dict(),expected_next)
     self.assertEqual(QCInput.from_file(os.path.join(test_dir,"small_neg_freq/mol.qin.freq_2")).as_dict(),QCInput.from_file(os.path.join(scr_dir,"mol.qin")).as_dict())
     self.assertRaises(StopIteration,myjob.__next__)
コード例 #12
0
    def run_task(self, fw_spec):

        # initialize variables
        qchem_cmd = env_chk(self["qchem_cmd"], fw_spec)
        multimode = env_chk(self.get("multimode"), fw_spec)
        if multimode == None:
            multimode = "openmp"
        input_file = self.get("input_file", "mol.qin")
        output_file = self.get("output_file", "mol.qout")
        max_cores = env_chk(self["max_cores"], fw_spec)
        qclog_file = self.get("qclog_file", "mol.qclog")
        suffix = self.get("suffix", "")
        scratch_dir = env_chk(self.get("scratch_dir"), fw_spec)
        if scratch_dir == None:
            scratch_dir = "/dev/shm/qcscratch/"
        save_scratch = self.get("save_scratch", False)
        save_name = self.get("save_name", "saved_scratch")
        max_errors = self.get("max_errors", 5)
        max_iterations = self.get("max_iterations", 10)
        linked = self.get("linked", False)
        max_molecule_perturb_scale = self.get("max_molecule_perturb_scale",
                                              0.3)
        job_type = self.get("job_type", "normal")
        gzipped_output = self.get("gzipped_output", True)

        handler_groups = {
            "default": [
                QChemErrorHandler(input_file=input_file,
                                  output_file=output_file)
            ],
            "no_handler": []
        }

        # construct jobs
        if job_type == "normal":
            jobs = [
                QCJob(qchem_command=qchem_cmd,
                      max_cores=max_cores,
                      multimode=multimode,
                      input_file=input_file,
                      output_file=output_file,
                      qclog_file=qclog_file,
                      suffix=suffix,
                      scratch_dir=scratch_dir,
                      save_scratch=save_scratch,
                      save_name=save_name)
            ]
        elif job_type == "opt_with_frequency_flattener":
            if linked:
                jobs = QCJob.opt_with_frequency_flattener(
                    qchem_command=qchem_cmd,
                    multimode=multimode,
                    input_file=input_file,
                    output_file=output_file,
                    qclog_file=qclog_file,
                    max_iterations=max_iterations,
                    linked=linked,
                    max_cores=max_cores)
            else:
                jobs = QCJob.opt_with_frequency_flattener(
                    qchem_command=qchem_cmd,
                    multimode=multimode,
                    input_file=input_file,
                    output_file=output_file,
                    qclog_file=qclog_file,
                    max_iterations=max_iterations,
                    linked=linked,
                    max_molecule_perturb_scale=max_molecule_perturb_scale,
                    scratch_dir=scratch_dir,
                    save_scratch=save_scratch,
                    save_name=save_name,
                    max_cores=max_cores)

        else:
            raise ValueError("Unsupported job type: {}".format(job_type))

        # construct handlers
        handlers = handler_groups[self.get("handler_group", "default")]

        c = Custodian(handlers,
                      jobs,
                      max_errors=max_errors,
                      gzipped_output=gzipped_output)

        c.run()