def optimize(self, shot=0, method="newton", crit=1e-4): """ Optimize the geometry and align the optimized geometry to the starting geometry. """ if os.path.exists("%s.xyz_2" % self.name): os.unlink("%s.xyz_2" % self.name) self.mol[shot].write("%s.xyz" % self.name, ftype="tinker") if method == "newton": if self.rigid: optprog = "optrigid" else: optprog = "optimize" elif method == "bfgs": if self.rigid: optprog = "minrigid" else: optprog = "minimize" o = self.calltinker("%s %s.xyz %f" % (optprog, self.name, crit)) # Silently align the optimized geometry. M12 = Molecule("%s.xyz" % self.name, ftype="tinker") + Molecule("%s.xyz_2" % self.name, ftype="tinker") if not self.pbc: M12.align(center=False) M12[1].write("%s.xyz_2" % self.name, ftype="tinker") rmsd = M12.ref_rmsd(0)[1] cnvgd = 0 mode = 0 for line in o: s = line.split() if len(s) == 0: continue if "Optimally Conditioned Variable Metric Optimization" in line: mode = 1 if "Limited Memory BFGS Quasi-Newton Optimization" in line: mode = 1 if mode == 1 and isint(s[0]): mode = 2 if mode == 2: if isint(s[0]): E = float(s[1]) else: mode = 0 if "Normal Termination" in line: cnvgd = 1 if not cnvgd: for line in o: logger.info(str(line) + "\n") logger.info("The minimization did not converge in the geometry optimization - printout is above.\n") return E, rmsd
def optimize(self, shot=0, method="newton", crit=1e-4): """ Optimize the geometry and align the optimized geometry to the starting geometry. """ logger.error( 'Geometry optimizations are not yet implemented in AMBER interface' ) raise NotImplementedError # Code from tinkerio.py if os.path.exists('%s.xyz_2' % self.name): os.unlink('%s.xyz_2' % self.name) self.mol[shot].write('%s.xyz' % self.name, ftype="tinker") if method == "newton": if self.rigid: optprog = "optrigid" else: optprog = "optimize" elif method == "bfgs": if self.rigid: optprog = "minrigid" else: optprog = "minimize" o = self.calltinker("%s %s.xyz %f" % (optprog, self.name, crit)) # Silently align the optimized geometry. M12 = Molecule("%s.xyz" % self.name, ftype="tinker") + Molecule( "%s.xyz_2" % self.name, ftype="tinker") if not self.pbc: M12.align(center=False) M12[1].write("%s.xyz_2" % self.name, ftype="tinker") rmsd = M12.ref_rmsd(0)[1] cnvgd = 0 mode = 0 for line in o: s = line.split() if len(s) == 0: continue if "Optimally Conditioned Variable Metric Optimization" in line: mode = 1 if "Limited Memory BFGS Quasi-Newton Optimization" in line: mode = 1 if mode == 1 and isint(s[0]): mode = 2 if mode == 2: if isint(s[0]): E = float(s[1]) else: mode = 0 if "Normal Termination" in line: cnvgd = 1 if not cnvgd: for line in o: logger.info(str(line) + '\n') logger.info( "The minimization did not converge in the geometry optimization - printout is above.\n" ) return E, rmsd