Asphericity and Gyration tensor

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

Regards,
Julien

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

Dear Constanze,

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

Thanks a lot
Julien

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