Table of Contents
In NanoLanguage you will primarily use two types of files for input and output:
These two types of files serve different purposes: VNLFile are for storing structural configurations (e.g. molecules, bulk or two-probe systems), calculated properties (e.g. eigenstates, transmission spectra etc. ) whereas NetCDF files are for storing self-consistent field calculations.
The NetCDF file format is an open file format suitable for storing vast amounts of scientific data. In NanoLanguage, these files are used to store converged or on-going DFT calculations. This is useful in order not having to redo lengthy calculations, thus saving computational resources.
This file is the only place where information needed to restore a previously performed calculation is located. So if you need your converged calculation later on, you want to save this file.
If you want to save information from a DFT calculation performed in NanoLanguage using e.g. KohnShamMethod, in order to write a NetCDF you must specify a name for this file, using the setCheckpointFilename() function. If you just specify the filename (i.e. no path) the file will be saved in the same directory as the NanoLanguage file. The name of the NetCDF checkpoint file can also be specified using a parameter dictionary argument to the self-consistent calculation; see runtimeParameters().
When you want to restore your DFT calculation, you should use the restoreSelfConsistentCalculation() function, which
returns an object of type SelfConsistentCalculation. This
object can then be used either to calculate a specific property or to continue an
already started DFT calculation; e.g. if your computer crashes while calculating you
can resume from the NetCDF file.
If you want to store structural configurations or specific properties extracted from a DFT calculation you should use the VNLFile format. These files can be used with the Virtual NanoLab for e.g. 3D rendering of molecules, bulk samples or visualization of isosurfaces, Bloch states or other properties.
Previously created structures, which have been saved in a VNLFile, can be restored using the readAtomicConfigurations() method of the VNLFile object.
You can store multiple objects in the same VNLFile and in this way build a collection of structures into a single file or use it for collecting several experiments for a single structure.
Sometimes it might be desirable to store information obtained from ATK in a format compatible with other applications than VNL. Information contained in NanoLanguage objects originating from calculations can be retrieved and stored into files using the conversion methods implemented in each object. Please refer to the individual calculation method in the Reference manual index to see which conversion methods it supports.
Because NanoLanguage is Python based, the powerful pickle module can be used to save objects in files, and
then restore these at a later time. The process of storing the information into a
file is referred to (in Python terms) as pickling
whereas the process of retrieving the file information is referred to as unpickling. In this way, one can export and import
information (even objects!) for later use. The method we will use is the
dump() method of the Pickler object.
from ATK.KohnSham import * import pickle elements = [ Carbon ]*2 coordinates = [ (0.0,0.0,0.0), (0.25,0.25,0.25) ] diamond_lattice = FaceCenteredCubic( 3.567*Ang ) diamond = BulkConfiguration( diamond_lattice, elements, fractional_coordinates = coordinates ) # Create file into which output will be stored outputFile = open('exportedData.txt','w') # Create object to store information into output file translator = pickle.Pickler(outputFile) # Write Cartesian coordinates of a BulkConfiguration into output file translator.dump(diamond.cartesianCoordinates())
We have now transferred our diamond structure into the file
exportedData.txt for later use.
To unpickle an object, we create an instance of
the Unpickler class and use the
load method of this object.
import pickle # Open output file and prepare to retrieve information. inputFile=open('exportedData.txt','r') translater=pickle.Unpickler(inputFile) importedObjects=[] # Load pickled objects into a list for later retrieval for object in translater.load(): importedObjects.append(object)
The list importedObjects now contains
the objects that were stored in the file and you can use these by accessing the
list as you would normally do.
The files containing the pickled information are stored in a binary format, and is not humanly readable. It is therefore necessary to unpickle the files before the information can be retrieved.
The pickle module provides a convenient way of exporting
information from an ATK calculation without having to use the VNLFile.