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 - Constanze Kalcher

Pages: [1] 2 3 ... 5
1
Support Forum / Re: Create custom bins for each frame
« on: December 14, 2018, 04:23:52 PM »
So just to clarify, I used an example structure of a binary alloy to show you what the region you select in your script would look like.
When you select atoms based on their y-position you create a thin slab that will look similar to the region marked in red in the screenshot. It's not a cube. Is that what you wanted to achieve?

-Constanze

2
Support Forum / Re: Create custom bins for each frame
« on: December 14, 2018, 04:09:27 PM »
Hello ad,
     
it's not really clear to me what you're trying to do. So in your code snippet, you're calculating the average y-Position of all particles with particle type 1. Then you're calculating how many particles of type 2 are located in a thin slab (d_y=4), whose center coincides with the average position of all particles of type 1.

What do you mean by this?
Quote
... it showed the results for selection 1 particle types instead of selection 2 particle types.

-Constanze

3
Support Forum / Re: Regarding Wigner-Seitz defect analysis
« on: December 05, 2018, 12:07:14 PM »
Dear Bahman,

at the moment both version (OVITO 2.9 and the current developer version) do not support 2D configurations in the Wigner-Seitz defect analysis. But it might well be added in a future release. If you like, you can upload an example of your data here so we can look into the problem.

-Constanze

4
Support Forum / Re: Position Y histogram of of each frame
« on: December 04, 2018, 10:42:10 AM »
Hi ad,
I seem to miss what the OVITO specific question is here.
As stated in the numpy documentation, using "density=True" will cause the histogram to be normalized such that the integral over the range is 1. And from the link you posted it seems that you already found the corresponding page in the scipy documentation to plot the cumulative sum of your histogram?
-Constanze

5
Support Forum / Re: Position Y histogram of of each frame
« on: November 29, 2018, 12:16:08 PM »
Hi ad,

global attributes are actually not meant to save whole arrays. In your case it would be easier to just loop over all frames and use numpy.savetxt() to save the current histogram to a txt file, for example:

Code: [Select]
node = import_file(...)

for frame_index in range(node.source.num_frames):
    data = node.compute(frame_index)
    hist, bin_edges = numpy.histogram(data.particles["Position"][:,1])
    numpy.savetxt("histogram%d.txt" %frame, np.column_stack((bin_edges[:-1],hist)))

-Constanze

6
Support Forum / Re: Compute & Visualization of temperature field
« on: November 23, 2018, 03:58:26 PM »
Hello,

note that what I explained above is not a python script modifier, it's how you would implement the Compute property modifier in a stand-alone python script which you execute from the terminal.
Please explain again what you're trying to calculate. If you want to average the per-atom values you calculate you don't need a python script modifier. The Compute property modifier already does that when you activate "Include Neighbor terms" (and divide by NumNeighbors +1 of course).

http://www.ovito.org/manual/particles.modifiers.compute_property.html

~Constanze

7
Hello,

I don't think the Wigner-Seitz defect analysis would be the right analysis tool for you, since it would require comparison to a (in your case amorphous) reference configuration.


~Constanze

8
Support Forum / Re: Compute & Visualization of temperature field
« on: November 23, 2018, 01:33:30 PM »
Hi,

if I understand your question correctly you're asking how to use the Compute Property modifier in a python script?
If you have imported the per-atom kinetic energy with your data it will appear as particle property with the name you gave it in lammps. So you should have an extra column named e.g. "c_ke" in your dump file, right?

You can access that data in the ComputePropertyModifier.

Code: [Select]
pipeline.modifiers.append(ComputePropertyModifier(
    output_property = 'temp',
    expressions = [ '2.0 * c_ke/(... )' ],
    neighbor_mode = True,
    neighbor_expressions = [ '2.0*c_ke /(...)'],
    cutoff_radius = ....,
))
pipeline.compute()
where you would use your formula from above in the expression field and neighbor_expression field to calculate and average the property over all particles in the given cutoff. Note that you would have to divide by (NumNeighbors +1 ) though, since the central particle also counts.

See also the corresponding Manual entry:
http://ovito.org/manual_testing/python/modules/ovito_modifiers.html#ovito.modifiers.ComputePropertyModifier

~Constanze

9
Support Forum / Re: Partial radial distribution function (RDF)
« on: November 19, 2018, 04:00:18 PM »
Hi,
an example of how to calculate averages of only specific particles is also shown in the FAQ: http://forum.ovito.org/index.php?topic=376.0.

For each particle you calculated a property called "Coordination". If you now want to calculate the mean value of this property for only particles of type 2 e.g., you need to select these particles based on their type:

