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 ... 25
Extending the Bin and Reduce modifier to also support 3d grids is on my wish-list, yes. I am currently working the data model design that will lay the ground work for this.

No, OVITO currently doesn't have a built-in function for exporting the graphical representation of the 2d data grid computed and visualized by the Bin and Reduce modifier. But with some scripting and the matplotlib module of Python one can do it, of course. Python scripts can access the data produced by the Bin and Reduce modifier.

Support Forum / Re: Rendering Images with Python Script
« on: May 18, 2018, 10:12:43 PM »
Yeah, my mistake, here in this line:
Code: [Select]
pipeline.modifiers.append(AssignColorModifier(color=(0.3, 0.3, 1.0))

The third closing ')' is missing at the end to match the three opening '('.

Support Forum / Re: Rendering Images with Python Script
« on: May 18, 2018, 05:22:07 PM »
Can you please post the entire file as an attachment. From the error message I cannot tell where this is coming from.

Support Forum / Re: Rendering Images with Python Script
« on: May 18, 2018, 12:15:06 PM »
Giving vacancy sites a certain color depending on the type of atom that originally occupied that site in the perfect crystal is straightforward. Simply use a ExpressionSelectionModifier followed by an AssignColorModifier:

Code: [Select]
pipeline.modifiers.append(ExpressionSelectionModifier(expression = 'Occupancy==1 && ParticleType==1'))
pipeline.modifiers.append(AssignColorModifier(color=(0.3, 0.3, 1.0))
pipeline.modifiers.append(ExpressionSelectionModifier(expression = 'Occupancy==1 && ParticleType==2'))
pipeline.modifiers.append(AssignColorModifier(color=(0.2, 0.6, 1.0))

(Note that this code is for OVITO 3.0-dev. The SelectExpressionModifier class from OVITO 2.9 has been renamed to ExpressionSelectionModifier.)

Coloring interstitial atoms depending on their chemical type is less straightforward, but can probably done and will probably require turning on the per_type_occupancies option. I guess you want interstitials to be coloured according to their own chemical type, not the chemical type of the site they are sitting on, right? If yes, then one has find a way to determine which of the two (or more) atoms occupying a site is the interstitial and which one is the original atom (if any).

Dear Afshin,

If you understand you correctly, you would like to transfer some atomic property from the unstructured atoms to a three-dimensional structured grid. Is that right? So this function would be similar to the existing Bin and Reduce function, but using a three-dimensional grid of bins instead of two-dimensional.

Dear SG,

The RDF is a statistical distribution and not something that can be calculated for individual atoms. So please clarify how you mean that. For a given BCC atom, would you like to compute the distances to all its neighbours within a certain cutoff range?


Support Forum / Re: Rendering Images with Python Script
« on: May 12, 2018, 02:07:30 PM »
I now ran your script myself with OVITO 2.9.0, and I can confirm that are indeed some issues. I was able to find a workaround for the zooming issue, but the viewport overlay function, which is needed to render the scale bar, seems to be broken in that program version. It might be that it cannot be used from a batch script at all, only within the GUI.

In this situation I suggest you switch to the current development build of OVITO 3.0.0 instead. The old 2.9 release is already one year old and issues like the one encountered here have been fixed since then. The Python programming interface has been further simplified, but that also means you will need to adjust the code accordingly. I have done that for you already. Below you find the updated script code, which should work correctly with OVITO 3.0.0-dev198 according to my tests:

Code: [Select]
from import *
from ovito.vis import *
from math import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

pipeline = import_file("../../")

# Turn off cell display:
pipeline.get_vis(SimulationCellVis).enabled = False

bar_length = 100 # Simulation units (e.g. Angstroms)
bar_color = QColor(0,0,0)
label_text = "{} nm".format(bar_length/10)
label_color = QColor(255,255,255)

# Define the overlay function, which renders the scale bar:
def render_overlay(args):
    # Compute length of bar in screen space
    screen_length = args.project_size((0,0,0), bar_length)

    # Define geometry of bar in screen space
    height = 0.07 * args.painter.window().height()
    margin = 0.02 * args.painter.window().height()
    rect = QRectF(margin, margin, screen_length, height)

    # Render bar
    args.painter.fillRect(rect, bar_color)

    # Render text label
    font = args.painter.font()
    args.painter.drawText(rect, Qt.AlignCenter, label_text)

# Create a viewport and install overlay function:
vp = Viewport()
# This selects a parallel projection with viewing direction along -Z axis:
vp.type = Viewport.Type.TOP
# Adjust camera pos and FOV automatically:
# Alternatively, set parameters explicitly:
#vp.camera_pos = (251.497,251.551,550.188)

# Set up renderer
renderer = TachyonRenderer()

# Now render the frames, one by one:
for frame in range(pipeline.source.num_frames):
    print("Rendering frame", frame)
    vp.render_image(frame=frame, size=(1920,1440), filename="t"+str(frame)+".png", renderer=renderer)


Thanks for clarifying what you meant, and I'm sorry that I didn't realise at first that you are using the "Color lines by Burgers vector" mode and not the "Color line by dislocation type" mode.

The answer remains more or less the same though. I didn't have time yet to implement a customization option for the user and the set of line colors is currently hardcoded in the source code of OVITO and cannot be changed by the user. Here are the corresponding lines in the source code:

There are seven colors in total: four 1/2<111> and three <100> Burgers vectors for the BCC crystal lattice.

For the time being you would have to modify the source code and recompile OVITO if you want to customise these predefined colors.

Support Forum / Re: Rendering Images with Python Script
« on: May 11, 2018, 09:25:02 PM »
Dear Ben,

1) I am not really sure how this issue arises. What I noticed in your script is that you never set the field of view of the camera explicitly (i.e. the Viewport.fov parameter). You only set the camera position and the direction. My suggestion is that you either set the FOV value, i.e. the size of the visible render region, explicitly, or call the Viewport.zoom_all() to let OVITO choose the FOV value automatically in order to fully show the entire dataset.

2) Another mistake I noticed is that you add the user-defined viewport overlay function inside the for-loop that renders the series of frames. That means you keep adding multiple overlays to the viewport's list of overlays, one more with each frame. This certainly isn't what you want. You should rather add an overlay just once before entering the for-loop, i.e. in the following order:
Code: [Select]
# Install the user-defined viewport overlay, which will render the scale bar:
def render_overlay(painter, **args):
overlay = PythonViewportOverlay(function=render_overlay)

# Now render the frames, one by one:
for frame in range(0,dataset.anim.last_frame+1):
I'm not sure though why the scale bar is not showing. If you didn't modify the original code of the overlay function, which was taken from the OVITO docs, it should work. Perhaps it is related to the first issue above then. Let's see.


Support Forum / Re: Calculating atomic density
« on: May 11, 2018, 10:14:07 AM »
What I meant was to use the Compute property modifier and simply enter "1" as math expression. You can pick any name for the particle property to be generated, but not one of the standard names from the drop-down list.
What this modifier will do is to assign a new property with the given name to each particle with the value 1.

Well, I can spot several syntax errors in this code. What you wrote is not valid Python code, and with that you will not get very far. Please understand that I simply do not have the time to give a general introduction to the Python language.

Maybe there is another programming language you prefer instead. You could export the bond vector list to a text file and then write a program to process the data externally. The savetxt() method of Numpy would allow you to do that:

Code: [Select]
def modify (frame, input, output):
particle_positions = input.particle_properties.position.array
bonds_array = input.bonds.array
bond_vectors = particle_positions[bonds_array[:,1]] - particle_positions[bonds_array[:,0]]
bond_vectors +=[:,:3], input.bonds.pbc_vectors.T).T
numpy.savetxt('bond_vectors.txt', bond_vectors)

