当前位置: 首页>>代码示例>>Python>>正文


Python Molecule.to_bohr方法代码示例

本文整理汇总了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')
开发者ID:CCQC,项目名称:summer-program,代码行数:31,代码来源:numerical_hessian.py

示例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)
开发者ID:CCQC,项目名称:summer-program,代码行数:32,代码来源:hessian.py


注:本文中的molecule.Molecule.to_bohr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。