coordination analysis

Quote from tengfei zheng on November 28, 2020, 4:16 amDear 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 ovito.data import *
import numpydef 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
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 ovito.data import *
import numpydef 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

Quote from Constanze Kalcher on November 30, 2020, 1:05 pmHi 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:
https://numpy.org/doc/stable/reference/arrays.indexing.html#arrays-indexing
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.
-Constanze
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:
https://numpy.org/doc/stable/reference/arrays.indexing.html#arrays-indexing
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.
-Constanze