本文整理汇总了Python中forcebalance.molecule.Molecule.comms方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.comms方法的具体用法?Python Molecule.comms怎么用?Python Molecule.comms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forcebalance.molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.comms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from forcebalance.molecule import Molecule [as 别名]
# 或者: from forcebalance.molecule.Molecule import comms [as 别名]
def main():
M = Molecule(opts.coords)
if len(M.molecules) != 1:
raise RuntimeError('Input coordinates must be a single contiguous molecule')
if opts.phi1 == None:
raise RuntimeError('phi1 (the first quartet of atoms) must be provided')
xyzout = []
commout = []
xyzcsh = []
commcsh = []
if opts.phi2 != None: # Two dimensional scan
for inc1 in range(0, 360, opts.scan):
for inc2 in range(0, 360, opts.scan):
xyzrot, clash = get_rotated_xyz(M, [opts.phi1, opts.phi2], [inc1, inc2])
print(inc1, inc2, "Clash" if clash else "Ok")
comm = "Dihedrals %s, %s set to %i, %i" % (str(opts.phi1), str(opts.phi2), inc1, inc2)
if clash:
xyzcsh.append(xyzrot.copy())
commcsh.append(comm)
else:
xyzout.append(xyzrot.copy())
commout.append(comm)
else: # One dimensional scan
for inc1 in range(0, 360, opts.scan):
xyzrot, clash = get_rotated_xyz(M, [opts.phi1], [inc1])
print(inc1, "Clash" if clash else "Ok")
comm = "Dihedral %s set to %i" % (str(opts.phi1), inc1)
if clash:
xyzcsh.append(xyzrot.copy())
commcsh.append(comm)
else:
xyzout.append(xyzrot.copy())
commout.append(comm)
if len(xyzout) > 0:
M.xyzs = xyzout
M.comms = commout
M.write(os.path.splitext(opts.coords)[0]+"_out"+os.path.splitext(opts.coords)[1])
if len(xyzcsh) > 0:
M.xyzs = xyzcsh
M.comms = commcsh
M.write(os.path.splitext(opts.coords)[0]+"_clash"+os.path.splitext(opts.coords)[1])
示例2: int
# 需要导入模块: from forcebalance.molecule import Molecule [as 别名]
# 或者: from forcebalance.molecule.Molecule import comms [as 别名]
from forcebalance.readfrq import read_frq_gen
# Frequency output file.
fout = sys.argv[1]
# Mode number, starting from 1.
modenum = int(sys.argv[2])
if modenum == 0:
raise RuntimeError("Start mode number from one, please")
frqs, modes, intens, elem, xyz = read_frq_gen(fout)
M = Molecule()
M.elem = elem[:]
M.xyzs = []
xmode = modes[modenum - 1]
xmode /= (np.linalg.norm(xmode)/np.sqrt(M.na))
xmode *= 0.3 # Reasonable vibrational amplitude
spac = np.linspace(0, 1, 101)
disp = np.concatenate((spac, spac[::-1][1:], -1*spac[1:], -1*spac[::-1][1:-1]))
for i in disp:
M.xyzs.append(xyz+i*xmode.reshape(-1,3))
M.comms = ['Vibrational Mode %i Frequency %.3f Displacement %.3f' % (modenum, frqs[modenum-1], disp[i]*(np.linalg.norm(xmode)/np.sqrt(M.na))) for i in range(len(M))]
M.write(os.path.splitext(fout)[0]+'.mode%03i.xyz' % modenum)