Compute quantities from converged simulations

Version: 2016.0

In this tutorial, you will learn how to start a converged calculation to add additional functions. In this way a lot of simulation time can be saved.

What can you do if you forgot to add the Bandstructure analysis to your script when you set it up? Or you discover you probably need more k-points to get a converged transmission spectrum? Do not worry - with ATK you don’t have to compute all quantities together with the self-consistent calculation. You can always compute them later on, by reading the converged state of the calculation from the NetCDF file.

Using the Script Generator script_generator_icon is usually the easiest way to do post-processing analysis, especially for small calculations. The post-processing can take some time, however, especially to compute the transmission spectrum or DOS with many k-points. In those cases you might want to run the script in parallel on a cluster (the analysis calculations usually parallelize linearly up to very many nodes). If so, it is still very handy to set up the script using the Script Generator, and then save it. That is - just like you would do it for the main self-consistent calculation itself.


Start a new Script Generator script_generator_icon from the QuantumATK toolbar. When you open it without dropping any configuration on it, the only available block is Analysis from File, which is precisely what we want - to perform analysis based on a NetCDF file. Double-click this block to insert it into the script.

Open it, then browse and select the relevant NetCDF file.


If you intend to run the script on another computer, from the command line (e.g. in parallel) you must naturally copy both the script and the NetCDF file to it. Make sure to place the two files in the same directory, and only specify the name of the input NetCDF file, without any path.


Next, check that the Object id corresponds to the self-consistent calculation you want to base the analysis on. If your calculation was a “standard run”, then most likely the default gID000 is the one you want. However, if you did a geometry optimization, gID000 corresponds to the initial geometry, and the optimized geometry will be gID001. You can inspect the contents of the NetCDF file, and the object ids, in the LabFloor in the main QuantumATK window.

Click OK, and then add all the Analysis quantities you want to compute, and set the parameters as appropriate.


Finally, give a name and location at the blank Default output file.


As above, if you will run the script from the command line on a different computer, just set a name without a path, in order to save the file in the running directory.


You might want to save the computed analysis quantities in a separate NetCDF file, in order not to make the original NetCDF file too big.

Now either send the script to the Job Manager job_manager_icon by using the Send To button sendto_icon at the lower right corner, as usual, or save the script and copy it (with the NetCDF file!) to the cluster and run it from the command line.

If you haven’t looked into the Python scripts used by ATK, this is an excellent type of script to start with. If you send the script to the Editor editor_icon, you will see the following.


You will see that each function of the script is separated into blocks and under each block, there are lines to setup the detail parameters of the simulation. The line that does the main trick is at the very top, using the function nlread() to read the configuration from the NetCDF file.


nlread() can in principle read many objects at once from a NetCDF file. Object ids must however be unique, so by using the object_id keyword, you are guaranteed to get only one object back. However, nlread() always returns a list of objects, even if there is only one match, so we need the [0] to pick out the first/only configuration matching the object_id.