Daniel_Arndt 发表于 2021-1-7 07:29
我以前写过一段算二面角的awk代码,当时是照着stackoverflow上的一个回答写出来的(记不清具体网址了),用 ...
"Flip" the first vector so that eclipsing vectors have dihedral=0
def new_dihedral(p):
"""Praxeolitic formula
1 sqrt, 1 cross product"""
p0 = p[0]
p1 = p[1]
p2 = p[2]
p3 = p[3]
b0 = -1.0*(p1 - p0)
b1 = p2 - p1
b2 = p3 - p2
# normalize b1 so that it does not influence magnitude of vector
# rejections that come next
b1 /= np.linalg.norm(b1)
# vector rejections
# v = projection of b0 onto plane perpendicular to b1
# = b0 minus component that aligns with b1
# w = projection of b2 onto plane perpendicular to b1
# = b2 minus component that aligns with b1
v = b0 - np.dot(b0, b1)*b1
w = b2 - np.dot(b2, b1)*b1
# angle between v and w in a plane is the torsion angle
# v and w may not be normalized but that's fine since tan is y/x
x = np.dot(v, w)
y = np.dot(np.cross(b1, v), w)
return np.degrees(np.arctan2(y, x))
liyuanhe211 发表于 2021-1-7 09:45
代码截图的分辨率起码得能看得清是等号还是减号吧。。。
令二面角是A1-A2-A3-A4组成的,则算二面角的俩 ...

highlight 发表于 2021-1-7 09:41
这里 https://stackoverflow.com/questi ... ordinates-in-python
乘负一的原因是
我本是个娃娃 发表于 2021-1-7 12:10
2019年7月写的,当时是为了解决另一个帖子的关于乙烷的二面角问题。
我本是个娃娃 发表于 2021-1-7 12:10
2019年7月写的,当时是为了解决另一个帖子的关于乙烷的二面角问题。
我本是个娃娃 发表于 2021-1-7 12:10
2019年7月写的,当时是为了解决另一个帖子的关于乙烷的二面角问题。
liyuanhe211 发表于 2021-1-7 15:22
学一下numpy吧,很好用的。

liyuanhe211 发表于 2021-1-7 15:22
学一下numpy吧,很好用的。
少年爱吃地三鲜 发表于 2021-1-14 16:54
老师,我想问一下您,我们自己构建函数时候用到的原子坐标可能随着轨迹突然跳到另一端,这个时候我们编写 ...
少年爱吃地三鲜 发表于 2021-1-14 17:19
老师,按照简单的例子,如果求 分子链的均方末端距,那这条链横跨了两个镜像,如果按您说的坐标来看,坐标 ...
| 欢迎光临 计算化学公社 (http://bbs.keinsci.com/) | Powered by Discuz! X3.3 |