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

Pages: [1]
1
Support Forum / Re: Updating Molecule IDs in Replicate Copies
« on: November 28, 2018, 10:38:05 PM »
Hi Alex,

Thanks for the information. I will look into it but for a quick fix I just used LAMMPS to make my data file. Anyways thanks for your efforts, and I am definitely looking forward for the update in the future version of OVITO.

JK


2
Support Forum / Updating Molecule IDs in Replicate Copies
« on: November 16, 2018, 12:40:32 AM »
Hello All,

I have one question, please pardon me if I am missing anything. Let's say I have a system in which I have 10 atoms in which first five atoms had molecule ID 1 and next five has molecule ID as 2. And now if I replicate 1 copy in any direction, then why it doesn't assign updated molecule IDs to the newly generated atoms as it does for atom IDs i.e. new 10 atoms still have molecule IDs as 1 and 2 instead of 3 and 4.

Thanks a lot for your time.

3
Support Forum / Re: Not Able to Print a Variable While Looping Over Frames
« on: November 08, 2018, 05:25:20 PM »
Hi Alex,

I was not able to see your reply until now without realizing the thread got extended to the 2nd page and I kept checking only that part of the thread which become first page after my last reply. Anyways, one workaround worked for me as follows: Since I'm using iterm2 on a mac so I restarted the terminal just in a hope doing so will free-up default memory of the terminal. And it worked! And then I batched process all of my jobs in that way i.e. restarting the terminal before running code and it worked just fine! So I think the bug may not be in OVITO.

Thanks a lot for your help in the project.
Hope to work with you in future again.



4
Dear Alex,


Here is the full script which works for most of the cases:

import ovito
print("Hello, this is OVITO %i.%i.%i" % ovito.version)

from ovito.io import *
from ovito.modifiers import *

import numpy
node = import_file("sftp://jk435@kong.njit.edu:/research/ddlab/jk435/MD_LAMMPS_ddlab/TEST/water_gr/water_btw_gr/redo/angle_16/variable_gap/3_h2o/main/stress/cont_merge/dry/dump_*.cfg")

def compute_max_z(frame, input, output):

    #Find the index of the particle with the highest z-coordinate and look up its x-coordinate
    positions = input.particles["Position"]
    output.attributes["x_coord"] = positions[ numpy.argmax(positions[:,2]) ][0]
    output.attributes["Ocount"] = numpy.count_nonzero(input.particles["Particle Type"] == 2)

node.modifiers.append(PythonScriptModifier(function=compute_max_z))
export_file(node, "max_z2.txt", "txt", columns=["Ocount", "x_coord"], multiple_frames = True)

5
Hi Constanze,

That worked perfectly well. Can please help me to solve the below error:

import ovito
Hello, this is OVITO 3.0.0
ERROR: Failed to open input file: Too many open files
Traceback (most recent call last):
  File "ovito4.py", line 13, in compute_max_z
  File "/Applications/Ovito.app/Contents/MacOS/Ovito.App/Contents/MacOS/../Resources/python/ovito/data/particles/particles_view.py", line 46, in __getitem__
KeyError: "The DataCollection does not contain a particle property with the name 'Position'."


P.S: When I do the ulimit it shows unlimited.

Thanks.

6
Alex,

I'll be waiting for your or other user's reply to the problem mentioned above.

Over the course of last few days, I've meet with my principal investigator to narrow down the possibilities of the sceintific collaborations. And it turns out that it will be best if we can do that instead of depending upon the forum primarily. I'll contact your team very soon about our current and/or future projects based on what's the result of this thread comes out to be.

Thanks a lot!
 

7
Thanks Alexander. It's working completely fine. Can you please help me in the main project I'm working on. In our project, I have a system in which a body of water is sandwitched between the two graphene layers as you can see in the picture. After the system is relaxed a wrinkle is generated(height along Z axis) in the upper graphene layer to accomodate the presence of the water-body. Since we have constrained the movement of lower graphene layer, wrinkle is moving along the length of the sheet(x-axis) while we're deleting some number of water molecules after some random number of steps untill water-body is completely deleted. Now I have to find out the velocity of the wrinkle in the graphene sheet, and plot it against number of water molecules. I'm getting confused whether can I use the built-in displacement vector feature of the OVITO or not. Since the wrinkle is behaving like a wave i.e. whenever wrinkle moves it do not actually moves the atoms but instead energy gets tranferred from one atom to the other. Is it possible to find out the displacement vector between two DIFFERENT atoms in adjacent frames (commong thing will be those atoms will be having highest Z coordinate in their corresponding frame) or we have to just go with more basic algorithm in which we will find out the x coordinates of the atoms having highest Z coordinates in two adjacent frames and dividing the difference in x coordinates by timestep to get the velocity and then loop it from very first frame to the last frame so that we can a have a continuous plot showing the velocity fluctuations against the number of water molecules.

