Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Anders Blom

Pages: 1 ... 3 4 [5]
61
Dear all, I wanted to share with you a script that pretty much does the same thing as the Nanotube Grower in VNL, but in a much more versatile way.

Specifically, it contains easy-to-use functions to generate
  • Perfect nanotubes, as bulk
  • Carbon or boron-nitride tubes (or any A-B tube)
  • Ideal two-probe representations of nanotubes
  • Molecular nanotube segments for editing and insertion as central region in two-probes

I will make a more proper tutorial around it later, but I just wanted to let everyone get a chance to try to script.

Essentially, it's built up around a class called Nanotube which has a lot of useful methods like chiralVector(), radius(), etc. These will be documented separately later on.

Then, there are 4 high-level functions that use this class:

Code
def createNanotubeAsPAC (n,m,reps=1,elements=(Carbon,Carbon),bondlength=1.422*Ang)

def createNanotubeAsBulk (n,m,reps=1,elements=(Carbon,Carbon),bondlength=1.422*Ang)

def createNanotubeForCentralRegion (n,m,reps=1,elements=(Carbon,Carbon),bondlength=1.422*Ang)

def createPerfectNanotubeAsTwoProbe (n,m,elec_reps,sr_reps,elements=(Carbon,Carbon),bondlength=1.422*Ang)

The parameters are almost the same for all functions.

  • n and m are of course the nanotube indices, as in a (n,m)=(4,1) nanotube
  • reps is a repetition factor (along the tube), by default always 1
  • elements should be a tuple (or list) with 2 elements, like (Carbon,Carbon) or (Boron,Nitrogen)
  • bondlength is the carbon-carbon (or whatever) distance; must be given with unit

For the two-probe function, there are 2 repetition parameters instead of one: one for the electrodes (elec_reps) and one for the scattering region (sr_reps).

The functions all return a configuration. You can use it as it is, in the script, or store it in a VNL file for manipulations in VNL or later use. For instance, running

Code
from ATK.KohnSham import *
from Nanotube import *

# -----------------------------
# Tube parameters
# -----------------------------
aCC = 1.422*Ang
n = 12
m = 1
element1 = Boron
element2 = Nitrogen
# -----------------------------

nanotube = createNanotubeAsBulk (n,m,1,(element1,element2),aCC)

vnl_file=VNLFile("BN_nanotube.vnl")
vnl_file.addToSample(nanotube,"Boron-nitride (12,1) nanotube")

produces a file that we can visualize in VNL (attached as image) with a (12,1) B-N nanotube.

Dropping the VNL file on the NanoLanguage scripter, we can now immediately proceed to calculate its band structure, for instance, etc.

62
There is a new tutorial on the web site (http://quantumwise.com/publications/tutorials) on the topic of graphene nanoribbons that might be useful to some people ;)

63
Scripts, Tutorials and Applications / Voltage sweep (I-V curve)
« on: December 12, 2008, 22:20 »
One of the fundamentally important applications of ATK is to produce an I-V curve for a two-probe system. There is, however, no simple way to do it without quite a bit of scripting, as noted in another post on this Forum.

Here is a script/module ivcurve.py (attached) that takes care of that, at least in a quick-and-dirty way. The script is not a masterpiece of software design, and does no error checking etc, but ... it works :-)

The idea is to minimize the code the user has to write in his own script. The only required code to add is something along the lines of

Code
import ivcurve
   
voltages=[0.0,0.1,0.2,0.3]*Volt

ivcurve.runIVcurve (
    twoprobe_configuration,
    two_probe_method,
    runtime_parameters,
    voltages,
    vnl_filename='myfile.vnl', sample_name='mysample',
    current_k_point_sampling = (1,1),
    current_number_of_points = 100
  )

iv = ivcurve.extractIVcurveFromVNLFile('myfile.vnl','mysample')

ivcurve.plotIVCurve(iv,'iv.png')

Hopefully the above is relatively self-explanatory, but we'll review some details below. Note how the variable names above are chosen to match those used by Virtual NanoLab when it produces NanoLanguage code for a two-probe system. Therefore it is very easy to just include the code above at the end of a script produced by Virtual NanoLab to obtain an I-V curve.

For a more complete example, see the attached script lih2li_iv.py. It is based on the Li-H2-Li system from the manual, just because it's relatively quick to compute, so it's easy to test the I-V curve script using this system. To run the example you should have the geometry file lih2li.vnl too; for simplicity it is also attached.