Unlike in the example where you copied this code from, which was operating on the output of a data pipeline ("node.output"), in the present context you have to take the atomic coordinates from the input of the user-defined modifier function. Thus, replace "node.output" with "input" in the first two lines of the function.

Then the existing code should work with an error message showing up. You can then continue and compute the angles formed by the bond vectors.

This may be difficult, because particle selection sets don't have a particular ordering. The ordering is always the same and equal to the ordering of the full list of particles. OVITO's file export function will always write the list in that same order.

How exactly did you select the atoms that you want to export? Using the Manual Selection modifier?

Most likely you will need to use a Python script modifier for this and write a short Python function, because there is no built-in function for this particular computation in OVITO. The user-defined modifier function would first compute the bond vectors and then the angles. Finally, this modifier function would output the angles as a new bond property.


Dear Jinyu,

OVITO defines a hardcoded set of dislocation types for each crystal type, for which default colors are prescribed. You can find this list in the source code here:

For BCC, three typical dislocation types are predefined, all being lattice dislocations and not GB dislocations.
For all other, non-standard dislocation types, a single default color is used to visualise the dislocation lines. I'm afraid there is no way to assign other colors to them within the program. The only option you have is to modify the source code, add your specific Burgers vector types to the list, and rebuild OVITO.

If you want, you can create an issue with a feature request on GitLab, so that I can add support for custom dislocation types in the future:


Support Forum / Re: VTK mesh transparency
« on: May 07, 2018, 06:46:33 PM »
Dear Tomek,

For VTK triangle mesh files that do not contain any color information, OVITO already allows you to set the global transparency of the mesh. See the attached screenshot.

However, for VTK geometries containing color information, like in the following example file, the transparency setting has no effect:

But note that the color values in the VTK file typically have 4 components (RGBA), allowing you to specify an alpha transparency value for each triangle cell in the input file. OVITO will use this per-face transparency information.


Pages: [1] 2 3 ... 25