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

how to identify a surface crystalline grain boundary


I am using ovito to identify a surface prefreezing structure which is a four-nearest-neighbor structure and to mark the grain boundary for observing how the GB flows. I looked in some python scripts and wrote a script, but it was extremely slow to find all neighbor atoms in the cutoff distance in a system with 380000 atoms. I am not sure what happened.

Here is my test script, and my plan is to select atoms in the top layer and count the number of first neighboring atoms, so it needs to filter other atoms.

node.apply(ExpressionSelectionModifier(expression='Position.Z < 50'))

node.apply(ExpressionSelectionModifier(expression='ParticleType == 2'))

cutoff = 4.0
finder = CutoffNeighborFinder(cutoff, node)

ptypes = node.particles.particle_types

for index in range(node.particles.count):
    print('neighbors of particle %i: ' % index)
    for neigh in finder.find(index):
        print(neigh.index, neigh.distance,, neigh.pbc_shift)
        type_of_neighbor = ptypes[neigh.index]

An example has been attached below.  Hope to get help from you. Thanks  a lot.



Uploaded files:
  • example.png

Hi Yuan,

to count the number of neighbors within a given cutoff, you can simply use the Compute property modifier:

and store the coordination number of every particle in your own custom particle property e.g. "My coordination". Another strategy would be to use the Coordination analysis modifier.

Based on each particle's coordination number you could then create a selection of your grain boundary atoms,  i.e. "My coordination != 4" if I understand your problem setting correctly.


I'm wondering, though, is your surface a flat surface? If that's not the case it might not be a good idea to select the top atoms based on their z-position. You could try the "Construct surface mesh" modifier instead, which has an option "Select particles on the surface".

After you have deleted all non-surface atoms (and also all atoms of particle type 2 like you did above) you could then try to work with a combination of the Centrosymmetry and Color coding modifiers to get a clear signature for the grain boundary atoms.



Hi Constanze ,

Thanks for your reply. I tried the compute property modifier, but I did not know how to output the results without using the python interface. And the attributes provided by the modifier also confused me to decide which one adapted to my case.

My former plan was to obtain the neighboring particles and then compare the Z coordination with the central one. If the value was too big (exceeding 2 Angstron for instance), it could almost say this particle was in another layer. Then I could delete atoms not belong to the first layer. It is not efficient but works well. The only problem is that the computational cost is very big to work out the neighboring list.

Your tip seems good. The surface is not flat. But I have no idea how to extract the obtained surface's information to a file. I will have a try using a script.

Thank you very very much. It indeed helps me much.

Best regards,



P.S. Below is a lammps file. It would be easier to understand what I mean.


Uploaded files: