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

Pages: [1]
1
Support Forum / Re: How to coloring particles by its properties
« on: August 10, 2018, 08:34:59 AM »
Thanks your help.
Sincere thanks to you.

2
Support Forum / Re: How to coloring particles by its properties
« on: August 09, 2018, 02:26:05 PM »
Thank you,Mr.Alexander.
You really help me a lot!
I will try to fix my error.And use this modifier to compare my old result.
Thank you again.

Another thing,can I please you remove the test88modified temporarily?
Because the calculation method has not been validated,and I want to keep the process secret.
After verification its accuracy,I will post it again in the net.
Thanks.

3
Support Forum / Re: How to coloring particles by its properties
« on: August 08, 2018, 03:12:16 PM »
After execute the modified version, the old problem still happen.
RuntimeError: Data pipeline evaluation failed: Modifier 'Color coding' reported: The property with the name 'myproperty' does not exist.
This error happen at final line:
Code: [Select]
data = node.compute(frame_index)

4
Support Forum / Re: How to coloring particles by its properties
« on: August 08, 2018, 02:23:16 PM »
Thanks your reply.
So I need to create a modifier function at first and then loop over the frames.
I know where I am wrong now.
Thanks you again,Mr.Alexander.

5
Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 08:55:10 PM »
I am running successful!
Thank you very much,Mr.Alexander!

6
Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 05:20:56 PM »
I want to produce an image or see the computation results in the viewports.

7
Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 04:40:55 PM »
I run this version's code.
It run successful but nothing happen

8
Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 04:26:49 PM »
Thanks your reply Mr.Alexander.
Due to my code is very long,if I post here,the readability will be poor.
Has any way to send my script for you?

9
Support Forum / Re: How to coloring particles by its properties
« on: August 03, 2018, 02:32:30 PM »
Ok,that's my code now:
if I coding:
Code: [Select]
#create a list to store all particle's result
    result_list = []

#calculate every particle's result and add it to a list
    for k in range(data.particles.count):
        property_list.append(result)

#create a particles property by result
    data.particles.create_property('myproperty', data=result_list)
    node.modifiers.append(ColorCodingModifier(property = 'myproperty',gradient = ColorCodingModifier.Rainbow(),start_value = 0,end_value= 19))

    node.add_to_scene()
    vis = node.get_vis(ParticlesVis)
It will happen
RuntimeError: Data pipeline evaluation failed: Modifier 'Color coding' reported: The property with the name 'myproperty' does not exist.

if I coding:
Code: [Select]
#create a list to store all particle's result
    property_list = []

#calculate every particle's result and add it to a list
    for k in range(data.particles.count):
        property_list.append(locals()["variant_color%s"%k])

#create a particles property by result
    data.particles.create_property('myproperty', data=property_list)
    node.modifiers.append(ColorCodingModifier(property = 'myproperty',gradient = ColorCodingModifier.Rainbow(),start_value = 0,end_value= 19))
It doesn't have any error message but there is nothing happen

10
Support Forum / Re: How to coloring particles by its properties
« on: August 02, 2018, 08:12:36 AM »
Ask a question.After coding a Color coding Modifier.
It can visualization directly?Or I need to add any visualization code?
Because I use a color coding modifier and run success(no error message)
But it is nothing happen,I can't see my color coding result.
How should I do to see my color coding visualization?

11
Support Forum / Re: How to coloring particles by its properties
« on: July 31, 2018, 11:49:50 AM »
Thanks for your reply!!!
I have a idea now

12
Support Forum / Re: How to coloring particles by its properties
« on: July 29, 2018, 01:50:47 PM »
Color coding modifier need to input property.
My property is calculating by my method,I seem to use ParticleProperty.Type.User   
But I don't put my method into property function.
Should I need to transform my method to property form?
If I need ,how should I do this?

13
Support Forum / Re: How to coloring particles by its properties
« on: July 29, 2018, 08:00:16 AM »
Thanks your reply.
But I want to do is like CNA modifier , if central atom is FCC coloring green.....
now I has been decide each atom's type and color.
But I still don't know how to visualize it.
I see the color coding modifier.But it seem not  to do this?


14
Support Forum / How to coloring particles by its properties
« on: July 27, 2018, 02:57:42 PM »
Hello everyone.
I use the python script to define the particle's new properties.
Now I want to coloring the atom with its properties.
For example:atom 1 is type A,then coloring the blue,atom 2 is type B,then coloring the orange...and I can choose the color by myself.
Has any modifiers can do this function? I read the vis modifiers,but I don't see the similar function to coloring by atom.

15
Support Forum / Order of neighbors from NearestNeighborFinder
« on: July 09, 2018, 07:02:26 PM »
And I still want to ask a question.
Now I stored 6 nearest neighbors around the central atom.
The neigh index in NearestNeighborFinder is sorted list of nearest neighbors.
But I want to sort these 6 atoms is array by +x +y +z -x -y -z direction to central atom.
Has any function to re-array the neigh index list?

16
the 127048's position:
https://imgur.com/nXFXKnB

the 127049's position:
https://imgur.com/76FnEIX

the delta value by modifier:
https://imgur.com/0cH1q9X

17
It's a nice news.
The ovito is more and more strong.
But when I use the NearestNeighborFinder modifier.
I met a problem.When I compare the result with ovito's GUI by my eyes.
I find the  neigh.index is true.But the neigh.delta is different form the position delta in graph.

18
Thanks for your reply!
The script is working now.
But I still have a question.
How do we know the change in OVITO3.0?
Has any documentation can know the new module's name?

19
When I update my ovito to the latest version.
My older script can't work
It will said:AttributeError: type object 'BondsView' has no attribute 'Enumerator'

Below is my code:

