Color code particles with number of bonds

Is it possible to color-code the particles with the number of bonds as the parameter?

Yes, you can use the Bond Topology information to determine how many bonds are attached to each particle and store that information in a new particle property. To achieve this, you can use a Python Modifier, such as the following example:

def modify(frame: int, data: DataCollection):
    bond_count = numpy.bincount(numpy.ravel(data.particles.bonds.topology), minlength = data.particles.count)
    data.particles_.create_property("Bond count", data = bond_count )
    

This approach makes the newly created Bond count particle property available for use as input to the Color Coding Modifier.

1 Like

I managed to do it using Compute property to find the number of neighbors and then color coding per the new property.

Great! Yes, counting the number of neighbors located in a spherical volume around each particle is possible with the Compute property modifier.
Just for others reading this, please keep in mind that this is not necessarily the same as counting the neighbor particles that actually share a bond with each central particle, especially when information about varying bond connectivity is part of your input data.