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 - RMCtestFYP

Pages: [1]
1
Thank you for your instruction! It works! :)

2
Thank you for your suggestion, it works now! :)

3
Oh, ok, I make some wrong copy.

It should the 'distribution of Voronoi index of certain type of atom'.
For example, my sample  have A, B, C type atoms.

I want to find the distribution of polyhedron formed around A.

Since the above script is to find the distribution of polyhedron formed around A, B and C totally,
I have no idea on how to edit it.

Sorry for my confusing wording! :'(

4
This script is to find the ten most frequent Voronoi index.
(This script is written by Mr. Kalcher.)

I want to find the ten most frequent Voronoi index of certain particle.
(i.e. what types of polyhedron around certain particle.)
How should I edit it?
I don't know what should be added. :'(

Code: [Select]
from ovito.data import *

def modify(frame, input, output):
print("Input particle properties:")
for name in input.particles.keys():
print(name)
from ovito.data import *
import numpy

def row_histogram(a):
    ca = numpy.ascontiguousarray(a).view([('', a.dtype)] * a.shape[1])
    unique, indices, inverse = numpy.unique(ca, return_index=True, return_inverse=True)
    counts = numpy.bincount(inverse)
    sort_indices = numpy.argsort(counts)[::-1]
    return (a[indices[sort_indices]], counts[sort_indices])

def modify(frame, input, output):
   
    voro_indices = input.particles['Voronoi Index']
    # Compute frequency histogram.
    unique_indices, counts = row_histogram(voro_indices)
    # Print the ten most frequent histogram entries.
    for i in range(10):
        print("%s \t %i \t (%.1f %%)" % (tuple(unique_indices[i]), counts[i], 100.0*float(counts[i])/len(voro_indices)))
   

5
Sorry for unclear wording :'(
For example, in the picture uploaded, the left picture is the original image in OVITO.
If I want get a image which is only about few nm thick, like the right picture.
I want to have a look on the linear structure of the sample.
How can I do this?

6
Thank you for you patient reply! :)
It seems that learning more concept of coding is a must.
Be frankly, I still don't know something you said. It looks a bit complicated, haha :)

7
Support Forum / How to cut the atomic configuration into desired size?
« on: August 04, 2018, 01:39:02 PM »
For example, I want to get a layer of about 0.3 nm to see its atomic arrangement.
I have tried some option in OVITO, but I cannot cut into such small size.
It just cuts at most half the size.
How should I do this? :)

8
OH... it seems that it is too complicated for me... I don't understand :'(
But it' okay, I still can use the code you provide, it works, thank you! :)

1. For the script you provide, it is to find the distribution of Voronoi indices for all types of atoms?

For example, my input data contains 3 types of atoms
if I want to find the distribution of Voronoi indices of type-1 atom only (e.g. The Voronoi polyhedron around type-atom),
Can I find it by OVITO?


2 To find the Voronoi indice, do I need to click 'Use particle radii' in 'Voronoi analysis'?

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

def row_histogram(a):
    ca = numpy.ascontiguousarray(a).view([('', a.dtype)] * a.shape[1])
    unique, indices, inverse = numpy.unique(ca, return_index=True, return_inverse=True)
    counts = numpy.bincount(inverse)
    sort_indices = numpy.argsort(counts)[::-1]
    return (a[indices[sort_indices]], counts[sort_indices])

def modify(frame, input, output):
   
    voro_indices = input.particles['Voronoi Index']
    # Compute frequency histogram.
    unique_indices, counts = row_histogram(voro_indices)
    # Print the ten most frequent histogram entries.
    for i in range(10):
        print("%s \t %i \t (%.1f %%)" % (tuple(unique_indices[i]), counts[i], 100.0*float(counts[i])/len(voro_indices)))



3. how to know that whether the script is batch scripts?

4. DO OVITO able to find the distribution of polyhedrons?

Thank you for you reply! Sorry if I ask some silly questions... since I am a super rookie in coding :'(

9
Thank you very much again! ;)
This method is much convenient, which can give the result very fast.
For this function, I still have some questions.

(1) These two method gives the same result?

(2) As picture 'Result.jpg', is this result reasonable for metallic glass? The value is very low.
Am I do anything wrong? :'(

(2) I have tried the new code from OVITO 3.0.0-dev211 documentation.
But I still got error when using the new code.
I type wrong code on atom type? ???

The thing I have changed is:
pipeline = import_file("C:/Users/wai/Desktop/example.cfg.cfg")

