XCrySDen --
(X-Window) CRYstalline Structures and DENsities

Home | About | Description | Documentation | Download | News | Links
XCrySDen's scripting HOWTO

Table of Contents

What is scripting
    The "scripting::" scripts
    The XCrySDen generated scripts

What is scripting

In some circumstances it would be desirable to perform particular tasks in some automatic way without any user interactivity. In such a case the executive operations are encapsulated inside a script. Typical use of scripting is when several similar jobs have to be performed, such as, for example, plotting all the valence molecular orbitals (MO) of a give molecule. Typically in all MO plots one would like to keep the same display parameters. It would really be cumbersome and a pure waste of time to perform, for example, 15 alike jobs interactively. In such cases scripts would be much more convenient as all operations would then be performed in automatic way. XCrySDen have specially designed programming scripting interface for achieving above mentioned goal. XCrySDen scripts use the Tcl syntax. Technically speaking XCrySDen scripts are Tcl scripts. The specially designed scripting functions use the scripting:: namespace. However one can use any XCrySDen Tcl function in such scripts. XCrySDen scripts can be either loaded from command line as xcrysden -s scriptFile or xcrysden --script scriptFile, or alternatively from menu File-->Open Structure ...-->Open XCrySDen Scripting File .

The "scripting::" scripts

In scripts that were manually written the scripting:: functions most likely represent the majority of the commands. Here you can found documentation about the scripting:: interface, together with hypertext examples. The documentation was automatically generated from the source code. The easiest way to learn "how to write" such scripts is to start with examples. The basic knowledge of Tcl-syntax is welcome here. The examples are well documented, and since they are written in hypertext manner, they have hypertext references to all used functions. XCrySDen distribution contains several scripting examples. See the $XCRYSDEN_TOPDIR/examples/Scripting/ directory. They can be also accessed using the File-->XCrySDen Examples ...-->Scripting Files menu. Here is a list and short description of several scripting examples:
-- a simple example for animating a molecular structure
-- shows how to edit atomic labels
-- animates and builds a crystal structure
-- a simple example for animating a contour plots
-- plots contours+colorplane from XSF file
-- a simple example for display of MO from Gaussian cube file
-- plots and prints isosurface and contours
-- a simple example for making a MPEG movie
-- a simple example of multi-job script

The XCrySDen generated scripts

There exists another type of XCrySDen scripts. This type of files is automatically created by XCrySDen when saving the current state and structure using the File-->Save Current State and Structure menu. The default file-extension of these files is *.xcrysden. Such a script contains the structure and the majority of the display parameters. When the script will be loaded (i.e. as xcrysden -s script) the structure will be displayed in the same way as it was saved, i.e., having the same orientation, zoom, colors, and other display parameters. These scripts do not use the scripting:: interface, and are messy although somewhat documented. It is possible to use part of these scripts together with the manually created scripts. A typical use would be: display a structure and set proper display parameters. Save with File-->Save Current State and Structure . Then use this saved parameters (this means extracting the right part of the *.xcrysden file) inside the manually created scripting:: script. Here is an example of *.xcrysden script.

Home | About | Description | Documentation | Download | News | Links
Webmaster: Tone Kokalj
This document was last modified on Wed Oct 7 16:08:45 CEST 2015