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.


Topics - RMCtestFYP

Pages: [1]
1
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)))
   

2
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? :)

3
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)))


4
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]