Author Topic: How to find path of interstitial when they are in cluster  (Read 575 times)

prash

  • Newbie
  • *
  • Posts: 9
How to find path of interstitial when they are in cluster
« on: October 23, 2018, 02:08:23 PM »
Dear all,

I'm new to ovito, I have to find MSD for interstitial cluster.
The problem I have is in some time frame my interstitial are not together (means cluster). So is it possible some how from ovito to neglect frames where interstitial are not in cluster and only export the coordinates of SIA's when they are in cluster (or close together)

Any help would be greatly appreciated

Thank you in advance

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 113
Re: How to find path of interstitial when they are in cluster
« Reply #1 on: October 23, 2018, 02:26:01 PM »
Dear prash,

that sounds like it could be achieved by using the Cluster analysis modifier in conjunction with a user defined function in a python script modifier.

-Constanze

prash

  • Newbie
  • *
  • Posts: 9
Re: How to find path of interstitial when they are in cluster
« Reply #2 on: October 23, 2018, 02:39:09 PM »
Thanks for the reply,
I tried to use cluster modifier but I didn't have any idea how to procede.
With python script modifier.

thank you

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 113
Re: How to find path of interstitial when they are in cluster
« Reply #3 on: October 23, 2018, 02:45:07 PM »
Dear prash,

without seeing (at least an example of) your simulation data it's very difficult for me to help you. That also goes for the other topic you opened on this board. If you like, you can upload an example of your trajectory, then I and other users can look into it your problem.

-Constanze

prash

  • Newbie
  • *
  • Posts: 9
Re: How to find path of interstitial when they are in cluster
« Reply #4 on: October 23, 2018, 03:36:24 PM »
I'm attaching here some of my example dump data frame for 2 interstitial.
In this i tried to use cluster modifier.
Now I need some idea how to proceed .
I'm thinking to select the frame when cluster analysis modifier found 1 cluster.
Then using this frame for further calculation of finding displacemnet vector and msd.

Thank you

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 113
Re: How to find path of interstitial when they are in cluster
« Reply #5 on: October 24, 2018, 02:53:22 PM »
Dear prash,

I have had a look at the data files you uploaded. So as a starting point, here is how you would use the Python script modifier (OVITO 3.0 syntax) to identify frames where the particles are aggregated in 1 cluster only (Note that you need to perform the Cluster analysis before, see attached screenshot).

Code: [Select]
from ovito.data import *
import numpy as np
def modify(frame, input, output):
    #get the particle property "Cluster"
    cluster = input.particles['Cluster']
   
    #Perform calculation only if all particles are aggregated in 1 cluster
    #(i.e. no Cluster-ID higher than 1 is allowed)
    if np.max(cluster) == 1:
        print("Found 1 cluster in frame {}".format(frame))
        #...continue here

What I don't quite understand yet is what these 4 particles represent. I noticed they have different particle identifiers in every frame and sometimes different particle types. So I couldn't use the Displacement vectors modifier, since there's no reference structure that contains all present particle identifiers.

If you need further help, maybe you could explain, what displacements you're trying to calculate? Individual particle displacements to some reference (you didn't include in your example files?) or the displacement of the center of mass of the whole cluster?

-Constanze
« Last Edit: October 24, 2018, 02:55:42 PM by Constanze Kalcher »

prash

  • Newbie
  • *
  • Posts: 9
Re: How to find path of interstitial when they are in cluster
« Reply #6 on: October 24, 2018, 03:18:55 PM »
I'm really thankful for your reply.
These 4 atoms are 2 interstitial cluster (2  dumbbells). If I'm not wrong it's changing type because I have a binary system of 2 type of atom and identifier because I have box of 16000 atoms and I extracted these two SIA cluster via WS analysis and dumped.data file by using wild card from ovito.

I need to calculate displacement of the center of mass of the whole cluster so that I can calculate MSD for this cluster.
I'm attaching here the reference file what I used for WS analysis.

Thank you in advance.

Constanze Kalcher

  • Administrator
  • Full Member
  • *****
  • Posts: 113