The code above should be inserted into a script, after the usual part which defines the TwoProbeConfiguration and the TwoProbeMethod, and also the run-time parameters. Then, insert the code snipped above at the bottom of the script, replacing the execution statement (executeSelfConsistentCalculation()) if present. If you used your own variable names for the configuration, method and run-time parameters, adjust accordingly.

The code snippet above
  • defines the voltages for which to compute the current
  • runs a sweep with one calculation for each voltage bias
  • produces a plot, stored in "iv.png" of the I-V curve

Important notes:
  • The bias values should come in sequence and start with 0 V, since for each bias, the previous converged calculation is used to initialize the calculation.
  • An alternative way to set up the bias is to use numpy; to sweep from 0.0 to 1.0 V in steps of 0.1 V, use
Code
import numpy
voltages = numpy.arange(0.,1.01,0.1)*Volt
  • If the runtime parameters contain a checkpoint filename, the value of the bias will be added before the extension to create a unique NetCDF file for each bias. Thus, if you specified file.nc for a run with bias 0.0, 0.1 and 0.2 V, you will get three nc files file-0.0.nc, file-0.1.nc, and file-0.2.nc.
  • The runtime parameters argument is required, but you can give None if you don't want any NetCDF files.
  • All the computed values of the current will be stored in the VNL file specified, under the given sample name. You can inspect these values in Virtual NanoLab afterwards too.
  • Remember to provide the correct integration parameters for the current (k-point sampling, in particular!).
  • The plot can be customized to your liking. ATK actually has a built-in plotting engine (matplotlib), and you can produce very beautiful plots directly in NanoLanguage by using it. I'll make a separate post on that below!
  • You can change the extension of the image file from "png" to any other supported file format (such as "eps").
  • To print the I-V values, add this code to the end of the script:
Code
print 'Bias (V)\tCurrent (A)\n' + '-'*40
for i in iv:
    print i[0],'\t\t',i[1]

It's not unlikely that I overlooked some detail in this script, which causes it not to work in a particular situation... But please try it out, and together we can update it to make it a powerful NanoLanguage tool!

Edit: Updated version of script, which is safe for running in parallel.

64
The libstdc++.so.5/6 is installed on most systems, but not all.

To install a missing libstdc++ library, visit http://rpm.pbone.net/ and search for libstdc++ for your relevant distribution. Download and rpm --install it (as root).

Link the installed library from the VNL lib directory, like so:
Code
ln -s /usr/lib/libstdc++.so.6 libstdc++.so.6

Modify as needed for the location of the installed library, as found by (as root, in /)
Code
find -iname libstdc++*

65
One of the most common error messages when trying to start VNL/ATK is

Quote
'Not available', 'libg2c.so.0: cannot open shared object file: No such file or directory'

Quite obviously, this is because the library libg2c is missing. In many cases it is straightforward to install this library from the relevant package/software/update manager (look for libg2c, libf2c or g77), but one needs to pay some attention to which version to install, especially on 64-bit platforms, since VNL is a 32-bit application and therefore needs the corresponding 32-bit g2c library.

Some more detailed advice on specific platform will appear in further posts on this thread!

In general, a good resource for locating missing libraries to download is http://rpm.pbone.net/ (click "Search", then go to "Advanced Search" to be able to select distribution, otherwise you usually get way too many results in the search).

66
When launching VNL after installing it, you may experience the following kind of error message:

Quote
QT ('Not available', '/home/user/vnl-2008.10.0/lib/python2.4/site-packages/qtext.so: cannot restore segment prot after reloc: Permission denied')

This can also occur for ATK, in which case the error message will point to the file lib/python2.4/_PyATK.so.

The cause of this error are the new kernel security extensions from the SELinux project which are enabled in some newer Linux distributions, to allow finer-grained control over system security and shared library loading. The solution is to register the relevant libraries in the security module to allow them to be relocated in memory.

For VNL:
Code
chcon -t texrel_shlib_t lib/python2.4/site-packages/qtext.so

For ATK:
Code
chcon -t texrel_shlib_t lib/python2.4/_PyATK.so

Don't forget that there is a local ATK installation inside the VNL installation too, which needs to be registered separately.

67
It is quite common, on several different different Linux distributions, to encounter the following error message when you launch VNL after installing it:

Quote
Unable to resolve GL/GLX symbols - please check your GL library installation.

The solution is relatively simple.

