Question about the .principal_axes() outputs. Conflicts with document? #4778
Replies: 1 comment
-
The code is for principal_axes() is straightforward def principal_axes(group, wrap=False):
atomgroup = group.atoms
e_val, e_vec = np.linalg.eig(atomgroup.moment_of_inertia(wrap=wrap))
# Sort
indices = np.argsort(e_val)[::-1]
# Make transposed in more logical form. See Issue 33.
e_vec = e_vec[:, indices].T
# Make sure the right hand convention is followed
if np.dot(np.cross(e_vec[0], e_vec[1]), e_vec[2]) < 0:
e_vec *= -1
return e_vec and does exactly what its docs say: calculate eigenvalues and eigenvectors, then sort from highest to lowest eval. If you look at wikipedia's List_of_3D_inertia_tensors you can see that the one for the solid cuboid of sides with the entries representing the eigenvalues for the principal axes along x, y, and z. The last eigenvalue Thus, you made a mistake in your assumption Considering the shape of the selected lipid heads is like a plate, the membrane norm should be the one with smallest eigenvalue. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am using The MDAnalysis v2.7, trying to calculate the local membrane norm.
I searched the lipid heads in local area and use the principal_axes to achieve.
According to the theory I understand, the eigenvector which has the smallest eigenvalue should be the one pointing at direction that shows least variations.
Considering the shape of the selected lipid heads is like a plate, the membrane norm should be the one with smallest eigenvalue.
As it is Documented for .principal_axes(), the returned eigenvectors e1,e2,e3 are listed with largest to smallest eigenvalues. That is why I tried to use the e3 as membrane norm.
However, when I check the e3 vector, it is not the one pointing to the positive Z like a membrane norm. In contrast, the e1 is.
Here is a example I took:
Here is the returned vectors:
You can find the 1st is the one pointing to positive Z, like a membrane norm, instead of the 3rd one.
Here is the coordinates of the lipid heads selection:
I did a brief trial to calculate the eigenvalues and eigenvectors using these coordinates:
And the output:
Regardless of handedness, the vectors a1,a2,a3 are pretty close to ones from .principal_axes(), but in opposite sequence.
So what can cause such problem, feels like .principal_axes() did not sort them from largest to smallest eigenvalues?
Or did I misunderstand the math?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions