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 - Alexander Stukowski

Pages: 1 2 [3] 4 5 ... 31
Support Forum / Re: Select atoms at the interface of two materials
« on: August 09, 2018, 02:50:05 PM »
Hi Mike,

yes, you're right. We wrongly assumed that you're already using OVITO 3.0, the current development version, but you are actually using OVITO 2.9.0. For future reference, in case you decide to switch to OVITO 3.0, all changes of the Python API are documented here:
One of the new features of OVITO 3.0 is that the Python programming interface gives you direct access to the vertices and triangles of a computed surface mesh (see here) --something that might be of interest to you.

However, there seems to be a misconception regarding the Construct Surface Mesh function. This function is designed to construct a surface around a group of atoms forming a three-dimensional solid. It does not construct a surface through the selected atoms. In your case, you are passing just the surface atoms to the function, which form a planar sheet. A two-dimensional sheet has no solid volume, that's why you don't get a proper surface mesh.

In other words, you went one step too far here. Instead of extracting the atoms at the interface between the two materials yourself, you could simply pass all atoms of one material to the Construct Surface Mesh function. To do that, first select all particles of one type, then activate the Use only selected particles in the Construct Surface Mesh panel.


Support Forum / Re: running ovito on cluster
« on: August 09, 2018, 02:32:12 PM »

Under Linux, OVITO will automatically try to connect to a running X server if there is one. Even though it is not showing any graphical user interface, this also applies to the script interpreter "ovitos". That's because image rendering via hardware-accelerated OpenGL requires the GLX extension to the X window system.

The detection is based on the DISPLAY environment variable. If it is set, which seems to be the case on your compute node (maybe because you captured all environment variables from the login node during job submission), ovitos thinks an X server is running and tries to connect to it. This fails. The solution to this problem is to clear the DISPLAY variable right before running ovitos, e.g.:

   export DISPLAY=
   ovitos ...


Support Forum / Re: Void in amorphous material
« on: August 09, 2018, 01:31:53 PM »
Hi Zhen,

Since you are interested in the void size distribution, you want to identify the individual voids in the material and determine their sizes, right?

Yes, in principle you can do this by taking the triangle mesh generated by the Construct Surface Mesh modifier, decompose it into disconnected components, one component (polyhedron) per void. For each mesh component, you would then have to calculate the volume it encloses. That is probably the hardest part, because the voids may be non-convex, and calculating the volume of a general non-convex polyhedron is not trivial.

The SurfaceMesh class of the OVITO 3.0 Python interface gives you programmatic access to the vertices and triangles of the surface mesh. From here on you are on your own though. OVITO doesn't provide any built-in functions for calculating the volumes, and I am not working on any such functionality at the moment.

Best regards,

Support Forum / Re: How to coloring particles by its properties
« on: August 09, 2018, 09:49:36 AM »
Thanks for uploading the data files. I ran the script on these files and got the following error message:

Code: [Select]
moglios:eason1021 stuko$ ~/prj/ovito/build/debug/
Traceback (most recent call last):
  File "", line 349, in compute_myproperty
    locals()["px_f_%s"%k] =["px_matrix_%s"%k],locals()["px_matrix_inv_ref%s"%k])
KeyError: 'px_matrix_inv_ref0'
Traceback (most recent call last):
  File "", line 812, in <module>
    data = node.compute(frame_index)
  File "/Users/stuko/prj/ovito/build/debug/", line 178, in _Pipeline_compute
    raise RuntimeError("Data pipeline evaluation failed: %s" % state.status.text)
RuntimeError: Data pipeline evaluation failed: Modifier 'Color coding' reported: The property with the name 'myproperty' does not exist.
ERROR: The Python script '' has exited with an error.

Note that these are actually two errors. The first one occurs in line 349 of the script file ("KeyError: 'px_matrix_inv_ref0'"). The second one, in line 812, is only a subsequent error. Because the user-defined modifier function raises an error, the new particle property is never created and that's why the Color Coding modifier complains about the missing property.

The problem in your script seems to be the usage of the locals() function in various places. Note that it may return a different dictionary depending on the context from where you call it. Inside the user-defined modifier function you have a different set of locals than in the main body of the program where you process the reference structure. Furthermore, modifying the locals() dictionary is generally discouraged any, see the official Python docs:

I suggest you replace it with a simple dictionary that you create at the beginning of your program:

Code: [Select]
myvars = {}

Then replace all occurrences of "locals()" in your code with "myvars".

Support Forum / Re: ModuleNotFoundError: No module named 'sklearn'
« on: August 09, 2018, 08:50:43 AM »
Dear Haomin,

The Python interpreter shipping with OVITO doesn't come with the scikit-learn module. Only numpy is included. Thus, you need to install the module as described in the manual here:

Please run this command from the terminal:
Code: [Select]
ovitos -m pip install scipy scikit-learn

if you are using OVITO 2.9.0, you may encounter a pip connection error due to an expired SSL certificate in the Python interpreter. In this case, please upgrade to the current development release of OVITO 3.0.


Support Forum / Re: How to coloring particles by its properties
« on: August 08, 2018, 04:18:20 PM »
I don't have an explanation for this at the moment. I took the script, removed most of the calculation code and tested it with one of my data files. I didn't see any errors in this case.

