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

cluster size

Hi Constanze, Hi Alex,

would it be possible to also return the cluster size as a per atom value from the cluster modifier? Sometimes I just want to color specific types of molecules or delete cluster smaller than a specific size. This would come in really handy in the pipeline. I know that one can sort the clusters by size, but especially in the first case an "expression selection" by cluster size would be nice.

Or maybe I just oversaw sth again. In that case, I'd be glad if you could point out to me.

Regards

Wolfgang

Hi Wolfgang,

you can use the particle property "Cluster", that tells you the Cluster-Id to which each particle belongs, to look up the Cluster Size from the list of clusters that appears under Data Tables in the Data Inspector and save that as a custom particle property.

If you like you can try the following python script modifier in the GUI:

from ovito.data import *
import numpy as np
def modify(frame, data):
    #Get the cluster size list data table
    cluster_sizes = data.tables['clusters'].y
    #Create a new particle property Cluster size
    cluster_size_pp = data.particles_.create_property("Cluster Size", data=cluster_sizes[data.particles["Cluster"] - 1])

 

Best,

Constanze

Hi Constaze,

works like a charm. Thanks

Wolfgang