I know we can accomplish this task by other methods as well i.e. LAMMPS etc. but since we are planning to adopt OVITO python scripting in our future projects extensively so this will be our preferred option which will also serve us as our learning curve of the code as well. Can you please help me to build the algorithm to accomplish above task, and it will definitely guide me for my future projects as well.

Thanks a lot!

8
Hello Alexander,

Thanks a lot for your quick reply with detailed explanation for the algorithm. It's working without any problem. And thanks to your algorithm explanation, now I'm feeling more comfortable with OVITO python interface. I used below code:

import ovito
print("Hello, this is OVITO %i.%i.%i" % ovito.version)

from ovito.io import *
from ovito.modifiers import *


import numpy
node = import_file("/Users/kashyap/Google_Drive/NJIT/graphene_h2o/redo/angle_6/variable_gap/1_h2o/main/stress/dry/200000/dump_*.cfg")
def compute_max_z(frame, input, output):
    output.attributes["High_Z"] = numpy.max(input.particles["Position"][:,2])
node.modifiers.append(PythonScriptModifier(function=compute_max_z))
export_file(node, "max_z.txt", "txt", columns=["Frame", "High_Z"], multiple_frames = True)
~


And just to confirm
"def compute_max_z(frame, input, output):
 output.attributes["High_Z"] = numpy.max(input.particles["Position"][:,2])"
 is the piece which is converting local particle property to global attribute, correct?

And "node.modifiers.append(PythonScriptModifier(function=compute_max_z))" is the piece which is calling our user-defined modifier into OVITO, correct?

And one last thing I want to do in this code is, I want to print number of oxygen atoms in every simulation frame next to High_Z column in text out put file so that I can plot High_Z Vs. # Oxygen atoms in matlab. Any hint to do it will be much appreciated.

Thanks  a lot!

9
Hello Alexander,

Thanks for your informative reply. It solved the error. Additionally, can you please help me with following error in which I'm trying to write a newly computed property(High_Z) which is the highest Z component in every single frame to a text file with the frame number.

import ovito
print("Hello, this is OVITO %i.%i.%i" % ovito.version)

from ovito.io import *
from ovito.modifiers import *

node = import_file("/Users/kashyap/Google_Drive/NJIT/graphene_h2o/redo/angle_6/variable_gap/1_h2o/main/stress/dry/200000/dump_*.cfg")
frames = node.source.num_frames
print("The total number of dump frames are:",frames)


for frame in range(node.source.num_frames):
   data = node.compute(frame)
   coordinates = data.particles["Position"]
   modifier = ComputePropertyModifier()
   modifier.output_property = "High_Z"
   modifier.expressions = ["max(Position.Z)"]

   export_file(node, "potenergy.txt", "txt", columns = ["Frame", "High_Z"])



Error

Hello, this is OVITO 3.0.0
The total number of dump frames are: 11
The highest z-coordinate in reference frame is: 17.81900825664
Traceback (most recent call last):
  File "ovito1.py", line 31, in <module>
    export_file(node, "potenergy.txt", "txt", columns = ["Frame", "High_Z"])
  File "/Applications/Ovito.app/Contents/MacOS/Ovito.App/Contents/MacOS/../Resources/python/ovito/io/export_file.py", line 177, in export_file
    if not exporter.export_nodes(ovito.task_manager):
RuntimeError: The global attribute 'High_Z' to be exported is not available at animation frame 0.
ERROR: The Python script 'ovito1.py' has exited with an error.



Can you please give me a hint why I'm getting this error.

Thank you.

10
Support Forum / Not Able to Print a Variable While Looping Over Frames
« on: October 06, 2018, 01:09:24 AM »
Dear All,

I'm trying to find out maximum Z coordinate in my dump file and then print it which I ultimatly want to write to a text file. I'm following snippets given at "https://ovito.org/manual/python/modules/ovito_io.html" for looping over multiple frames which looks likes below:

import ovito
print("Hello, this is OVITO %i.%i.%i" % ovito.version)

from ovito.io import *

node = import_file("/Users/kashyap/Google_Drive/NJIT/graphene_h2o/redo/angle_6/variable_gap/1_h2o/main/stress/dry/200000/dump_*.cfg")
frames = node.source.num_frames
print("The total number of dump frames are:",frames)

for frame in range(node.source.num_frames):
   node.compute(frame)
   coordinates = node.output.particle_properties.position.array
   zl = max(coordinates[:,2])
   print("The highest z-coordinate in reference frame is:",zl)



But all it's printing is the variable value only processed for the first frame for number of times equal to number of frames in that directory as below:

Hello, this is OVITO 3.0.0
The total number of dump frames are: 11
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664
The highest z-coordinate in reference frame is: 17.81900825664


