# How to get Dihedral angle for redundant coordinates?

Dear friends,
Recently, I begin to follow the geometry optimization tutorials (https://github.com/psi4/psi4numpy/blob/master/Tutorials/13_Geometry_Optimization/13a_Internal-Coordinates-Bmatrix.ipynb) of the psi4numpy. In this tutorial, the Ammonium molecule has been chosen as the example. In the tutorial, the author gave the codes about how to calculate redundant coordinate, such as bond, angle. However, for general, dihedral torsion should be calculated. Unfortunately, there is no codes about how to calculate it. Can you provide the general codes about calculating redundant coordinates from cartesian coordinates for me?

Thanks a lot,
Best regards,

Taiping Hu

Have you seen this function in Psi4Numpy’s `opt_helper`?

`measure_coordinates` from QCElemental may also be helpful. It’s already a Psi4 dependency so available through `import qcelemental as qcel`.

Yes, I have read carefully this function in opt_helper. I can understanding it and know how to calculate it. But I don’t know how to judge four atoms to form a dihedral angle.

I don’t know what it means to “judge four atoms to form a dihedral angle”. Could you try saying it a different way? Do you mean “how to know when the dihedral angle formed by four atoms is a good internal coordinate”?

I am very sorry for my bad expression.

Yes, I mean that. I want to calculated results such as:
B(1,2) = XXX,
A(1,2,3) = XXX,
D(1,2,3,4) = XXX

Good dihedrals include:

1. Dihedral angles that are fixed by symmetry. For formaldehyde, D(H1,C,O,H2) must be 180 degrees.
2. Dihedral angles for consecutively bonded atoms. For sulfuric acid, H-O-S=O would be a good choice because H is bonded to O, O is bonded to S, and S is (double) bonded to that other O.

OK. I will write some codes to calculate it, and do benchmark with other program.

Thanks a lot,
Best regards,

Taiping

Dear jmisiewicz,
According to your suggestions, I have writen some codes to calculate the “good dihedrals”. Unfortunately, I met some trouble (I have created successfully bond, angle). For example, I want to create redundant coordinate of the “methane”. According to your suggestion 2, there is no consecutively four bonded atoms. The bond matrix is:

[[False True True True True]
[ True False False False False]
[ True False False False False]
[ True False False False False]
[ True False False False False]]

However, in fact, there exists 4 dihedrals (extracted from Gaussian program output), i.e., D(2,1,4,3), D(2,1,5,3), D(2,1,5,4), D(3,1,5,4).

I hope that you can use a more general molecule as the case in your tutorial of psi4numpy.
Psi4 is so good as Python interface. Psi4Numpy is a good reference for studying the basic quantum theory. I learn much knowledge following your tutorial of Psi4Numpy.

Thanks a lot,
best regards,

Taiping

These kind of dihedrals are often called improper torsions.
http://cbio.bmt.tue.nl/pumma/index.php/Theory/Potentials

Automatically determining appropriate internal coordinates for a general molecule is an extremely difficult problem. The considerations I gave are appropriate for most molecules, but not all. If you really want more information on this, ask @Rollin_King.

Taiping, you can definitely add torsions if you wish manually using analogous function calls, for example,

intcos.append( tors.TORS(i, j, k, l) )

It is just unclear, as the other folks responded, why you would want to do this. If there is no bonding pattern i-j-k-l, then the coordinate is not effective in geometry optimizations (because the Hessian/2nd derivative is very not diagonal in such coordinates). This highlights one of the problems with Z-matrices, which force the use of dihedrals.

Dear Rollin_King,
In fact, I want to calculate Wilson B matrix according to the cartesian coordinates(the current geometry is optimized by other quantum program). Firstly, therefore, I want to calculate redundant coordinates and the transformation matrix between redundant and cartesian coordinates, i.e., Wilson B matrix.

Best regards,

Taipinghu

Dear jmisiewicz,
Thanks for your reply and taking time to solve my problems. Thank you!

best
taiping

These are things you may already know, but I’ll point out in case you do not know these:

1. In order to define a Wilson B matrix, you need a geometry in Cartesians and also a choice of internal coordinates.
2. The Wilson B matrix is technically not a transformation matrix between redundant and cartesian coordinates. It is the best linear approximation to the nonlinear map between Cartesian displacements and internal displacements. It is a map between changes in coordinates, not coordinates themselves, and it is the matrix approximation to a much more complicated function.

Also, why do you need a Wilson B matrix in the first place? The large problem you are trying to solve may have a simpler solution.

Dear jmisiewicz,
I want to calculate the Duschinsky matrix between two sets of normal modes. I will read force constant matrix and frequency information from other quantum chemical software. The final purpose are to calculate Duschinsky matrix and decomposite reorganization energy. The reference is “J. Chem. Phys. 115, 9103 (2001)”. Can you provide some suggestions for me? Thanks a lot.

Best
Taipng

I’m not familiar with these matrices, but I’ve skimmed the paper.

You seem to be trying to create a Python program to take in Cartesian force constant data for an arbitrary molecule at two different stationary points and compute the B matrix, as an intermediate for computing Duschinsky matrix. Am I understanding you? We are quickly getting to the limit of what I know, but I will have different things to say if you want to compute for a particular molecule or to create a program to do this for general molecules.

Dear jmisiewicz,
Yes, what you said is what I want to do. what things do you want to say? I am very glad to hear from you.

Best,
Taiping

Automatically generating appropriate non-redundant internal coordinates is a hard problem, and one I’m not qualified to help with. I see three options:

1. Have the user manually create the internal coordinates.
2. In cases like methane where there are not enough “good” internal coordinates, create ones that aren’t “good.” Create as many as you need, and then use the procedure from Sec. IIA of the paper to remove redundancies.
3. Abandon internal coordinates and construct the matrix in mass-weighted Cartesians. This may or may not be possible. Again, I’m not familiar with Duschinsky matrices.

And that is about as far as my knowledge goes.

Dear jmisiewicz,
Thanks for your suggestions. I am very happy to hear from you.

Best regards,
taiping