def __init__(self, molecule, forcefield=None): if which('obabel') is None: print('setup OBabel path') sys.exit() super(OBabel, self).__init__(molecule) if not os.path.isfile(self.start_xyz_file): molecule.mol_to_xyz(self.start_xyz_file) self.optimized_coordinates = [] self.energy = 0.0
def __init__(self, molecule, qc_params): if which('define') is None: turbomole_logger.error('set Turbomole path') sys.exit('Set turbomole path') super(Turbomole, self).__init__(molecule) self.start_coords = angstrom2bohr(molecule.coordinates) self.atoms_in_fragments = molecule.fragments self.energy = None self.optimized_coordinates = None self.basis = qc_params['basis'] self.method = qc_params['method']
def __init__(self, molecule, method): if which('define') is None: turbomole_logger.error('set Turbomole path') sys.exit('Set turbomole path') super(Turbomole, self).__init__(molecule) self.charge = method['charge'] self.scf_type = method['scftype'] self.multiplicity = method['multiplicity'] self.start_coords = angstrom2bohr(molecule.coordinates) self.atoms_in_fragments = molecule.fragments self.energy = None self.optimized_coordinates = None
def __init__(self, molecule, qc_params): if which('mopac') is None: print('set MOPAC path') sys.exit() super(Mopac, self).__init__(molecule) self.inp_file = 'trial_' + self.job_name + '.mop' self.arc_file = 'trial_' + self.job_name + '.arc' self.start_coords = molecule.coordinates self.optimized_coordinates = [] self.energy = 0.0 keyword = f'PM7 PRECISE LET DDMIN=0.0 CYCLES=10000 charge={molecule.charge}' self.prepare_input(keyword=keyword)
def __init__(self, molecule, method): if interface.which('define') is None: print('set Turbomole path') sys.exit() if interface.which('xtb') is None: print('set XTB path') sys.exit() super(XtbTurbo, self).__init__(molecule) self.start_coords = angstrom2bohr(molecule.coordinates) self.atoms_in_fragments = molecule.fragments self.job_dir = '{}/job_{}'.format(os.getcwd(), self.job_name) self.coord_file = 'coord' self.energy_file = 'energy' self.egrad_program = ['xtb', 'coord', '-grad'] if self.charge > 0: self.egrad_program += ['-chrg', str(self.charge)] if self.multiplicity != 1: self.egrad_program += ['-uhf', str(self.multiplicity)] self.energy = None self.optimized_coordinates = None
def __init__(self, molecule, method): if which('xtb') is None: xtb_logger.error('set XTB path') sys.exit() super(Xtb, self).__init__(molecule) self.cmd = "xtb {} -opt vtight".format(self.start_xyz_file) if self.charge != 0: self.cmd = "{} -chrg {}".format(self.cmd, self.charge) if self.multiplicity != 1: self.cmd = "{} -uhf {}".format(self.cmd, self.multiplicity) if self.multiplicity == 1 and self.scftype is not 'rhf': self.cmd = "{} -{}".format(self.cmd, self.scftype) self.trajectory_xyz_file = 'traj_' + self.job_name + '.xyz'
def optimize(self, options): """ :return:This object will return the optimization status. It will optimize a structure. """ # TODO: Add a return 'CycleExceeded' max_cycles = options['opt_cycles'] gamma = options['gamma'] convergence = options['opt_threshold'] self.keyword = self.keyword + '!Opt' self.prepare_input() with open(self.out_file, 'w') as fopt: out = subp.Popen([which("orca"), self.inp_file], stdout=fopt, stderr=fopt) out.communicate() out.poll() exit_status = out.returncode if exit_status == 0: f = open(self.out_file, "r") line = f.readlines() if "****ORCA TERMINATED NORMALLY****" in line[-2]: self.energy = self.get_energy() self.optimized_coordinates = np.loadtxt(self.inp_file[:-4] + ".xyz", dtype=float, skiprows=2, usecols=(1, 2, 3)) write_xyz(self.atoms_list, self.optimized_coordinates, self.result_xyz_file, energy=self.energy) f.close() return True else: print("Error: OPTIMIZATION PROBABLY FAILED. " "CHECK THE .out FILE FOR PARTIAL OPTIMIZTION ") print("Check for partial optimization.") print("Location: {}".format(os.getcwd())) return False