Table of Contents
Molecular systems constitute the simplest and most basic of the settings that can be analyzed using ATK and NanoLanguage. For such system, you will be able to
calculate molecular energy spectra
Define any molecular geometry
Access to the entire periodic table
Total energy and forces
Effective potential, electron densities, and eigenstates.
Mulliken populations.
Eigenstate occupations.
Calculate spin-specific properties.
Access to several exchange correlation functionals.
Calculate optimized molecular structures.
Read on through the subsequent section, for a quick introduction to some of the many tools NanoLanguage offers for analyzing molecular systems.
Setting up the geometry of molecular structures using NanoLanguage is simple. All you have to do is
define a list of atomic constituents and their respective positions
store the above information in the NanoLanguage class MoleculeConfiguration
The MoleculeConfiguration object is then ready to be passed on for investigation and calculation of its physical properties. Here is a short script example for setting up and storing a water molecule
# Import the KohnSham module from ATK from ATK.KohnSham import * # Set up elements and positions elm = [ Oxygen, Hydrogen, Hydrogen ] pos = [ ( 0.000, 0.000, 0.0)*Angstrom, ( 0.757, 0.586, 0.0)*Angstrom, (-0.757, 0.586, 0.0)*Angstrom ] # Add them to a configuration h2o = MoleculeConfiguration(elm,pos) # Open a VNL file and add the molecule to it vnl_file = VNLFile('h2o.vnl') vnl_file.addToSample(h2o, 'h2o')
Define atomic constituents and their positions
Store the molecule as a MoleculeConfiguration object,
Save the molecular configuration to a VNLFile. In this way, the configuration can be loaded and used from other scripts, and may also used for generating 3D renderings in VNL.
Run the script by issuing the command
atk water-viz.py
from the command line.
Once you have the geometry of your structure defined, you are ready to take advantage of the rich set of NanoLanguage functions and classes that are available for calculating the physical properties of your system. This requires to simple steps
define the method that should be used for running the DFT analysis of your structure
apply the method to your molecular configuration
choose the NanoLanguage function that should be used for determining the particular physical property that you wish to determine
For example, here is a script that loads the water molecule defined above and determine its total energy
# Import the KohnSham module from ATK from ATK.KohnSham import * # Load molecule from VNLFile h2o = VNLFile("h2o.vnl").readAtomicConfigurations()["h2o"] # Perform a selc-consistent calculation method = KohnShamMethod() scf = method.apply(h2o) print 'Total energy = ', calculateTotalEnergy(scf)
Restore the water molecule configuration from a VNLFile.
Choose the KohnShamMethod DFT method with default parameters. If you wish to tweak the input parameters that influence the finer details of the DFT method, this can of course also be done. A full list of available options for the KohnShamMethod is given here.
Calculate the total energy using the NanoLanguage function calculateTotalEnergy().
Run the script by issuing the command
atk water02-etot.py
from the command line.
Once you have your system defined, only a few lines of additional NanoLanguage scripting is necessary for extracting complicated physical properties. Again the steps are simple
Either define or load your system from a preexisting VNLFile.
Setup and perform the DFT method(s).
Use NanoLanguage functions for extracting the desired physical properties.
Here is a simple script for calculating and printing the energy spectrum of a water molecule
# Import the KohnSham module from ATK from ATK.KohnSham import * # Load molecule from VNLFile h2o = VNLFile("h2o.vnl").readAtomicConfigurations()["h2o"] # Set up Kohn-Sham for two exchange correlation functionals gga_calculation = KohnShamMethod(exchange_correlation_type=GGA.PBE).apply(h2o) lda_calculation = KohnShamMethod(exchange_correlation_type=LDA.PZ).apply(h2o) # Perform the actual calculations gga_spectrum = calculateMolecularEnergySpectrum(gga_calculation).energies() lda_spectrum = calculateMolecularEnergySpectrum(lda_calculation).energies() # eV = electronVolt print ' Energy eigenvalues for water (in eV)\n' print '-----------------------------------------' print ' LDA\t\t GGA\t\t diff\t' print '-----------------------------------------' for (E1,E2) in zip(lda_spectrum,gga_spectrum): e1 = E1.inUnitsOf(eV) e2 = E2.inUnitsOf(eV) print '%7.3f\t\t%7.3f\t\t%7.3f' % (e1,e2,(e1-e2))
Load the molecule from a VNLFile.
Perform two DFT calculations, using different exchange correlation functionals.
Use the NanoLanguage function calculateMolecularEnergySpectrum() for calculating the spectra of the respective exchange correlation functionals.
Use a Python for-loop for printing out the spectra.
Run the script by issuing the command
atk water02-egv.py
from the command line.
The results that you calculate with your NanoLanguage scripts can be stored using the flexible VNLFile storage format. Import these files into VNL and have access to advanced 3D rendering of complicated physical objects.
Here are the simple scripting lines needed for storing and later rendering the HOMO-LUMO orbitals of the water molecule.
# Import the KohnSham module from ATK from ATK.KohnSham import * # Load molecule from VNLFile h2o = VNLFile('h2o.vnl').readAtomicConfigurations()['h2o'] method = KohnShamMethod() scf = method.apply(h2o) # calculate HOMO and LUMO eigenstates egvs = calculateEigenstates( self_consistent_calculation=scf, quantum_numbers=( [3,4] ) ) results = VNLFile('results.vnl') results.addToSample(h2o, 'h2o') results.addToSample(egvs[0], 'h2o','0') results.addToSample(egvs[1], 'h2o','1')
Load the water molecule from a VNLFile.
Set-up the DFT method.
Use the NanoLanguage function calculateEigenstates() for calculating the molecular orbitals. In this case, only a subset is determined, since we only want to study the HOMO-LUMO states.
Store the HOMO-LUMO states in a VNLFile.
Run the script by issuing the command
atk water02-orb.py
from the command line.
A 3D rendering of the two states is shown below in Figure 3 and Figure 4.