Go to navigation


Atomic Blender and the Atomic Simulation Environment

Blender Logo

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

How does this work? Basically,
either a xyz file or Atoms object, surface or other structure is handed over to a function (blend_show or blend_render), which I have created for ASE. In the case of a structure, the function creates a temporary xyz file. 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 XYZ addon.

Note: The project is still quite new, so the scripts can change from time to time. You need Blender version >=2.6, don't take a version < 2.6! Last update: 2012-11-02

Download: Download the following zip file:

ase_blender_install.zip

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 Since ASE seems not be well working under Windows (see here), I have done nothing so far. However, in principle it should be possible but the paths in the script '__init__.py' have to be changed.



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 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.
**kwargs, optional (values: default)
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 ...

http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/XYZ

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

Details about the Python programming environment of Blender can be found on the following pages:

http://www.blender.org/documentation/blender_python_api_2_64_release/info_quickstart.html
http://wiki.blender.org/index.php/Main_Page
http://www.blender.org/documentation/blender_python_api_2_64a_release/
http://www.blender.org/documentation/blender_python_api_2_62_1/bmesh.html

























 

Go to top