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

Finding Type of atom from one specific Type atom to 2NN distance.

Dear all,

I have to calculate what is most likely configuration with Type-1 atom up to 2NN, meaning is Type -1( Fe) atoms have Type-2,3,4 atoms till 2NN distance or it's with same Type-1 atom up to 2NN distance.

Thank you  in advance for your time.


Uploaded files:


the most flexible solution would be to use the pythons scripting interface. You can use the utility class CutoffNeighborFinder() to find the neighbor atoms. Once you know their indices, you can easily look up their particle type property.

Here is an example of how to generate a histogram of the frequency of different particle types among each atom's neighbor particles. Let's say you have 4 particle types. If you open the Data inspector, you will see a new particle property "Neighbor type count" appear that contains a histogram per particle. An entry of [0 3 4 1 2] would mean that this atom has 0 neighbors of type 1, 3 neighbors of type 2, 4 neighbors of type 3 etc. If you like you can use this to further develop your own solution.

from import *
import numpy as np

def modify(frame, data, cutoff = 2.0):
     finder = CutoffNeighborFinder(cutoff, data)
     # Prefetch the property array containing the particle type information:
     ptypes = data.particles.particle_types
     # Create new empty property container Neighbor type count
     neigh_count = data.particles_.create_property("Neighbor type count", data = np.zeros([ data.particles.count , len(ptypes.types)]))   
     # Loop over all particles:
     for index in range(data.particles.count):
        #Count number of different neighbor types for each atom 
        neigh_count[index] = np.bincount([ ptypes[neigh.index] for neigh in finder.find(index)], minlength = len(ptypes.types)+1)[1:]

Alternatively, you can use several instances of the Compute Property Modifier in the OVITO Basic GUI as shown in the attached screenshot.

Hope that helps,


Uploaded files:
  • Screenshot_compute-property.png

Thank you, Constanze for guiding me.

I manage to get Histogram.

But I didn't understand in the histogram what I produce by Ovito.

What it is in X-axis. Is it NN distance or Number of occurrences of pair?

I'm attaching here the histogram for ref.




Uploaded files:
  • Analysis_TEST_COMPRESSION_BIG_PBC_t1_t1.png
  • Analysis_TEST_COMPRESSION_BIG_PBC_t3_t1.png
  • Analysis_TEST_COMPRESSION_BIG_PBC_t4_t1.png
  • Analysis_TEST_COMPRESSION_BIG_PBC_t2_t1.png

Hello,  Constanze

Hope you are doing good.

Can you please explain to me a little bit regarding the above histograms which are generated by ovito.

Thank you for your time.





sorry for the late response- The histograms shows you the distribution of the different particle property values "Type <neighbortype>.coord. around Type <type>" that you calculated with the Compute Property Modifier. The y-axis is the frequency and the x-axis is the value range of the respective particle property.

Keep in mind that every atom that is not of type 1 will have an entry of "0" for Type<neighbortype>.coord around Type 1. If you want to exclude these values from the histogram, you could use a Select Type modifier first and then apply the Histogram modifier with the option "use only selected elements".