Go to navigation


Atomic Blender (PDB/XYZ) and the Atomic Simulation Environment

Blender Logo

Blender
(version >= 2.8) in combination with Atomic Blender can be combined with the Atomic Simulation Environment (ASE).

How does this work? Basically,
either a single xyz file or Atoms object or a list of them (several structures) is (are) handed over to a function (blend_show or blend_render), which can be called from an ASE Python script. In the case of an Atoms object, a temporary xyz file is created or several files, if a list of Atoms objects is used. A Blender startfile is then created, which is called afterwards by Blender during the start of Blender. With help of the startfile, the xyz file is called and the atomic structure is finally imported into Blender. The startfile is in fact a modified Atomic Blender addon.

You need Blender version >=2.8.

Download: Download the following zip file:

ase_blender_install.zip (very old version !)

Linux Conditions
1. ASE must be in:
'/usr/lib/python2.7/dist-packages/ase/'
2. Blender must be in: '/usr/bin/blender' such that it can be executed by 'blender'

Extract the file and execute the file 'Install_files_Linux.sh'
in a terminal with superuser rights. For instance, if you work with a Debian like Linux system (e.g., Ubuntu) type: 'sudo sh Install_files_Linux.sh'. The ASE-Blender scripts will be installed in '/usr/lib/python2.7/dist-packages/ase/blender'.

Mac OS X Conditions
1. ASE must be in your local folder: '$HOME/ase/ase/'
('/Users/<user>/ase')
2. Blender must be in Applications: '/Applications/Blender/blender.app/Contents/MacOS/'

Extract the file and execute the file 'Install_files_Mac.sh'
in a terminal with superuser rights: 'sudo sh Install_files_Mac.sh'. The ASE-Blender scripts will be installed in '$HOME/ase/ase/blender'.

Windows I have no idea if this also works under Microsoft Windows.



After the installation, you can now import two functions
in your Python script:

from ase.blender import blend_show, blend_render
 
The options of the two function are:

blend_show(slab, **kwargs)
slab
Either a single (or list of) Atoms object(s) or path to a single (several) xyz ASCII file(s). Blender accepts xyz files with several frames, which can be used for animations. Atomic structures described in a list are put into different scenes of Blender.
**kwargs, optional (values: default)
screen = Default
The type of screen can be determined. Either 'Default' or 'Compositing' can be used.
mesh = False
Use mesh balls instead of NURBS
mesh_azimuth = 32
If mesh balls, number of sectors in azimut
mesh_zenith = 32
If mesh balls, number of sectors in zenith
scale_ballradius = 1.0
Scale factor to scalle all atom radii
atomradius = "1"
Atom radii: '0' pre-defined (default atomic radii), '1' atomic radii, '2' van der Waals
scale_distances = 1.0
Scale factor to scalle all distances
use_center = True
Center the atomic structure into the center (0,0,0) of the world
use_center_all = True
...
use_camera = False
Use a camera. The camera is placed into a distance such that the atomic structure can be well seen from the camera. Push '0' on the number pad after Blender has loaded the structure. You see the structure from the camera point of view
use_lamp = True 
Use also a point light source
load_frames = False
Load the frames, if present. Note: The number of atoms must not vary, it has to be constant for all frames.
frame_skip = 0
Skip each nth frame.
frame_delta = 1
Introduce more frames between each pair of frames, and interpolate the movement. frame_delta = 1: means no additional frames.
blender_close" = False
Close Blender after having opened. This is important for the rendering without the Blender UI opened. See function blend_render.
blender_save_file" = ""
Save the Blender scene into a Blender .blend file.  This will be always done if the string is not empty.


blend_render(slab, file_blend, file_img_mov, **kwargs)
slab
Either an Atoms object, surface or other structure, or the path to a xyz ASCII file. Blender accepts xyz files with several frames, which can be used for animations.
file_blend
This is the Blender file, in which the scene is saved to.
file_img_mov
This is the image or movie file name
**kwargs, optional (values: default)

same optional options from above (blend_show) +
image_format = "PNG"
Image/movie format (AVIRAW, AVIJPEG, PNG, BMP).  
frame_start = 1
Render from frame 'start' to ...
frame_end   = 1
... frame 'end'


The Wiki pages describe the parameters of the xyz importer in more detail.


Examples:
Here are a couple of examples:

ase_blender_cluster.xyz
You need this file for some of the examples.
ase_blender_example1.py
An Al(111) surface terminated by a few hydrogens is generated. The surface is then shown in Blender.
ase_blender_example2.py
A Cu nanoparticle is loaded from the xyz file ase_blender_cluster.xyz, which contains some frames. The nanoparticle is shown in Blender, including all frames.
ase_blender_example3.py
The same Cu nanoparticle is loaded from a xyz file and a picture is rendered. Note that Blender has to open and save the scene first. After, Blender closes and renders the scene in the terminal. Results: ase_blender_example3.blend and ase_blender_example3_0001.png
ase_blender_example4.py
The same Cu nanoparticle is loaded from a xyz file and a movie is created from the frames. Note that Blender has to open and save the scene first. After, Blender closes and renders the movie in the terminal. Results: ase_blender_example4.blend and ase_blender_example4_0001-0015.avi
ase_blender_example5.py An example, which shows how a movie of a molecular dynamics calculation can be created by Blender. Result: ase_blender_example5.blend and ase_blender_example5_0001-0020.avi
All examples
All results



The examples show that Blender and ASE can work together in a very powerful manner. ASE is producing a slab of atoms whereas Blender is loading the atomic structure and performing the visualization. Since both, Blender and ASE, work with Python and since their libraries contain a huge amount of useful commands that can be used for simulations (ASE) and visualization (Blender), many complicated and complex things can be automatized within one Python script.


For those, who are new to Blender

Note that before you start with the Atomic Blender addons you have to understand the concept of Blender. The following page supplies some info about the installation of Blender and some links to tutorials one can find in the internet:

Important information about Blender

More details about the Python API of Blender can be found here:

Current Python API of Blender























Go to top