atom_types[0].radius = 1.35   # Pd atomic radius (atom type 1 in input file)
atom_types[1].radius = 1.55   # Cu atomic radius (atom type 2 in input file)
atom_types[2].radius = 1.55   # P atomic radius (atom type 3 in input file)



Code:
Code: [Select]
# Import OVITO modules.
from ovito.io import *
from ovito.modifiers import *

# Import NumPy module.
import numpy

# Load a simulation snapshot of a Cu-Zr metallic glass.
pipeline = import_file("C:/Users/wai/Desktop/example.cfg.cfg")

# Set atomic radii (required for polydisperse Voronoi tessellation).
atom_types = pipeline.source.compute().particles['Particle Type'].types
atom_types[0].radius = 1.35   # Pd atomic radius (atom type 1 in input file)
atom_types[1].radius = 1.55   # Cu atomic radius (atom type 2 in input file)
atom_types[2].radius = 1.55   # P atomic radius (atom type 3 in input file)

# Set up the Voronoi analysis modifier.
voro = VoronoiAnalysisModifier(
    compute_indices = True,
    use_radii = True,
    edge_count = 6, # Length after which Voronoi index vectors are truncated
    edge_threshold = 0.1
)
pipeline.modifiers.append(voro)
                     
# Let OVITO compute the results.
data = pipeline.compute()

# Make sure we did not lose information due to truncated Voronoi index vectors.
if data.attributes['Voronoi.max_face_order'] > voro.edge_count:
    print("Warning: Maximum face order in Voronoi tessellation is {0}, "
          "but computed Voronoi indices are truncated after {1} entries. "
          "You should consider increasing the 'edge_count' parameter to {0}."
          .format(data.attributes['Voronoi.max_face_order'], voro.edge_count))
    # Note that it would be possible to automatically increase the 'edge_count'
    # parameter to 'max_face_order' here and recompute the Voronoi tessellation:
    #   voro.edge_count = data.attributes['Voronoi.max_face_order']
    #   data = pipeline.compute()

# Access computed Voronoi indices.
# This is an (N) x (edge_count) array.
voro_indices = data.particles['Voronoi Index']

# This helper function takes a two-dimensional array and computes a frequency
# histogram of the data rows using some NumPy magic.
# It returns two arrays (of equal length):
#    1. The list of unique data rows from the input array
#    2. The number of occurences of each unique row
# Both arrays are sorted in descending order such that the most frequent rows
# are listed first.
def row_histogram(a):
    ca = numpy.ascontiguousarray(a).view([('', a.dtype)] * a.shape[1])
    unique, indices, inverse = numpy.unique(ca, return_index=True, return_inverse=True)
    counts = numpy.bincount(inverse)
    sort_indices = numpy.argsort(counts)[::-1]
    return (a[indices[sort_indices]], counts[sort_indices])

# Compute frequency histogram.
unique_indices, counts = row_histogram(voro_indices)

# Print the ten most frequent histogram entries.
for i in range(10):
    print("%s\t%i\t(%.1f %%)" % (tuple(unique_indices[i]),
                                 counts[i],
                                 100.0*float(counts[i])/len(voro_indices)))

10
I found the following statement in section C.2.7. of the RMC user guide:

Quote
The coordinates are reduced, going between –1 and +1 and the box half-length and other distance related properties are given in Ångstrom in RMC.

So I assume that the 43.62 value found in the header of your .cfg file denotes a half box length, right?
Note that OVITO assumes the cell sizes in the POSCAR header to be full lengths and the reduced atomic coordinates to be in the range 0-1. That means, after import in OVITO, the atomic coordinates will already be correctly converted to Angstroms by chance, but the cell size will come out too small by a factor 1/2. You should be able to fix this by applying the Affine Transformation modifier with a 2x scaling matrix just to the simulation cell but not the particle coordinates. Do you agree?

Thank you for your reply. :)
Yes, it seems work when change the cell size by Affine transformation.
So does this mean that I just need to change the cell size for correct analysis?

11
Hello, I am now trying to find the 10 most frequency Voronoi indices.
(The sample .cfg file have been uploaded for reference.)

I encounter some problems.
I copy the script from this example. https://ovito.org/manual/python/introduction/examples.html
And make some change, I highlight them in red colour below.
But some error occur.

Here is the possible problems I guess.
1. The .cfg file have some error. The cell size is wrong, or the coordinate of particles is not in the range [0 1].

