# Asphericity and Gyration tensor

Quote from Julien Lam on September 23, 2020, 5:37 pmDear Ovito admins,

I noticed that the gyration tensor was implemented. Yet, I wonder if there is systematic way to also compute the asphericity.

Regards,

Julien

Dear Ovito admins,

I noticed that the gyration tensor was implemented. Yet, I wonder if there is systematic way to also compute the asphericity.

Regards,

Julien

Quote from Constanze Kalcher on September 24, 2020, 10:03 amDear Julien,

please correct me if I'm mistaken, but following the description here: https://en.wikipedia.org/wiki/Gyration_tensor, one should be able to calculate the asphericity from the principal moments of the gyration tensor like this:

from ovito.data import * import numpy as np def calculate_asphericity(gyr_tensor): xx, yy, zz, xy, xz, yz = gyr_tensor l = np.linalg.eigvalsh([[xx, xy, xz],[xy, yy, yz],[xz, yz, zz]]) l.sort() return (l[2] - 0.5*(l[0] + l[1])) def modify(frame, data): cluster_table = data.tables['clusters_'] gyration_tensors = cluster_table['Gyration Tensor'] asphericity = [calculate_asphericity(g) for g in gyration_tensors] cluster_table.create_property('Asphericity', data=asphericity)If you like you can try this Python script modifier in the GUI. It will add an extra column called "Asphericity" to the Clusters list data table visible in the Data inspector.

-Constanze

Dear Julien,

please correct me if I'm mistaken, but following the description here: https://en.wikipedia.org/wiki/Gyration_tensor, one should be able to calculate the asphericity from the principal moments of the gyration tensor like this:

from ovito.data import * import numpy as np def calculate_asphericity(gyr_tensor): xx, yy, zz, xy, xz, yz = gyr_tensor l = np.linalg.eigvalsh([[xx, xy, xz],[xy, yy, yz],[xz, yz, zz]]) l.sort() return (l[2] - 0.5*(l[0] + l[1])) def modify(frame, data): cluster_table = data.tables['clusters_'] gyration_tensors = cluster_table['Gyration Tensor'] asphericity = [calculate_asphericity(g) for g in gyration_tensors] cluster_table.create_property('Asphericity', data=asphericity)

If you like you can try this Python script modifier in the GUI. It will add an extra column called "Asphericity" to the Clusters list data table visible in the Data inspector.

-Constanze

Quote from Julien Lam on September 29, 2020, 8:57 amDear Constanze,

I have my own code outside of ovito and I will compare both results.

Thanks a lot

Julien

Dear Constanze,

I have my own code outside of ovito and I will compare both results.

Thanks a lot

Julien

Quote from Constanze Kalcher on September 29, 2020, 10:17 amHi Julien,

ok great. It would be helpful if you let me know if you find any issues with the code snippet I posted above. Thank you!

-Constanze

Hi Julien,

ok great. It would be helpful if you let me know if you find any issues with the code snippet I posted above. Thank you!

-Constanze