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

Pages: [1] 2
1
Support Forum / Re: How to calculate max and min of cluster's position
« on: February 14, 2018, 09:00:46 PM »
I just wanted to add why I decided to add clustering feature when identifying stackingfault width.
This was a safety feature that will exclude some of the HCP structures randomly appearing from thermal fluctuation.

-Kevin

2
Support Forum / Re: How to calculate max and min of cluster's position
« on: February 13, 2018, 06:41:08 PM »
Yes definitely, it's always nice to have someone look at my code.

Yes, I don't know why I decided to use clustering when there is going to be only 1 cluster. Thanks for pointing that out.

-Kevin

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

4
Support Forum / Re: source, output attributes
« on: February 11, 2018, 02:26:33 AM »
Thank you for the reply.
I came up with one additional question as follows:

Code: [Select]
# Note                                                                         
# :This works with ovito 3.0.0                                                 

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


print(node.source.attributes['Timestep'])
print(node.compute(3).attributes['Timestep'])
print(dataset.anim.current_frame)
dataset.anim.current_frame=3   
node.compute()
print(dataset.anim.current_frame)
print(node.source.attributes['Timestep'])

The results from the last 6 lines of the code are as follows:
print(node.source.attributes['Timestep'])           => 0   [This is OK]
print(node.compute(3).attributes['Timestep'])    => 7500  [This is OK]
print(dataset.anim.current_frame)                    => 0  [This is OK]
dataset.anim.current_frame=3
node.compute()
print(dataset.anim.current_frame)                     => 3  [This is OK]
print(node.source.attributes['Timestep'])            => 0  [This should be 7500]

Quote
node.source is the cache for the current animation time, which is controlled by the global ovito.dataset.anim.current_frame setting (basically the time slider in the GUI). This setting is not affected when you call node.compute(3). Thus, you'll still find data for the current animation time (frame 0) in that input cache.

According to the quote above, I expect the last line of the code to print 7500 instead of 0. Could you explain why this prints 0?

UPDATE
1. this happens only when previous node.compute(3) is there.
If 'frame1' in node.compute(frame1) (6th line from the bottom) and
'frame2' in dataset.anim.current_frame = frame2  (4th line from the bottom) is different, this behavior is not observed.

2. node.source seems to update only after both 'current_frame' has changed and node.compute() has been used.

5
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'])

6
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

7
Support Forum / Re: Box size in Ovito scripting
« on: February 09, 2018, 05:57:00 PM »
Ahhh... thank you so much for clearing this up.
After posting the previous reply, I realized cell origin is not related to the box size.
I was assuming OVITO uses the same convention to LAMMPS.
Thanks again. (And special thanks to origin+size convention. This was exactly what I wanted for LAMMPS to have.)

8
Support Forum / Re: Box size in Ovito scripting
« on: February 09, 2018, 05:43:27 PM »
Ahh I see. I just have to use the cell vector anyways. (Since Ovito GUI provides 'Width', 'Length' and 'Height' of box, I thought there may be a function that retrieves the box size, which I couldn't locate on the OVITO documentation. I guess the GUI provides box sizes using by calculating elements in the cell vector.)

PS. By the way, I think the cell origin has to be considered to get the exact box size(unless it's 0).

Thank you again for answering this somewhat trivial question.

9
Support Forum / Re: Box size in Ovito scripting
« on: February 09, 2018, 04:53:14 PM »
Thank you for the reply.


Yes I could use cell vector and then calculate box size using elements in the cell vector as follows:
I was just wondering if there is a function that directly retrieves box size rather than cell vector.


Code: [Select]
cell = node.source.cell                                               
cellSize = cell.matrix
boxLo = cellSize[2][3]                                         
boxHi = cellSize[2][2]                                 
boxSize = boxHi - boxLo 

10
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

11
Support Forum / Re: histogram over all frames
« on: February 05, 2018, 06:20:51 PM »
1st node.compute() right after CNA modifier, and 2nd node.compute() after histogram modifier also does not trigger the error.

Since this issue is resolved in 3.0.0 version of OVITO, it may not be important issue, but I just wanted to refer this issue in case this matters to the developers.

Thanks again for the help.

12
Support Forum / Re: ovito on Linux
« on: February 02, 2018, 10:06:49 PM »
Nevermind.
Changing name of 'ovitos' works.
So, I changed 'ovitos' to 'ovitos3', and it still works.

13
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')

14
Support Forum / Re: installing two versions of OVITO
« on: February 01, 2018, 09:13:46 PM »
I downloaded again with Chrome and Safari, and installed it again, but it still gives the same error.

I am using mac, and I have 2.9.0 version installed (and changed the name of application "Ovito" to "Ovito_2.9.0"). Then I installed newer version (3.0.0), and it still gives the same error.

I could still run ovito using terminal command, but I just wanted to report the problem.

15
Support Forum / Re: installing two versions of OVITO
« on: February 01, 2018, 05:55:15 PM »
I think there is something wrong with Ovito 3.0.0 installation file for mac.

Attached is the error shown after installing and running the Ovito 3.0.0

Pages: [1] 2