91

**Support Forum / Re: How to find out the distribution of Voronoi indices? I got some error in script**

« **on:**August 01, 2018, 09:41:29 AM »

Hi,

there are some changes in the python programming interface of OVITO 3.0 as compared to OVITO 2.X and you're using the example script from the OVITO 2.X manual.

Let me refer you to the updated script in the OVITO 3.0 documentation.

However, from your screen-shot I can see that you're using the graphical user interface, where you can make your life a lot easier by calculating the Voronoi indices by inserting

the Voronoi analysis modifier in the modification pipeline (see attached screen-shot). Afterwards, you can still use a python script modifier function to print the 10 most frequent Voronoi motifs, e.g. like this:

-Constanze

there are some changes in the python programming interface of OVITO 3.0 as compared to OVITO 2.X and you're using the example script from the OVITO 2.X manual.

Let me refer you to the updated script in the OVITO 3.0 documentation.

However, from your screen-shot I can see that you're using the graphical user interface, where you can make your life a lot easier by calculating the Voronoi indices by inserting

the Voronoi analysis modifier in the modification pipeline (see attached screen-shot). Afterwards, you can still use a python script modifier function to print the 10 most frequent Voronoi motifs, e.g. like this:

Code: [Select]

`from ovito.data import *`

import numpy

def row_histogram(a):

ca = numpy.ascontiguousarray(a).view([('', a.dtype)] * a.shape[1])

unique, indices, inverse = numpy.unique(ca, return_index=True, return_inverse=True)

counts = numpy.bincount(inverse)

sort_indices = numpy.argsort(counts)[::-1]

return (a[indices[sort_indices]], counts[sort_indices])

def modify(frame, input, output):

voro_indices = input.particles['Voronoi Index']

# Compute frequency histogram.

unique_indices, counts = row_histogram(voro_indices)

# Print the ten most frequent histogram entries.

for i in range(10):

print("%s \t %i \t (%.1f %%)" % (tuple(unique_indices[i]), counts[i], 100.0*float(counts[i])/len(voro_indices)))

-Constanze