Thanks for your patience!!
the angles I want to get are:
(2, 1, 3), (2, 1, 4), (3, 1, 4), # 1 is the vertex of an angle
(2, 3, 1), (2, 3, 4), (1, 3, 4), (2, 3, 5), (4, 3, 5), (1, 3, 5)
(1, 2, 3), (1, 4, 3),
dihedral:
(4, 1, 2, 3), # twist 1-2 by using 4 and 3, that's why it calls dihedral
(2, 1, 4, 3),
(1, 4, 3, 2),
(1, 2, 3, 4),
(2, 1, 3, 4), (2, 1, 3, 5), (4, 1, 3, 5),
# can not twist 3-5 since 5 doesn't have neighbor
improper dihedral angle(improper torsion(sorry for the typo before)) is how atom left the plane formed by other three atoms. Here is another tutorial https://wanglab.hosted.uark.edu/DLPOLY2/node50.html
(3, 2, 1, 5), (3, 2, 4, 5), (3, 1, 2, 4), (3, 1, 4, 5) # 3 left the plane formed by 2-1-5 etc.
(1, 2, 3, 4)
# 2, 4 , 5 doesn't have improper torsion because they don't have enough three neighbors
When we talk about “twist”, “plane”, those spital concept because we need to calculate it in 3D chemical space, but that chemical connection is topological and defined on a graph. So I need to infer those angle/dihedral/improper(which atoms form an angle, get their index and access position, then calculate degree of the angle) from the molecule graph, and then I can calculate intramolecular energy.