Sorry for my silly question, since I have few experience on coding.
I search some key word in google, but I still don't know the reason.
I try the script several time and encounter several error too.
I don't know how to fix the problems :'( Are there any problems in the script?



# Import OVITO modules.
from ovito.io import *
from ovito.modifiers import *

# Import NumPy module.
import numpy

# Load a simulation snapshot of a Cu-Zr metallic glass.
node = import_file("C:/Users/wai/Desktop/example.cfg.cfg")

# Set atomic radii (required for polydisperse Voronoi tessellation).
atypes = node.source.particle_properties.particle_type.type_list
atypes[1].radius = 1.35        # Pd
atypes[2].radius = 1.55        # Cu
atypes[3].radius = 1.55        # P


# Set up the Voronoi analysis modifier.
voro = VoronoiAnalysisModifier(
    compute_indices = True,
    use_radii = True,
    edge_count = 6, # Length after which Voronoi index vectors are truncated
    edge_threshold = 0.1
)
node.modifiers.append(voro)
                     
# Let OVITO compute the results.
node.compute()

# Make sure we did not lose information due to truncated Voronoi index vectors.
if voro.max_face_order > voro.edge_count:
    print("Warning: Maximum face order in Voronoi tessellation is {0}, "
          "but computed Voronoi indices are truncated after {1} entries. "
          "You should consider increasing the 'edge_count' parameter to {0}."
          .format(voro.max_face_order, voro.edge_count))
    # Note that it would be possible to automatically increase the 'edge_count'
    # parameter to 'max_face_order' here and recompute the Voronoi tessellation:
    #   voro.edge_count = voro.max_face_order
    #   node.compute()

# Access computed Voronoi indices as NumPy array.
# This is an (N)x(edge_count) array.
voro_indices = node.output.particle_properties['Voronoi Index'].array

# This helper function takes a two-dimensional array and computes a frequency
# histogram of the data rows using some NumPy magic.
# It returns two arrays (of equal length):
#    1. The list of unique data rows from the input array
#    2. The number of occurences of each unique row
# Both arrays are sorted in descending order such that the most frequent rows
# are listed first.
def row_histogram(a):
    ca = numpy.ascontiguousarray(a).view([('', a.dtype)] * a.shape[1])
    unique, indices, inverse = numpy.unique(ca, return_index=True, return_inverse=True)
    counts = numpy.bincount(inverse)
    sort_indices = numpy.argsort(counts)[::-1]
    return (a[indices[sort_indices]], counts[sort_indices])

# Compute frequency histogram.
unique_indices, counts = row_histogram(voro_indices)

# Print the ten most frequent histogram entries.
for i in range(10):
    print("%s\t%i\t(%.1f %%)" % (tuple(unique_indices),
                                 counts,
                                 100.0*float(counts)/len(voro_indices)))


12
Dear RMCtestFYP,

I took a look at your input file "Example .cfg file.cfg". Unlike the file extension suggests, this file actually follows the POSCAR format (as used by the VASP simulation code), not the "CFG" format used by the AtomEye software.

The number in the second line of the file is the global scaling factor. If you change it from "1" to "2", the simulation box gets larger. However, since all atomic positions are given in reduced coordinates (as specified by the "Direct configuration" keyword), they get scaled along with the cell. Note that reduced coordinates must all lie in the range [0,1]. However in your file, they range from -1 to +1. This is why some of the atoms appear outside of the box, irrespective of the global scaling factor. To solve the problem, please change the reduced coordinates in your file to be in the range [0,1].

-Alexander

Dear Alexander,

Thank you for your reply.
The input file 'Example.cfg' is transformed from the .cfg file in RMC++. The uploaded file is the .cfg file generated by RMC++.
I change the format of .cfg file of RMC++ so that it can be inputted to OVITO.

Can I just change the cell size in OVITO, or by affine transformation to solve this problem?
After affine transformation, it seems that the coordination number shown in OVITO is reasonable.

Thank you! :)

13
Hi,

(1) Yes, then you will perform your analysis for type-2 center atoms.

(2) Let's say the list of particle types of the neighbors you find for a specific atom is
neighbor_types = [1 1 2 2 1 1 3 1] ,
i.e. 5 atoms of type 1, 2 atoms of type 2 and 1 of type 3. Then np.bincount(neighbor_types) returns a "histogram" [0 5 2 1] with 4 entries.
To read out the number of neighbors of type 3 you would do
np.bincount(neighbor_types) [3] etc.

