Forum Navigation
You need to log in to create posts and topics.

coordination analysis

Dear Constanze & Alex,

I use the below script to count the coordination and only get the coordination of  ParticleType-2 around each ParticleType-2. Now I don't know how to count the all other Particletypes around ParticleType-2 and it's average value for all ParticleType-2.

I'm sorry if I don't describe the problem clearly. Really appreciate your help!

Best wishes!

Tengfei Zheng

from import *
import numpy

def modify(frame, data):

##Initialize neighbor finder object
cutoff = 3.6
finder = CutoffNeighborFinder(cutoff, data)

##Prefetch the property array containing the particle type information:
p_types = data.particles["Particle Type"]
values = numpy.zeros(data.particles.count, dtype = int)
my_count = data.particles_.create_property("Zr - Zr Coordination", data = values)

##Loop over all particles:
for index in range(data.particles.count):
##Iterate over the neighbors of Zr particles only:
if(p_types[index] == 2):
for neigh in finder.find(index):
if( p_types[neigh.index] == 2):
with my_count:
my_count[index] += 1

Hi Tengfei,

the particle properties in OVITO basically behave like python numpy arrays, so you can make use of the following notation for indexing and slicing:

For averaging a particle property, you can use numpy.mean(). I have linked some references in the official numpy documentation, which explain all of this in more detail.