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

Pages: [1]
1
Support Forum / How to calculate max and min of cluster's position
« on: February 13, 2018, 04:49:58 AM »
Hello everyone,

I figured out this problem after writing all the question and right before submitting it,
but I will just post this anyways with the working code in case someone finds helpful.

Following is the code that identifies a cluster of HCP atoms, extracts only the atoms in the cluster, and calculates maximum and minimum x-position of this cluster.

Essentially I was trying to find the stackingfault width of a dissociated dislocation.

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

node = import_file("dump.200.*",
                   multiple_frames = True)
# Modifiers                                                                                                 
# Modifier 1: CNA                                                                                           
node.modifiers.append(CommonNeighborAnalysisModifier())

# Modifier 2: Select HCP (dislocation)                                                                     
node.modifiers.append(SelectExpressionModifier
                      (expression = 'StructureType==2'))
# Modifier 3: Cluster HCP                                                                                   
node.modifiers.append(ClusterAnalysisModifier
                      (cutoff=3.5,
                       only_selected = True))
# Modifier 4: Select cluster 0, which doesn't belong to any cluster.                                                                           
node.modifiers.append(SelectExpressionModifier
                      (expression = 'Cluster==0'))
# Modifier 5: Delete cluster 0                                                                                       
node.modifiers.append(DeleteSelectedParticlesModifier())

#Each particle's Position.X in addition to cluster id                                                                   
#can be outputted to xyz format file as follows:                                                           
export_file(node, "1xyz", "xyz",
            columns = ["Cluster", "Position.X"])

# BUT, I wanted to have access to position data in this script level
# to calculate Min and Max values of Position.X
# All particle_properties that belong to 'deleted_particles' seem
# to get deleted
data = node.compute()
cluster = data.particle_properties['Cluster'].array #this is not necessary
pos = data.particle_properties['Position'].array
xpos = pos[:,0]
leading = max(xpos)
trailing= min(xpos)


PS. Just in case someone new to OVITO finds this post and is trying to understand better way of manipulating clustering feature, I found the following post helpful:
http://forum.ovito.org/index.php?topic=118.msg222#msg222
(Note that the post was written 2017 Feb, and note the version of OVITO by then.)

2
Support Forum / source, output attributes
« on: February 10, 2018, 06:45:37 AM »
Dear Dr.Stukowski,

I observed a weird behavior in both OVITO 2.9.0 and 3.0.0, so I report it here.

The following code reads in two files(dump.200.0000 and dump.200.0001).
Each timestep is incremented by 2500.
So, node.compute(3) should result in timestep 7500.

Since node.compute() should cache the most recent compute to the node.output field,
expected outputs for the last 3 lines of the codes are as follows:
0        => node.source.attributes['Timestep']   
7500  => node.output.attributes['Timestep']
7500  => theOutput.attributes['Timestep']

However, the outputs from 2.9.0 version are as follows:
7500  => (source should remain at the timestep 0)
7500
7500


