我不太擅长python,但是我已经能够从一组笛卡尔坐标中提取长度,我想知道在从这些笛卡尔坐标中抽象二面角时是否还有可用的python代码吗? / p>
例如,我有一个带有许多笛卡尔坐标的输出文件,如下所示:
Cartesian coordinates: (bohr)
I= 1 X= 1.089161712305D+00 Y= -6.795658386274D-01 Z= 2.912662235164D+00
I= 2 X= 1.031796515496D+00 Y= -2.381146835527D+00 Z= 5.335292839755D-01
I= 3 X= 1.149783510982D+00 Y= 2.340571359678D+00 Z= -6.876555647869D-01
I= 4 X= 1.278468575364D+00 Y= 2.072538501526D+00 Z= 2.220316248303D+00
I= 5 X= -4.171475147776D-01 Y= -1.004865635312D+00 Z= 4.252321635652D+00
I= 6 X= 2.547199557318D+00 Y= -1.259033236649D+00 Z= 4.204565916632D+00
I= 7 X= -4.086320906666D-01 Y= 3.325945634419D+00 Z= 2.852114332848D+00
I= 8 X= 3.139057776797D+00 Y= 3.055463552677D+00 Z= 2.732226137725D+00
I= 9 X= -1.409353483554D+00 Y= -1.721937234077D+00 Z= -1.137312724699D+00
让我找到说I1和I2的键长,我将这样做:
for f in logfile;
do
awk '/Cartesian coordinates: (bohr)/{x=NR+1}NR == x' $f > length1.dat
cut -c13-33 bond1.dat > bond1x.dat
cut -c37-57 bond1.dat > bond1y.dat
cut -c61-80 bond1.dat > bond1z.dat
paste bond1x.dat bond1y.dat bond1z.dat > bond1xyz.dat
sed -i -e 's/D/E/g' bond1xyz.dat
awk '/Cartesian coordinates: (bohr)/{x=NR+2}NR == x' $f > length2.dat
cut -c13-33 bond1.dat > bond2x.dat
cut -c37-57 bond1.dat > bond2y.dat
cut -c61-80 bond1.dat > bond2z.dat
paste bond2x.dat bond2y.dat bond2z.dat > bond2xyz.dat
sed -i -e 's/D/E/g' bond2xyz.dat
paste bond1xyz.dat bond2xyz.dat > bond12xyz.dat
awk '{print $1 - $4}' bond12xyz.dat > bond_x1.dat
awk '{print $2 - $5}' bond12xyz.dat > bond_y1.dat
awk '{print $3 - $6}' bond12xyz.dat > bond_z1.dat
paste bond_x1.dat bond_y1.dat bond_z1.dat > bond_xyz1.dat
awk '{print sqrt(($1)^2+($2)^2+($3)^2)}' bond_xyz1.dat > bond_xyz1val.dat
awk -v factor=0.529177 '{print $1 * factor}' bond_xyz1val.dat > cart_xyz1.dat
我知道它远非优雅,但对我来说效果很好。
例如,我现在正在尝试查找二面角I1 I2 I4 I5,而我想知道与上述方法相比,是否有类似的方法?
谢谢您的任何建议!