If, however, you would only find neighbor atoms of type 1 in the specified cutoff, e.g.
neighbor_types = [1 1 1 1], np.bincount(neighbor_types) returns [0 4], but we need this to look like [0 4 0 0].

(3) Yes, that works.  :)

Best,
-Constanze

Thank you Constanze.
And thank you for you explanation, I hear similar concept in Scilab course before lol.
I have just plotted all the graph of the data, and now have to do some calculation, quite tired :'(
Thank you for your patient teaching! :)

14
Thank you very much! It is very hard but I still learn it. :)
You give a good instruction, I know more about how to use OVITO to analyze it.

For the coding, I still have some questions.
(1) As a red circle in the picture uploaded, if I only change this value into 2,
for example, if(ptypes[index] == 2):

Does this mean that it is to calculate the coordination number of type-2 atom
(i.e. how many type-2 atom surround type-2 atom?)


(2) For the last line, you add 'minlength=4', what does it mean?

(3) To check the coordination of type-3 atoms (surrounded by type-2 atom)
Change these two values?

if(ptypes[index] == 3):

new_property[index] = np.bincount(neighbor_types, minlength=4)[2]

Moreover, I need to select type-3 atom in 'Select type' too?


Again, thank you for your reply!
I am very weak in coding, but your teaching do help me a lot.
I am very grateful for your help :)

15
Good morning :) Thank you for your reply again!

For (1), I try to change the cell size but I don't know why it doesn't change.
In picture one, it is the original one.
In the second picture, I made the change but the cell size remains half the whole size :'(


For (2) and (3), I have some questions.

(a) My procedures: insert the script > select type A atom in 'Select type' > click 'histogram' > chose 'Type 2 coordination' > click 'Use only selected elemetns'
Am I correct? 8)

(b) Do I need to edit the script? If yes, what thing should I change?

(c) In the script, why the cut-off be 3? Can I change to other value?

(d) It seems that the coordination number I get is very big. (picture 3) Perhaps it is due to the problems of cell size or the cut-off is too large?

(e) In the 'histogram', if I choose 'coordination' and click 'use only selected elements'
For example, my sample contain atom types A, B, C.
I only click atom A in 'Select type'.

So it show the coordination of number of A (number of B and C that surround A)?

Again, thank you very much!  :)
Sorry for my silly questions again and again, since it is my first times to do the work on the analysis of simulation of atomic configuration, I don't know a lot of thing in this field
And I have few experience on computer coding too:'(
Thank for your great help! I really learn more about how to use OVITO

16
Thank you so much! :D

(1) Yes, I also find this problem, I see that the cell length is always half the total size.
As the picture uploaded, I have changed value in the red circle. However, no matter I change, the cell size shown in OVITO is still half the total atomic configuration. The only change is just the density.

Should I change the cell size is .cfg file directly or change in OVITO "simulation cell" option?


(2) I have tried it as shown in picture below. I got two columns of value which is the partial g(r). But how can I calculate the coordination number from it? Or any other method? :'(

(3) Can the histogram show certain pair of atom that I choose?
For example, the sample contain atom types A, B and C.
Can I get the histogram of coordination number that contains atom A and B only?

I tried to click on 'select types' to tick atom C. Then, I click on 'delete select'.
Atom C disappears, but the graph of the coordination number in 'histogram' still show the total number (contains atom types A, B, C).


Thank you for your reply again! It is my first time to use this kinds of software, sorry for asking too much silly questions lol :'(

17
I find the option 'histogram' in OVITO, it plots the coordination number vs. count number. (the picture uploaded)

However, can I have the graph or data of the distribution of coordination number by OVITO? (like the example picture)



Thank you for reply :)

18
Hello, I encounter some problems when I use the OVITO.
It is my first time to use this software.

I have a .cfg file. I have uploaded it here. Is the format correct to input in OVITO?

I made a RMC simulation, the sample contains 3 elements.
I use OVITO to analyze its atomic structure.
How should I find the coordination number of certain pairs of atoms?
For example, the sample is Ag Al Mg alloy, I want to find the number of Ag atoms which surrounds Al atoms.

I find the option 'histogram' in the list, but it only shows the total coordination number within the configuration.
How should I do?
Please give a detail procedure if it is possible, because I really don't know how to use this software. :'(

Thank you for your answer! I am still learning how to use this software :)

Pages: [1]