def submit(self): """ Submits the job to turbogo for preparation and running, getting freqopts, job id and the job object back """ os.chdir(self.indir) try: self.jobid, freqopt, self.name, self.jobtype = jobrunner(job=self.job) if self.jobtype != 'sp': self.freqopt = freqopt.split('+')[0] if len(freqopt.split('+')) == 2: self.freeh = True if self.jobtype == 'opt' or self.jobtype == 'optfreq': self.status = "Opt Submitted" elif self.jobtype == 'numforce' or self.jobtype == 'aoforce': self.status = "Freq Submitted" elif self.jobtype == 'ts': self.status = 'TS Submitted' self.ts = True if not self.freqopt: self.freqopt = 'numforce' elif self.jobtype == 'sp': self.status = 'SP Submitted' except Exception as e: self.jobid = None self.job = None self.freqopt = None self.status = "Submit Failed: {}".format(e) os.chdir(TOPDIR)
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'