Re: How to find path of interstitial when they are in cluster
« Reply #7 on: October 24, 2018, 04:39:23 PM »
Ah okay, I see. In principle you have three options: 1) Either you write a bash-script that takes care of everything and which you can execute from the command line like this:
Code: [Select]
ovitos <your-script.py>but that will require some more python coding on your part. See the documentation about running scripts.

Or  2) if you prefer using the graphical user interface, you could calculate the center of mass of your cluster for every frame, where the atoms are aggregated and save that information in a global attribute (it will also appear in the Data Inspector.) The time-series of a global attribute can be exported using the File-Export function Table of Values.

If you like, try the following: First, apply the Cluster analysis modifier. Then, you should assign masses to your atoms via the Compute property modifier. For example if your particles of type 1 and 2 have masses of 0.5 and 1.1 you can use the expression shown in the screen shot. Then, add the following Python script modifier to your pipeline:
 
Code: [Select]
from ovito.data import *
import numpy as np
def modify(frame, input, output):
    #get the particle property "Cluster", "Position" and "Mass"
    cluster = input.particles['Cluster']
    positions = input.particles['Position']
    masses = input.particles['Mass']
   
    #Perform calculation only if all particles are aggregated in 1 cluster
    #(i.e. no Cluster-ID higher than 1 is allowed)
    if np.max(cluster) == 1:
        sum = 0
        for i in range(len(positions)):
            sum += masses[i]*positions[i]
        com = sum/np.sum(masses)
        output.attributes["CenterofMass"] = com
    else:
        output.attributes["CenterofMass"] = "Nan"

If you export that data as explained above, you will get a table with the position of the center of mass of the cluster for every frame. In frames, where there's more than 1 cluster, you'll have an entry "Nan" instead. You can then further post-process your file and calculate the displacements and from that the MSD etc.

Edit: Note, that the above script is just meant as starting point for you. You should probably also add a part that takes care of the periodic boundary conditions and use the minimum image convention for calculating the position of the center of mass. 


3) What you could also do is export a series of dump or data files, where you pretend your center of mass is a "particle". If you reimport that data into Ovito, you could simply use the Displacement vectors modifier or even the Generate particle trajectories modifier to visualize the movement of the center of mass.

-Constanze
« Last Edit: October 24, 2018, 06:11:04 PM by Constanze Kalcher »

prash

  • Newbie
  • *
  • Posts: 9
Re: How to find path of interstitial when they are in cluster
« Reply #8 on: November 13, 2018, 04:55:07 PM »
Hello,

Thank you so much for the reply it was really helpful for me.
Due to huge file I have to start using Ovitos interface.
I have tried to write ovito script for running in ovitos.
But it has a lot of error.
I'm attaching here the file and also data file. It would be great if I get help for start.

I'm starting with deleting a type 2 particle and then finding COM of all the type 1 particle.

Thank in advance.
« Last Edit: November 14, 2018, 10:09:29 AM by prash »

prash

  • Newbie
  • *
  • Posts: 9
Re: How to find path of interstitial when they are in cluster
« Reply #9 on: November 14, 2018, 03:09:46 PM »
Dear all,

I wanted to add below condition in all x, y  and z direction in ovito script to get unwrap Center of Mass.

if (periodic_x) then
  if (x <  -x_size * 0.5) x = x + x_size
  if (x >=  x_size * 0.5) x = x - x_size
end if


from ovito.data import *
import numpy as np
def modify(frame, input, output):
    #get the particle property "Cluster", "Position" and "Mass"
    cluster = input.particles['Cluster']
    positions = input.particles['Position']
    masses = input.particles['Mass']
   
    #Perform calculation only if all particles are aggregated in 1 cluster
    #(i.e. no Cluster-ID higher than 1 is allowed)
    if np.max(cluster) == 1:
        sum = 0
        for i in range(len(positions)):
            sum += masses*positions
        com = sum/np.sum(masses)
        output.attributes["CenterofMass"] = com
    else:
        output.attributes["CenterofMass"] = "Nan"


any help appreciated.

Thank you