Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - shanis

Pages: [1]
Hi Constanze,

1. By not working I mean, that the number of clusters that I want to get the surface of is different for each frame. So the value of the range in the for loop below should itself be a variable that depends on the output of the cluster analysis modifier, and this I am not able to think of how to do properly.

for clusterID in range(1,6):
    my_expression = "Cluster == {}".format(clusterID)
    clusterselect_modifier.expression = my_expression
    data = pipeline.compute()


Thanks Constanze ! Your suggestions have been very useful. I am coming back with two problems now.

1. Using the for loop for frames doesn't work with the work around you suggested for obtaining the mesh.

2. When I use the more primitive way,  and try to export (for all frames using the GUI) the volumes as the global attribute, in the middle of the saving process I get the errror: ERROR: The global attribute 'ConstructSurfaceMesh.solid_volume.47' to be exported is not available at animation frame 50.
--when I look at the frame, looks like ovito wasn't able to construct mesh for a cluster. The error message: Cannot construct mesh for this input dataset. Adjacent cell face not found.

Please let me know if there is a solution to this problem, or if I just have to skip those problematic frames (which is not ideal when I have large number of frames to process as I won't know before hand which frame will give me an error).


clusterselect = SelectExpressionModifier(expression = 'Cluster == 40')
pipeline.modifiers.append(ConstructSurfaceModifier(radius=2.0, only_selected = True))
data = pipeline.compute()
clusterselect_modifier = SelectExpressionModifier(expression = 'Cluster == 47')
pipeline.modifiers.append(ConstructSurfaceModifier(radius=2.0, only_selected = True))
data = pipeline.compute()

Thanks Constanze. This works for a single frame analysis. Is there a way I can use it to analyze multiple frames/all frames of a trajectory ? -

Support Forum / Re: Particle count on multiple selected clusters
« on: May 17, 2019, 03:57:42 PM »
Thanks a lot Constanze,

This is helpful to count clusters with certain sizes. However, I also want to output the size of each cluster that has been counted, not just the counts. The hint I have is to express the ClusterSize property as an array, and have a nested loop for each frame and each selected cluster to output the cluster size, but this may be very inefficient given that there are lots of frames to be analyzed.

Let me know if you have any suggestions for alternatives.


Support Forum / Re: Particle count on multiple selected clusters
« on: May 16, 2019, 10:01:20 PM »
Thanks Constanz.

Now I am trying to compile, for each frame, the values of ClusterSize when it evaluates to greater than a cut off, lets say when the size is > 100, and export all the values for each frame into a single text file (n_columns = number of frames, n_rows = maximum number of clusters ). I am guessing I can do,

pipeline.modifiers.append(SelectExpressionModifier(expression= 'ClusterSize >100) )

and somehow loop over each frame while specifying selection == 1, but I am not sure how to do it exactly at this moment.

Let me know if you have suggestions.

Support Forum / Particle count on multiple selected clusters
« on: May 09, 2019, 07:16:46 PM »
Dear Ovito users,

I am trying to do particle count by type of only specific clusters (lets say 3 out of 5 clusters). Here is the code I use to do the counting. However, currently the counting is executed on all clusters. Let me know how I can perform the counting only on selected clusters.

Code: [Select]
cluster = ClusterAnalysisModifier(sort_by_size=True)

num_particles = data.particle.count

def particle_counting(frame, data):
    cluster_sizes = np.zeros(num_particles, dtype=int)

    for pidx in range(num_particles):
        ptype = data.particles_['Particle Type'][pidx]

        if data.particles['Particle Type'].type_by_id(ptype).name == 'C':
            cluster_sizes[data.particles['Cluster'][pidx]] += 1

     data.particles_.create_property('ClusterSize_', data = cluster_sizes)
     data.attributes['ClusterSize'] = list(cluster_sizes)

Thanks Constanze,

Yes, I am sorting the clusters based on size, and I can see that using the relational operator <= , as you suggested computes the surface mesh on all selected clusters. However, I also want to output the surface volume values as a global attribute for all of the selected clusters, but currently I only get one value for surface mesh using the above code. Alternatively, I can repeat the code for each cluster separately and get the volumes for each clusters that way, but this is not very efficient when there are many clusters. Let me know if you have other suggestions.


Dear ovito users,

If I have 10 clusters, out of which I want to select only 5 of them and apply the ConstructSurfaceModifier to each of them to obtain volume of each cluster, how could I achieve this ? Currently I can only select one cluster and apply the modifier. I can't use python variable to change the SelectExpressionModifier so I am thinking of an alternative way. Following is a code snippet that I am using to construct the surface.

Code: [Select]
# select cluster
clusterselect_modifier = SelectExpressionModifier(expression = 'Cluster == 1')
data = pipeline.compute()

# apply surface mesh on selected cluster
pipeline.modifiers.append(ConstructSurfaceModifier(only_selected = True))
data = pipeline.compute()

volume = pipeline.output.attributes['ConstructSurfaceMesh.solid_volume']

Thanks a lot !

Support Forum / selecting certain frames of trajectory files
« on: February 28, 2019, 04:41:17 PM »
Hello Ovito users,

Is there a way to specifiy certain frames (say frames 400 -500 of a trajectory that contains 500 frames) so that I can apply modifiers only to those frames while feeding the whole trajectory file to ovito ?


Support Forum / Re: Counting specific particle types inside a cluster
« on: February 07, 2019, 05:42:19 PM »
Thanks Constanze. Tried with both Python Script modifier and Expression Select modifier after applying Cluster Select modifier. Both worked ! I also see that ovito takes care of the PBC while doing cluster analysis, which is nice.

One issue I am trying to get around (only for visualization purposes) is to not have part of my molecules appear on the other side of the box due to the PBC. Is there something I can do with ovito, so my molecules don't look wierd when I make images ?


Support Forum / Counting specific particle types inside a cluster
« on: January 25, 2019, 04:04:42 AM »
I have a trajectory with four types of beads, two of them (A, B) form clusters and the other two are distributed inside and outside the clusters (C, D). Is there a way to count the number of C and D inside the clusters formed by A and B ?

Pages: [1]