本文整理汇总了Python中molecule.Molecule.to_bohr方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.to_bohr方法的具体用法?Python Molecule.to_bohr怎么用?Python Molecule.to_bohr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.to_bohr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_atomstring
# 需要导入模块: from molecule import Molecule [as 别名]
# 或者: from molecule.Molecule import to_bohr [as 别名]
def get_atomstring(mol):
mol.to_angstrom()
formatted_atoms = []
for atom in mol :
formatted_atoms.append("%s %f %f %f" % (atom[0], atom[1][0], atom[1][1], atom[1][2]))
mol.to_bohr()
return '\n'.join(formatted_atoms)
def get_energy(fpath, energy_prefix):
with open(fpath) as f:
for line in f:
if energy_prefix in line:
return float(line.split()[-1])
#throw error - energy not found ?
return 0.0
if __name__ == '__main__':
with open('../../extra-files/molecule.xyz', 'r') as f:
molecule = Molecule(f.read())
molecule.to_bohr()
with open('../../extra-files/template.dat', 'r') as f:
template_str = f.read()
generate_inputs(molecule, template_str)
run_jobs(molecule)
hessian = build_hessian(molecule, '@DF-RHF Final Energy:')
hessian_to_freqs.solve('../../extra-files/molecule.xyz','numerical_hessian.dat')
示例2: Exception
# 需要导入模块: from molecule import Molecule [as 别名]
# 或者: from molecule.Molecule import to_bohr [as 别名]
raise Exception("Did not match exactly once in {}.".format(filename))
return float(match_strings[0])
def build_hessian(mol, energy_prefix, disp_size = 0.005, directory = "DISPS"):
hessian = np.empty([3*mol.natom, 3*mol.natom])
e = functools.partial(get_energy, directory, energy_prefix)
for a, b in itertools.combinations_with_replacement(range(3*mol.natom), 2):
# A diagonal element.
if a == b:
hessian[a, b] = 1 / disp_size ** 2 * (
e("+", a, a) + e("-", a, a) - 2*e("0", "eq"))
# An off-diagonal element.
else:
hessian[a, b] = hessian[b, a] = 1/(2 * disp_size ** 2) * (
e("+", a, b) + e("-", a, b) - e("+", a, a) - e("-", a, a) - e("+", b, b) - e("-", b, b) + 2 * e("0", "eq"))
return hessian
if __name__ == "__main__":
water = Molecule("../../extra-files/molecule.xyz")
water.to_bohr()
# You can put your displacement in whatever unit you like, but it has to
# match the units of your energy. Psi4 sends energy in Hartrees, so Bohr
# units are necessary for our displacement.
with open("../../extra-files/template.dat", "r") as f:
template = f.read()
generate_inputs(water, template)
run_jobs(water)
hessian = build_hessian(water, "@DF-RHF Final Energy:")
np.savetxt("hessian.out", hessian)
frequencies(water, hessian)