Example #1
0
class TestScrewer(unittest.TestCase):
    """Tests the Jobset Class"""

    def setUp(self):
        self.screwer = Screwer("5")

    def test_setup_screwer(self):
        """Test setting up screwer"""
        self.assertEqual(self.screwer.mode, "5")

    def test_exit_screwer(self):
        """Test exit code"""
        self.assertEqual(self.screwer._end_screwer(), -99)
Example #2
0
def ensure_not_ts(job):
    """
    This runs to read out the vibrational modes. If there are negatives, runs
    screwer to adjust the geometry along the imaginary coordinate, and
    resubmits job.
    """
    if job.freqopt == 'numforce':
        newdir = os.path.join(job.indir, 'numforce')
    else:
        newdir = job.indir
    filetoread = os.path.join(newdir, 'control')

    controlfile = turbogo_helpers.read_clean_file(filetoread)

    vib1 = False

    for i in range(len(controlfile)):
        if '$vibrational spectrum' in controlfile[i]:
            for j in range (i+3, len(controlfile)):
                col = controlfile[j][15:34].strip()
                if not (col == '0.00' or col == '-0.00'):
                    try:
                        vib1 = float(col)
                    except ValueError:
                        pass
                    else:
                        mode = controlfile[j][:6].strip()
                        break
        if vib1:
            break

    if vib1:
        if job.firstfreq == vib1:
            #Found the same TS as before. End job.
            return 'same'
        job.firstfreq = vib1
        if vib1 < 0:
            os.chdir(newdir)
            screwer = Screwer(mode)
            try:
                screwer.run_screwer()
            except Exception as e:
                logging.warning("Error '{}' running screwer on job {}.".format(
                    e, job.name))
                os.chdir(TOPDIR)
                return "error"
            control = turbogo_helpers.read_clean_file('control')
            newcoord = list()
            readin = False
            for line in control:
                if '$newcoord' in line:
                    readin = -1
                elif '$end' in line:
                    readin = False
                if readin:
                    newcoord.append(line)
                elif readin == -1:
                    readin = True
            if job.freqopt == 'numforce':
                os.chdir(os.pardir)
                turbogo_helpers.write_file('coord', newcoord)
                try:  # Better to remove numforce, if not no biggie
                    os.remove(os.path.join(os.curdir, 'control'))
                    shutil.rmtree(os.path.join(os.curdir, 'numforce'))
                except OSError:
                    pass
            try:
                job.jobid, job.freqopt, job.name, job.jobtype = jobrunner(job=self.job)
                job.curstart = time()
            except Exception as e:
                logging.warning("Error {} resubmitting job {}.".format(
                    e, job.name))
                os.chdir(TOPDIR)
                return 'error'
            os.chdir(TOPDIR)
            return 'opt'
        else:
            return 'completed'
    else:
        logging.warning(
            'Error getting vibrational frequencies from job {}.'.format(
            job.name
        ))
        return 'error'
Example #3
0
 def setUp(self):
     self.screwer = Screwer("5")