Code: [Select]
from ovito.data import *
import numpy as np

def modify(frame, input, output):
    coord = input.particles["Coordination"]
    p_types = input.particles["Particle Type"]
    output.attributes["Average coord ptype2"] = np.mean( coord[ (p_types == 2) ] )
You will now see the global attribute "Average coord ptype2" appear in the Data panel when you click on "Attributes".

-Constanze

10
Support Forum / Re: Partial radial distribution function (RDF)
« on: November 15, 2018, 01:44:12 PM »
Yes, you could do that. I just wanted to clarify that the difference between the two solutions is that the python script counts all neighbors up to a certain cutoff radius, whereas in the Compute property modifier you can specify both a lower and upper cutoff value.
So in the end it depends on what you want to evaluate.

-Constanze

11
Support Forum / Re: Partial radial distribution function (RDF)
« on: November 15, 2018, 01:17:41 PM »
Hi,
just to confirm, so when you talk about the number of atoms in the second shell e.g., do you mean "only" the second, or does that include the first and the second? In the first case, the solution from the other forum topic would require an extra step where you subtract the results from the inner shells from the outer ones.

-Constanze

12
Support Forum / Re: Partial radial distribution function (RDF)
« on: November 15, 2018, 11:04:24 AM »
Hello,
I would suggest you to use the latest developer version, where you can see particle properties and data plots you calculate directly in the Data inspector below the viewports.
So here is one way to calculate what you're asking for:
First, I used the Coordination analysis modifier to find out the distance of the different coordination shells (see screenshot RDF.png).
Then, you can insert a Compute property modifier which allows you to calculate and safe new particle properties, in this case let's call it "Type 2 coord. 1st shell". So to count how many atoms of type 2 are in the first coordination shell of each atom, you can use the following expressions:
Expression
0
Neighbor Expression
(Distance <= 2.6) && (ParticleType == 2)

The Neighbor Expression is evaluated for each neighbor atom in the given cutoff and is either 1 if both conditions are true or 0 otherwise. "&&" means "and" in this context. In the data-panel you will see your new particle property appear: The particle with Id 1 e.g. is of particle Type 2 and has 2 neighbors of type 2 in the first coordination shell (see last column in 2nd screenshot).

Now it's up to you to repeat that for the different particle types and distances. So simply insert more Compute property modifiers into your pipeline. As an example, "Type 1 coord. 2nd shell" could then be:
Expression
0
Neighbor Expression
(Distance >= 2.6) && (Distance <= 3.0) && (ParticleType == 1)
etc.
Don't forget to increase the cutoff radius as well.

From there, you could go on and use the Histogram modifier in conjunction with the Select particle Type modifier or a python script modifier to calculate averages of that information for only type 2 center particles e.g. But first, you should try if the above works for you.

-Constanze


13
Support Forum / Re: Partial radial distribution function (RDF)
« on: November 13, 2018, 11:06:20 AM »
Hi Safy,

If you integrate the rdf between two values r1 and r2, you will get the number density of atoms in that shell, so you still have to multiply that by its volume. That's why I suggested to start from the unnormalized histogram of the bond lengths instead.

Yes, you could also use the Coordination analysis modifier. But this will give you the number of neighbors starting from r = 0 up to a certain cutoff value. But what you're asking for is the number of atoms in different coordination shells right? You could do that analysis from r0 to r1 and r0 to r2 and subtract the results of the inner shell from the outer one. However, the Coordination analysis modifier won't distinguish between different atom types.

But let me explain another way: What's probably easier for you is to use the Compute property modifier. Say you're examining atom type 1, this is how you would count the number of atoms of type 1 in an exemplary coordination shell between 2.5 and 4.0 (length units).

Expression
0
Neighbor Expression
(Distance >= 2.5) && (Distance =< 4.0) && (ParticleType == 1) && (@Particle Type == 1)

Note that  @... references the properties of the central particle, but this feature is not yet available in OVITO 2.9.
 
-Constanze

14
Support Forum / Re: Use bins to compute mass property
« on: November 13, 2018, 10:27:52 AM »
Hello ad,

I didn't understand yet what you are trying to do. Could you maybe explain a little bit more?

-Constanze

15
Support Forum / Re: Atoms Shifting to one end
« on: November 13, 2018, 10:15:34 AM »
Hi,
yes, you could apply the Affine Transformation modifier to your data and then export the files via the File Export function.

-Constanze

16
Support Forum / Re: Partial radial distribution function (RDF)
« on: November 09, 2018, 04:30:30 PM »
Hello,

