QuantumATK Forum

QuantumATK => Scripts, Tutorials and Applications => Topic started by: Anders Blom on June 15, 2009, 10:43

Title: Convert old atk files to NanoLanguage
Post by: Anders Blom on June 15, 2009, 10:43
The short story

Some users may still have a lot of .atk input files for ATK 2.0 and earlier. The script attached in this post makes it extremely simple to upgrade such files to NanoLanguage files. The script converts all kinds of ATK 2.0 input files, including two-probe systems, into NanoLanguage scripts, ready to be run!

Quote
Compatibility note
To run the conversion script requires ATK 2.3 or higher. The generated scripts are compatible with ATK 2.2 and later (and also ATK 2.1 and 2.2 with relatively small modifications). However, we recommend you to use the latest ATK for several reasons (calculation speed, bug fixes, etc, etc)!

Introduction

It is our hope and intention, that these generated scripts will make it easier to learn NanoLanguage, and to lower the barrier in learning the new input format. Once you can see how the old keywords translate into NanoLanguage, it will be a simple matter to use the converted scripts as templates for new calculations, with different geometries and/or different parameters.

The script is very simple to use: download it into the directory where you keep you keep your atk files. Then, download and install the latest ATK, and run

Code
atk convert_atk_to_nl.py input.atk > script.py

for each input file (here symbolically called input.atk) you wish to convert. Batch processing is also possible, along the lines of (in bash)

Code
for i in *.atk ; do
    atk convert_atk_to_nl.py $i > $i.py
done

Two-probe systems

To convert two-probe systems, the input file should be the two-probe file (containing the definition of the central region). The script will automatically attempt to locate, and convert, the electrode files, based on the keywords TwoProbe::LeftElectrode::ATKFile or TwoProbe::LeftElectrode::NetCDFFile (and correspondingly for the right electrode). If the NetCDF keyword is used, the script will look for an ATK input file by the same name, but with the extension .atk. If this file is not found, the conversion will fail. In this case, please edit the two-probe script to match the names of the electrode input files.

Two-probe systems will be considered as heterogeneous if the name of the input files for left and right electrode are different. In this case, separate configurations and parameters will be defined for the left and right electrode, respectively, and the multigrid method will be employed in the two-probe calculation.

Output control

The generated script will, when you run it in ATK, produce verbose output (if you prefer less output, you can modify the verbosity_level defined in the head of the conversion script) a VNL file containing the structure, and a NetCDF checkpoint file.

All these files are named after the original input file, but with an additional label "converted" in the name. At the top of the conversion script are a few parameters that furthermore effect the output script:


Specific details

The following additional things should be noted about the conversion:


In NanoLanguage, it is necessary to specify explicitly the Bravais lattice for bulk systems, while in ATK 2.0 the unit cell was given as just three vectors. The conversion script will attempt to recognize the simplest lattice types:

Code
simple cubic
fcc
bcc
simple tetragonal
simple orthorhombic
rhombohedral
hexagonal

All other lattice types will be represented as Triclinic. This actually has no effect on the calculations, as the lattice type is never used explicitly in NanoLanguage.

Note that a tolerance factor is employed in the recognition of the lattice type. This tolerance is used for comparison of angles and lattice constants to each other and known values. The default is 1e-5, which seems to work fine for orthogonal lattices. It might, however, be too low for hexagonal if the lattice vectors are given with
few decimals. In that case, it is safe to increase the value to, say, 1e-3. The parameter is easily accessible at the top of the script.

Unsupported keywords


Compatibility notes

To make the converted scripts compatible with ATK 2.1 and 2.2 is generally very simple. In fact, most converted scripts will work fine with these versions, and require no changes, except this one: Remove the nlPrint() statements.

After that, the first step, if you have an older version of ATK that you wish to use, is to simply test the script! If it fails, try these things to make the script compatible:


In all cases, these changes should only be necessary if include_defaults was set to True.

Final notes

You should always inspect the converted file carefully to verify that the conversion was successful, before attempting any calculations.

The script has been tested on a large amount of input files, but there may be special situations that have not yet been considered. If the script fails to convert an input file, or the converted script does not correspond to the input, please report the problem in this thread so that we can fix the problem!

We hope you will enjoy working with NanoLanguage, and explore and discover the much enhanced flexibility and control that the new input format offers over the old keyword-based input files. This script should hopefully make the transition easier!