Can anybody please help me to understand why the new dump files are not being loaded instead it's just repeating the variable value evaluated for first frame.
Thank you.


11
Support Forum / Re: Loading the dump file error in python script
« on: October 04, 2018, 10:56:37 PM »
My guess is that "ovito.py" is a script you wrote and it's in the same folder as "velocity.py"? If that's the case, note that this file might be mistaken for the actual ovito module when you call
Code: [Select]
import ovitoand that's what causes the error. (Read more on python modules here).
You should better rename it to something else.

You're correct! That solved the error. I'll be careful from next time.
Thanks a lot!

12
Support Forum / Re: Loading the dump file error in python script
« on: October 04, 2018, 10:55:29 PM »
Hello jatink,

as for your previous reply, yes in principle you're right, except for the part about not being able to load input data when invoking "Run python script" from the GUI, but you would need to call add_to_scene() to make it appear in your viewports. More on this in the first highlighted box in this Manual entry about importing files:
http://ovito.org/manual_testing/python/introduction/file_io.html.
Quote
/Users/kashyap/Google_Drive/NJIT/prof_singh/test/ovito.py

-Constanze

HI Constanze,

I'm sorry to be not clear enough at the first place. When I said "the first one can only modify the data and write it(i.e. can't load the input data) by reading the python script from "File > Run Python Script" ONLY"; I meant this method can not be used to load the data, it can only be use to modify and write the data once the dump file is already loaded into OVITO from GUI functionality. So it's similar to the Python Script modifier. And we can't submit batch job script from File > Run Python Script or can we?  I gets the error about function modify is not define when I submit batch script from File > Run Python Script. Please let me know if I'm wrong.

Thank you.

13
Support Forum / Re: Loading the dump file error in python script
« on: October 04, 2018, 07:54:27 AM »
Thanks Constanze, for your informative reply. Can you please help me with the following error:

Jatins-MacBook-Air:test kashyap$ /Applications/Ovito.app/Contents/MacOS/ovitos velocity.py
Traceback (most recent call last):
  File "/Users/kashyap/Google_Drive/NJIT/prof_singh/test/ovito.py", line 2, in <module>
    print("Hello, this is OVITO %i.%i.%i" % ovito.version)
AttributeError: module 'ovito' has no attribute 'version'
ERROR: Failed to initialize Python interpreter.


Moreover, can you please confirm about correctness about the first part of my last reply.
Thank you.

14
Support Forum / Re: Loading the dump file error in python script
« on: October 02, 2018, 10:26:32 PM »
Hi,