Locate the library libGL.so. To do this, give the command (as root, in /)
Code
find -iname libGL.so*

Most likely this returns something like
Quote
./usr/lib64/libGL.so.1
./usr/lib64/libGL.so.1.2
./usr/lib/libGL.so.1
./usr/lib/libGL.so.1.2

What we need to do, is link VNL to the 32-bit libGL.so.1 library.

Go to the lib directory in the VNL installation, and give the command
Code
ln -s /usr/lib/libGL.so.1 libGL.so

In many cases, this will not be sufficient to resolve the problem entirely, however. When you again try to launch VNL, you may now instead get the error message
Quote
Unable to resolve Xmu symbols - please check your Xmu library installation.

The solution is similar. Locate the library libXmu.so by giving the command (as root, in /)
Code
find -iname libXmu.so*

Most likely this returns something like
Quote
./usr/lib64/libXmu.so.6.2.0
./usr/lib64/libXmu.so.6
./usr/lib/libXmu.so.6.2.0
./usr/lib/libXmu.so.6

What we need to do, is link VNL to the 32-bit libXmu.so.6 library.

Go to the lib directory in the VNL installation, and give the command (if a link/file libXmu.so already exists in this folder, remove it first)
Code
ln -s /usr/lib/libXmu.so.6 libXmu.so

68
Links to Resources and Publications / Papers from 2008
« on: December 11, 2008, 12:40 »
We are currently collecting article references from 2008 for inclusion on the QuantumWise web site. A few are already up - showing really exciting applications of ATK on topics which look not only like superb basic research, but even device-oriented in many cases:

  • Molecular rectification in porphyrin dimer
  • Spin-dependent electron transport in metallic carbon nanotubes
  • Current-induced forces in conducting and semiconducting carbon nanotubes
  • Ferrocene dimers for molecular wire applications
  • Designing nanogadgets by interconnecting carbon nanotubes with zinc layers
  • Electron transport through carbon nanotube in intramolecular heterojunctions with peptide linkages
  • Conductance of benzene clusters in the Pi-stack direction
  • Excess-silver-induced brigde formation in a silver sulfide atomic switch
  • Interface electronic structures of zinc oxide and metals

Check them out at http://quantumwise.com/publications/scientific-publications!

If you have published an article with ATK, please make it known in the Forum (we would love it if you also included the abstract in the post!) or send us an email (contact details on the web site).

69
A recent post (http://quantumwise.com/forum/index.php?topic=4.0) asked about importing XYZ files into VNL. Here is a way to export XYZ files from VNL! It is not possible as a direct function in the program, but it is relatively simple anyway, by using just a few lines of NanoLanguage code.

1. Open an editor (it can be the Script Editor in VNL) and make a NanoLanguage script that contains the following code:

Code
from ATK.KohnSham import *

def printXYZFile (configuration):
    elements = configuration.elements()
    coordinates = configuration.cartesianCoordinates()
    print len(elements)
    print 'From VNL'
    for elem,coords in zip(elements,coordinates):
        print elem.symbol(),
        for i in coords:
            print i.inUnitsOf(Angstrom),
        print

2. If you are using Windows, you first need to make a new directory called site-packages in the directory atk\lib in the VNL installation.

On Linux, this directory already exists, but is located in atk\lib\python2.4.

3. Save the file in the directory site-packages. Call it xyzexport.py for instance.

4. Now, assume we have a molecule in VNL, built e.g. in the Molecular Builder. Drag the molecule from the Molecular Builder to the Script Editor (make sure the editor is empty, in case you used it to create the script above). The corresponding NanoLanguage code will be shown in the editor. Now add these two lines at the bottom of the script:

Code
from xyzexport import printXYZFile
printXYZFile(molecule_configuration)

5. Drop the script on the Job Manager, and behold - an XYZ listing of the molecule will be printed in the Log Window. From there, you can just copy/paste the lines and save them as an XYZ file. (To copy lines from the Log Window, mark them and press Ctrl-C!)

In the future, whenever you want to export an XYZ file, you just follow steps 4 and 5 each time.

A ready file xyzexport.py is attached for convenience, you can copy it into the site-packages directory.

  • Note that this trick is generally useful. Any Python files that are placed in site-packages can be imported directly in NanoLanguage scripts that are executed in the Job Manager.
  • In order to make the same script available also in NanoLanguage scripts executed with ATK, you just copy the same file to the same directory in the ATK installation.

Pages: 1 ... 3 4 [5]