Maybe the problem only occurs with your input files, or originates from the actual calculation code which I had to remove for testing. Could you please post your input data files, at least some of them? Then I can test the script with the original input data and investigate why it stops. Please let me also know which exact version of OVITO you are using. Thanks.

Support Forum / Re: How to coloring particles by its properties
« on: August 08, 2018, 01:26:58 PM »
Your script still didn't do the right thing. I see that you have written a for-loop over all input simulation frames. Within that loop, you do the following:

  • request the output of the data pipeline
  • perform some calculation on that output data
  • define a modifier function, which takes that computed data array to create a particle property from it, and append the function to the data pipeline
  • append a Color Coding modifier to the pipeline

Note that steps 3 and 4 will have no effect during the first loop iteration, because the pipeline was already evaluated in step 1, without the two modifiers being inserted into the pipeline yet. Thus, the user-defined modifier function is never called by the pipeline system. Furthermore, in consecutive loop iterations, the pipeline will get longer and longer, because you insert the user-defined modifier function and the Color Coding modifier multiple times.

The correct approach should look as follows (I have rearranged your script accordingly, see the attached file):

  • define a custom modifier function that takes whatever input data is provided by the pipeline system and performs some calculation on it; append that modifier function to the pipeline
  • append a Color Coding modifier to the pipeline
  • loop over the simulation frames and evaluate the pipeline at each timestep

Note that in this approach, the pipeline is first set up completely. Once all modifiers have been inserted into the pipeline, the static pipeline can be evaluated multiple times, once for each frame. The pipeline system will repeatedly call the user-defined function with the correct input data.

Support Forum / Re: visualization of vectors by arrows
« on: August 07, 2018, 04:05:55 PM »
You seem to be using the "Left" viewport of OVITO. That means the y-z plane is the projection plane in this case. You can reset the x-component of the vectors to 0.0 using OVITO Compute Property modifier. This should give you "nicer" arrow heads.

Support Forum / Re: visualization of vectors by arrows
« on: August 07, 2018, 03:59:35 PM »
Dear Ilya,

The arrows would look better if the vectors were parallel to the projection plane of the viewport. In your case, I assume, the vectors have a large component perpendicular to the projection plane (i.e. along the y-axis). That's why the heads of the (flat-shaded) arrows appear degenerate in the second picture and that's why you see the circular bottoms of the head cones of the normal-shaded arrows in the first picture.

Maybe there is a way for you to reduce the out-of-plane component of the vectors and project them into the plane of the viewport. This should improve the arrow visualization.


Support Forum / Re: Error redering image python script
« on: August 07, 2018, 10:32:38 AM »
You can check which installation of the Qt libraries Ovito is being built against by running "cmake -L" in the build directory. You should look for a set of cmake variables named "Qt5*_DIR" which point to the Qt library directory. 

To find out which version of Qt the PyQt5 Python module is loading, start up your Python interpreter and execute

Code: [Select]
import PyQt5

The directory path should contain a bunch of shared library files (Qt*.so). Run "ldd" on one of these .so files in the terminal to find out which Qt installation it was linked to. If it just says "statically linked", you may have a problem. It would mean that Qt was statically linked into the PyQt5 module libraries and there is no way for Ovito to use the same Qt libraries. I think in this case it might become necessary to rebuild the PyQt5 Python module from source.

Support Forum / Re: Error redering image python script
« on: August 07, 2018, 08:23:42 AM »

I haven't seen this error message before and seems confusing as you probably agree:
Code: [Select]
TypeError: wrapinstance() argument 2 must be sip.wrappertype, not sip.wrappertype

My guess is that this error is due to some sort of installation compatibility problem. Maybe you are mixing different versions of the same library in the same program, perhaps the PyQt5 module libraries. In particular, make sure that the PyQt5 module installed in your Python interpreter was built against the same Qt libraries which Ovito was built against.

One question: Are you running this script through the 'ovitos' interpreter or a standard CPython interpreter?

Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 05:39:52 PM »
Typically, you would insert this statement right after the line that creates the pipeline, i.e. right after the call to import_file().

Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 05:27:13 PM »
If you intend to produce a visual output, it's important that you add the pipeline (or rather its output) to the scene. This doesn't happen automatically for datasets imported via the import_file() function. See the first note on this page in the green box:

To add the pipeline's output to the scene and make it visible in the viewports of OVITO and in rendered images, add a call to the add_to_scene() method to your script:

Code: [Select]

Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 04:54:25 PM »
Thanks. I got your code and I am still trying to understand what you are doing and what your goal is.

You wrote that nothing happens when you run this script. What do you expect it to do? Do you want to produce an image or a movie? Or would you like to see the computation results in the viewports of OVITO? Or do you want to produce a series of data output files?

Support Forum / Re: How to coloring particles by its properties
« on: August 06, 2018, 04:29:27 PM »
When you post a message on this forum, you have the option to attach entire files to your message (similar to attachments in emails). Other forum users like me can then download the attached file and open it in a text editor, for example.

Pages: 1 2 [3] 4 5 ... 31