it looks like you copied that code snippet you posted here in a Python script modifier in the gui? This wouldn't work, since it's only meant to contain a single modifier function.
Note that what you wrote is a stand-alone batch script which you need to run from the command line, (see this section in the manual about running scripts http://ovito.org/manual/python/introduction/running.htm .

Code: [Select]
ovitos name_of_your_script.py
-Constanze

Hello Constanze,

I think I understood what you're saying about basic working machanism of the code. Correct me if I'm wrong: Referring to the 4 methods described here http://ovito.org/manual/python/introduction/running.html  ; the first one can only modify the data and write it(can't load the input data) by reading the python script from "File > Run Python Script" ONLY; second method is complete A to Z solution where it can load the data, modify it and export it by running the script from command terminal of the operating system ONLY; third and fourth methods are just to write once own modifier or write once own rendering image template by running the script from "Python Script Modifier" from OVITO's GUI ONLY.

Additionally, I'm not able to submit ovito job from terminal; it says "-bash: ovitos: command not found". So I guess installing the OVITO with the help of GUI will not install command line capability so one had to build it from source while following the instructions given at "http://www.ovito.org/manual_testing/development.build_macosx.html". But I'm facing errors while executing a part of the instructions given below:

/opt/local/bin/python3.5 configure.py \
   --qmake $HOME/Qt/5.7/clang_64/bin/qmake \
   --confirm-license \
   --no-designer-plugin \
   --no-qml-plugin \
   --assume-shared \
   --sip=/opt/local/bin/sip-3.5 \
   --concatenate \
   --enable QtCore \
   --enable QtGui \
   --enable QtWidgets \
   --enable QtMacExtras



It throws following,

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/Resources/Python.app/Contents/MacOS/Python: can't open file 'configure.py': [Errno 2] No such file or directory


P.S: I'm using OVITO version 3.0.

Thanks a lot for your time.

15
Support Forum / Re: Loading the dump file error in python script
« on: September 26, 2018, 07:20:52 PM »
Hi Constanze,

Thanks for your reply. But I think it's working if give the full path to the dump file in "node = import_file("dump.mix")" i.e.  if I changed this command with full path then following is the new script and it's output. Please help me to understand it's working now as I'm not sure since I'm still getting error/warning in the output window which I'm not sure about it's source.


-----------------------------------------------------------------------------------
Script:

from ovito.io import *
node = import_file("/Users/kashyap/Google_Drive/NJIT/prof_singh/dump.mix")

from ovito.modifiers import *
node.modifiers.append(SelectExpressionModifier(expression="Position.X<3.9"))
node.modifiers.append(DeleteSelectedParticlesModifier())

export_file(node, "/Users/kashyap/Google_Drive/NJIT/prof_singh/outputdata.dump", "lammps_dump",
columns = ["Position.X", "Position.Y", "Position.Z"])


Output:


Invalid Python script. It does not define the function named modify().


-----------------------------------------------------------------------------------

Despite the Invalid Python script error message I do gets the output file with requested data after running the code in OVITO interface.

Additionally, is there a documentation explaining how to compile the ovitos in university cluster or to access the dump files from cluster while running ovito python script in local machine?

Thank you.

16
Support Forum / Loading the dump file error in python script
« on: September 25, 2018, 11:48:13 PM »
Dear OVITO Users,

I'm new to python scripting in OVITO. And I'm banging my head just to solve a simple begining step problem. How to load the file? Can anybody please help me to solve it. It looks like the solution is very simple but I'm constantly missing it while reading this webpage "https://ovito.org/manual/python/introduction/overview.html#loading-data-and-applying-modifiers" Anyhelp to locate the answer will be much appreciated.

This is my sample script:

from ovito.io import *
node = import_file("dump.mix")

from ovito.modifiers import *
node.modifiers.append(SelectExpressionModifier(expression="PotentialEnergy<-3.9"))
node.modifiers.append(DeleteSelectedParticlesModifier())

export_file(node, "outputdata.dump", "lammps_dump", columns = ["Position.X", "Position.Y", "Position.Z", "Structure Type"])


And this is script output:

The Python script has exited with an error.
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/Applications/Ovito.app/Contents/MacOS/../Resources/python/ovito/io/import_file.py", line 121, in import_file
    importer = FileImporter.autodetect_format(ovito.dataset, first_location)
RuntimeError: File does not exist:
dump.mix

17
Support Forum / Re: Calculating the velocity of a, or group of atoms.
« on: September 25, 2018, 11:42:30 PM »
Thanks Constanze. I got it. And it's working.

18
Support Forum / Calculating the velocity of a, or group of atoms.
« on: September 14, 2018, 12:22:44 AM »
Hello,

I want to calculate the x-velocity of a particle between two given frames. I'm following this doc "https://www.ovito.org/manual_testing/particles.modifiers.compute_property.html" but I'm unable to help my self to find out the definition of all "Available input variables" given on the right side of the webpage so that I can make expression of velocity. Can anybody please give me the corresponding page or any short similar example to calculate the velocity of a group or single particle.

Thanks a lot!

19
Support Forum / Re: Shifting the System Along an Axis
« on: September 14, 2018, 12:07:33 AM »
Hi,

No problem. It works like charms.

Thanks again!

20
Support Forum / Re: Shifting the System Along an Axis
« on: September 12, 2018, 02:09:25 AM »
Hi Constanze,

Thanks a lot! That was what I was looking for exactly. Initially I was using affine transformation but without using wrap at periodic boundary modifier which was not giving me expected result. Just as a add up, why I can't do it in the OVITO 3.0?

Thanks a lot.

21
Support Forum / Shifting the System Along an Axis
« on: September 10, 2018, 05:57:17 PM »
Hello,

Can anybody please tell me, is there a feature in OVITO by which we can shift the system along a axis so that we can see a feature in the system in it's center instead of watching it half split at one corner and wrapping around at the other corner. I'm attaching the screenshot of my system which is showing a wrinkle in graphene sheet at its corner which I want to see in the center of the system.

Thank you.

22
Support Forum / Re: Unable to create animation
« on: September 26, 2017, 06:48:37 PM »
Thanks, Alex. It solved the problem.

23
Support Forum / Re: connection error reading from remote HPC
« on: September 26, 2017, 06:48:06 PM »
I was facing the same problem. It turns out that I am not specifying the name of the file at the end of the path to file instead just path itself. Once you give in the name of any one file, it will automatically read-in the others files available in the directory. 

24
Support Forum / Unable to create animation
« on: September 23, 2017, 02:16:36 AM »
Hello OVITOians,

I'm having around 10 CFG files that I dumped from LAMMPS. I'm using macSierra. I'm using this webpage "https://ovito.org/manual/usage.rendering.html" to create movie out of given CFG files it says "QuickTime Player can't open “movie.avi”." Is their any hint whats going around in here. This issue is giving me hard time.

Thank a lot for your time.

Pages: [1]