*I was going to say 3.0.0 version also behaves weirdly as follwos,
*but I guess 3.0.0 version doesn't have output field anymore.
Also, the outputs from 3.0.0 version are as follows:
0
0    =>(I don't think the most recent compute is cached into output field)
7500


Code: [Select]
from ovito.io import *
from ovito import dataset
from ovito.modifiers import *
import numpy

node = import_file("dump.200.*",
                   multiple_frames = True)
# Modifiers                                                                     
# Modifier 1: CNA                                                               
node.modifiers.append(CommonNeighborAnalysisModifier
                      (mode=CommonNeighborAnalysisModifier.Mode.FixedCutoff,
                       cutoff=3.5))
# Modifier 2: Selection                                                         
node.modifiers.append(SelectExpressionModifier
                      (expression = 'StructureType==3'))

theOutput=node.compute(3)
print(node.source.attributes['Timestep'])
print(node.output.attributes['Timestep'])
print(theOutput.attributes['Timestep'])

3
Support Forum / Accessing ovito source for histogram
« on: February 09, 2018, 08:23:10 PM »
Dear Dr.Stukowski,

I want to access how OVITO GUI works when it outputs histogram data.
Specifically, I want to figure out what the output format is. It is because the last floating number of histogram data in the following has one less decimal, and I couldn't mimic this behavior in my scripting version of histogram output. (I am trying to implement automated testing between data outputted from GUI and data from scripting.)

I was able to locate histogram_modifier.py here:
/Applications/Ovito_3.0.0.app/Contents/Resources/python/ovito/modifiers/stdmod/histogram_modifier.py
but this file only specifies how histogram data is created.

Code: [Select]
# Position.X histogram (bin size: 2.01018)
1.09469 2
3.10487 1
5.11505 1
7.12524 0
9.13542 0
11.1456 1
13.1558 1
15.166 1

Thank you,
Kevin

4
Support Forum / Box size in Ovito scripting
« on: February 08, 2018, 03:33:32 AM »
Dear Dr. Stukowski,

Attached is the image of 'Simulation cell' panel from ovito.
It seems like there is no function(?) to access Box sizes of simulation cell on scripting.
I could calculate this from "Cell geometry" but was wondering if there is a function to retrieve box size directly since it is offered in the OVITO GUI.

-Kevin

5
Support Forum / ovito on Linux
« on: February 02, 2018, 08:07:54 PM »
Ovito executable file on linux seems to be not a 'stand-alone' executable. So if I move 'ovitos' executable to '~/bin', ovitos wouldn't work.

I am currently using both 2.9.0 and 3.0.0 version, and am trying to find a way to run both versions of 'ovitos'.

I could add the ovito directory to $PATH environment, but then ovitos (2.9.0) and ovitos(3.0.0) will not be distinguished. Is there a way to distinguish two versions of ovitos with different name? (Would it be possible to change the name of 'ovitos' to 'ovitos3')

6
Support Forum / installing two versions of OVITO
« on: February 01, 2018, 03:07:21 PM »
Hello Dr. Stukowski,

Is it possible to install both OVITO 2.9.0 and 3.0.0 on mac?
I currently have 2.9.0 version on my mac, but I believe installing 3.0.0 would delete 2.9.0.
Would it be possible to keep both?

Bests,
Kevin

7
Support Forum / histogram over all frames
« on: January 30, 2018, 11:07:19 PM »
Hello Dr.Stukowski,

I wrote a python script that can run with 'ovitos' command. The script reads dump file with multiple frames, and selects all the atoms that are classified as BCC (structure type 3). Then histogram data (BCC atoms counts with respect to Position in Z direction) is outputted. This histogram data is appended to the same output file for all the frames.

However, this script becomes slow after several frames, and even much slower as more frame is processed.
It takes a few seconds to proceed from frame 0 to frame 10, but it takes an hour to proceed to frame 100.

Can you please help me with this issue? Original code and sample output file are attached.


Code: [Select]
# Settings                                                                                         
outFilename='ovito_zprofile'
wchProfile='Position.Z'
number_bin=50
range_end=100

from ovito.io import *
from ovito import dataset
from ovito.modifiers import *
import numpy


node = import_file("dump.*",
                   multiple_frames = True)
fout = open(outFilename, 'wb')


for frame in range (node.source.num_frames):

    dataset.anim.current_frame = frame

    print(dataset.anim.current_frame)
    # Modifier 1: CNA                                                                             
    node.modifiers.append(CommonNeighborAnalysisModifier
                          (mode=CommonNeighborAnalysisModifier.Mode.FixedCutoff,
                           cutoff=3.5))
    node.compute()

    # Modifier 2: Selection                                                                       
    node.modifiers.append(SelectExpressionModifier
                          (expression = 'StructureType==3'))
    node.compute()
    # Modifier 3: Histogram                                                                       
    hist_modifier = HistogramModifier(bin_count = number_bin,
                                      particle_property = wchProfile,
                                      only_selected = True,
                                      fix_xrange = True,
                                      xrange_start = 0,
                                      xrange_end = range_end)
    node.modifiers.append(hist_modifier)
    node.compute()

    # Write                                                                                       
    header = ('timeframe = ' + str(dataset.anim.current_frame) + '\n' +
              'z\tcount(bcc atoms)\n')
    fout.write(header.encode('ascii'))

    numpy.savetxt(fout,
                  hist_modifier.histogram,
                  fmt='%d',
                  delimiter='\t',
                  comments='',
                  footer='\n')

fout.close()


Thanks,
Kyu

Pages: [1]