test_grad_zmat.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:chemcoord 作者: mcocdawc 项目源码 文件源码
def test_grad_zmat():
    path = os.path.join(STRUCTURE_PATH, 'MIL53_beta.xyz')
    molecule = cc.Cartesian.read_xyz(path, start_index=1)
    fragment = molecule.get_fragment([(12, 17), (55, 60)])
    connection = np.array([[3, 99, 1, 12], [17, 3, 99, 12], [60, 3, 17, 12]])
    connection = pd.DataFrame(connection[:, 1:], index=connection[:, 0],
                              columns=['b', 'a', 'd'])
    c_table = molecule.get_construction_table([(fragment, connection)])
    molecule = molecule.loc[c_table.index]

    x = sympy.symbols('x', real=True)

    dist_mol = molecule.copy()
    dist_mol.loc[:, ['x', 'y', 'z']] = 0.
    dist_mol.loc[13, 'x'] = x

    zmat_dist = molecule.get_grad_zmat(c_table)(dist_mol)

    moved_atoms = zmat_dist.index[
        (zmat_dist.loc[:, ['bond', 'angle', 'dihedral']] != 0.).any(axis=1)]

    assert moved_atoms[0] == 13
    assert np.alltrue(
        moved_atoms[1:] == c_table.index[(c_table == 13).any(axis=1)])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号