why don't you use the information you already calculated in your script, i.e. when you calculate the histogram of the different bond lengths?
Code: [Select]
hist, bin_edges = np.histogram(output.bond_properties.length.array, bins=num_bins)
-Constanze

17
Support Forum / Re: Grab max z coordinate | python script
« on: November 08, 2018, 09:56:28 AM »
Hello ad,

have a look at this topic here http://forum.ovito.org/index.php?topic=404.0, where someone had a similar question.

-Constanze

18
Hi Ali,

as explained above, the Slice modifier doesn't know about your crystal orientation, it uses spatial coordinates. However, for your given set of Miller-Bravais indices you can calculate the normal vector of the plane in spatial coordinates.

-Constanze

19
Support Forum / Re: Transformation to target box
« on: October 29, 2018, 10:55:40 AM »
Dear anurag,

this is how you would set the option "relative_mode" to False in the Affine Transformation modifier:

Code: [Select]
AffineTransformationModifier(
         relative_mode = False,
         #...other options )

http://ovito.org/manual/python/modules/ovito_modifiers.html#ovito.modifiers.AffineTransformationModifier

Note that the relational operator "==" is not the same as "=", it compares the values on either sides of your expression and tells you the relation among them.
If the values of two operands are equal, then the condition becomes true.

-Constanze

20
Support Forum / Re: Quantum espresso files
« on: October 25, 2018, 01:42:02 PM »
As Alexander said, it would be helpful if you provide us with an example file. Then we can look into this.

-Constanze

21
Support Forum / Re: Problem in MSD results from ovito
« on: October 25, 2018, 12:10:52 PM »
Dear prash,

as far as I can see there's no issue with the way you calculate the MSD with OVITO, it's rather a problem with your reference structure. Are you sure that this is the correct reference file?

Note that the Displacement vectors modifier uses the Particle Identifiers and I found that you have different numbers of atoms in your reference and in your example frames. It seems that you were able to avoid this problem by deleting all particles of type 1. However, it appears that the Particle Identifiers of the atoms in your binary system do not correspond to their original ID's anymore. Can you explain how you inserted your second particle type in the reference structure?
Did you maybe not only change the atom type of some of your particles but also unintentionally their Particle Identifiers? And this is why you get these large displacements because you're actually comparing "different particles" so to say.

I'm also wondering, if you want the MSD of particle type 2 only, wouldn't it make more sense to use "frame 0" as a reference in the Displacement vectors modifier instead of the external reference structure, where these particles are not even present yet?
Hope that helps,

-Constanze

22
Support Forum / Re: How can we get a bond angle distribution in ovito?
« on: October 24, 2018, 04:50:13 PM »
Dear SC,

concerning the error message: did you just copy that code in a python script modifier in the GUI of OVITO? Note that this is a bash-script which is meant to be executed from the command line like this:
Code: [Select]
ovitos <name-of-script.py>
See the documentation about running scripts.

-Constanze

23
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

24
Support Forum / Re: Problem in MSD results from ovito
« on: October 24, 2018, 03:01:32 PM »
The script doesn't seem to be the issue.

25
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

26
Support Forum / Re: Partial radial distribution function (RDF)
« on: October 24, 2018, 02:11:14 PM »
Hi Kyu,
you're right. With these two lines you can print the current working directory:
Code: [Select]
import os
print(os.getcwd())
Under MacOS it turns out to be "/", where you typically don't have write permission.
So on the Mac, you need to give a file path as well, when you're trying to save a file with
numpy.savetxt() from within the python modifier in the GUI.

However, in a future release, there will be a more intuitive way to export that data such that you can simply use the "File Export" function.

-Constanze

27
Support Forum / Re: Quantum espresso files
« on: October 24, 2018, 01:24:42 PM »
Hi,
here's the list of file formats that can be imported in OVITO 3.0.
http://ovito.org/manual_testing/usage.import.html

-Constanze

28
Support Forum / Re: Problem in executing OVITOS
« on: October 23, 2018, 04:07:59 PM »
Dear ad,

in that case you don't have to build it from source. The python scripting interface comes with the OVITO package.
That means, on your Mac you can simply drag and drop the OVITO package into your Applications folder (like how you usually install programs). Then you can call ovitos like this:

Code: [Select]
/Applications/Ovito.app/Contents/MacOS/ovitos <your-script.py>
Further, you can make your life easier by adding the following line to your "~/.bash_profile" file:
Code: [Select]
export PATH=/Applications/Ovito.app/Contents/MacOS/:$PATH so you won't have to type the whole path every time.

-Constanze

29
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

30
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

Pages: [1] 2 3 ... 5