Code: [Select]
from ovito.io import *
from ovito.modifiers import *
from ovito.data import Bonds

# Import standard Python and NumPy modules.
import sys
import numpy

# Load the simulation dataset to be analyzed.
node = import_file("input.dump")

#create a output file
file = open('output_file.txt' , 'w')

# Create bonds.
node.modifiers.append(CreateBondsModifier(cutoff = 3.5))

# Compute CNA indices on the basis of the created bonds.
node.modifiers.append(
        CommonNeighborAnalysisModifier(mode = CommonNeighborAnalysisModifier.Mode.BondBased))
                     
# Let OVITO's data pipeline do the heavy work.
node.compute()

# A two-dimensional array containing the three CNA indices
# computed for each bond in the system.
cna_indices = node.output.bond_properties['CNA Indices'].array

# This helper function takes a two-dimensional array and computes the frequency
# histogram of the data rows using some NumPy magic.
# It returns two arrays (of same length):
#    1. The list of unique data rows from the input array
#    2. The number of occurences of each unique row
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)
    return (a[indices], counts)

# Used below for enumerating the bonds of each particle:
bond_enumerator = Bonds.Enumerator(node.output.bonds)

# Loop over atoms.
bonds_array = node.output.bonds.array
# Loop over particles and print their CNA indices.
for particle_index in range(node.output.number_of_particles):
   
    # Print particle index (1-based).
    sys.stdout.write("%i " % (particle_index+1))
    # Create local list with CNA indices of the bonds of the current particle.
    bond_index_list = list(bond_enumerator.bonds_of_particle(particle_index))
    local_cna_indices = cna_indices[bond_index_list]

    # Count how often each type of CNA triplet occurred.
    unique_triplets, triplet_counts = row_histogram(local_cna_indices)
   
    # Print list of triplets with their respective counts.
    for triplet, count in zip(unique_triplets, triplet_counts):
        sys.stdout.write("%s:%i " % (triplet, count))
        file.write("\n%i %s:%i " % (particle_index+1, triplet, count))

# Loop over half-bonds of current atom.
    for bond_index in bond_enumerator.bonds_of_particle(particle_index):
        atomA = bonds_array[bond_index][0]
        atomB = bonds_array[bond_index][1]
        assert(atomA == particle_index)
        print("\nAtom %i has a bond to atom %i" % (atomA, atomB))
        file.write("\nAtom %i has a bond to atom %i" % (atomA, atomB))

    # End of particle line
sys.stdout.write("\n")
file.close()

20
Support Forum / Re: How to export custom variables by python scripts?
« on: January 23, 2018, 05:44:46 PM »
Thanks for your reply.
But today I want to export the file likes the picture.
I want to export atomA bonded atomB for every particle (atomA= 1,2,3,4...)
How can I do this?
I can't think a way to change variables as a particle propertie

https://imgur.com/a/Sy0ZI

21
Support Forum / How to export custom variables by python scripts?
« on: January 23, 2018, 05:26:42 AM »
I want to export the atomA & atomB as a imd(or txt)

the code is below


# Import OVITO modules.
from ovito.io import *
from ovito.modifiers import *
from ovito.data import *
from ovito.data import Bonds
from ovito.modifiers import PythonScriptModifier

# Import standard Python and NumPy modules.
import sys
import numpy

# Load the simulation dataset to be analyzed.
node = import_file('/Users/eason851021/Documents/1635/dump.tensile_200.dump')
# Create bonds.
node.modifiers.append(CreateBondsModifier(cutoff = 3.5))

# Compute CNA indices on the basis of the created bonds.
node.modifiers.append(
        CommonNeighborAnalysisModifier(mode = CommonNeighborAnalysisModifier.Mode.BondBased))
                     
# Let OVITO's data pipeline do the heavy work.
node.compute()

# A two-dimensional array containing the three CNA indices
# computed for each bond in the system.
cna_indices = node.output.bond_properties['CNA Indices'].array

# This helper function takes a two-dimensional array and computes the frequency
# histogram of the data rows using some NumPy magic.
# It returns two arrays (of same length):
#    1. The list of unique data rows from the input array
#    2. The number of occurences of each unique row
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)
    return (a[indices], counts)

# Used below for enumerating the bonds of each particle:
bond_enumerator = Bonds.Enumerator(node.output.bonds)

# Loop over atoms.
bonds_array = node.output.bonds.array
# Loop over particles and print their CNA indices.
for particle_index in range(node.output.number_of_particles):
   
    # Print particle index (1-based).
    sys.stdout.write("%i " % (particle_index+1))
   
    # Create local list with CNA indices of the bonds of the current particle.
    bond_index_list = list(bond_enumerator.bonds_of_particle(particle_index))
    local_cna_indices = cna_indices[bond_index_list]

    # Count how often each type of CNA triplet occurred.
    unique_triplets, triplet_counts = row_histogram(local_cna_indices)
   
    # Print list of triplets with their respective counts.
    for triplet, count in zip(unique_triplets, triplet_counts):
        sys.stdout.write("%s:%i " % (triplet, count))
   # Loop over half-bonds of current atom.
    for bond_index in bond_enumerator.bonds_of_particle(particle_index):
        atomA = bonds_array[bond_index][0]
        atomB = bonds_array[bond_index][1]
        assert(atomA == particle_index)
        print("\nAtom %i has a bond to atom %i" % (atomA, atomB))
   
    export_file(node, "/Users/eason851021/Documents/1635/output.imd",
   format = "imd",
   columns = ["Particle Identifier", "Particle Type", "%i"%(atomA), "%i" % (atomB)])
   
   # End of particle line
    sys.stdout.write("\n")



But it display an error ´╝ÜRuntimeError: The set of output data columns is invalid (column 3). The property '0' does not exist.

Pages: [1]