本文整理汇总了Python中forcebalance.molecule.Molecule.align方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.align方法的具体用法?Python Molecule.align怎么用?Python Molecule.align使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forcebalance.molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.align方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: optimize
# 需要导入模块: from forcebalance.molecule import Molecule [as 别名]
# 或者: from forcebalance.molecule.Molecule import align [as 别名]
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