QuantumATK Forum

QuantumATK => Scripts, Tutorials and Applications => Topic started by: Anders Blom on January 12, 2009, 22:00

Title: Script for creating nanotubes
Post by: Anders Blom on January 12, 2009, 22:00
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

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.


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.
Title: Re: Script for creating nanotubes
Post by: Anders Blom on January 12, 2009, 22:03
There is none thing one should (always) observe with these 1D systems, and that is of course the transverse unit cell. The script tries to make the unit cell large enough to avoid electrostatic interactions with neighboring cells in the XY plane, but for serious work this should be checked carefully.

Fortunately it is nowadays easy to open a bulk sample in the instrument Bulk Builder in VNL and quickly adjust the unit cell vectors.

There is a relatively simple way to check if the unit cell is large enough in the XY directions. If it is too small, the residual electrostatic interactions will split the band structure in the degeneracy points at Gamma and Z = (0,0,0.5). Other parameters, like mesh cut-off or basis set size etc do not break degeneracies in this way.
Title: Re: Script for creating nanotubes
Post by: Anders Blom on January 12, 2009, 22:28
For example, let us compute the band structure of a (4,4) B-N nanotube. Now, remember that a (4,4) carbon nanotube is metallic; it turns out, the B-N is not.

Step 1: Run this script to create the geometry

Code
from ATK.KohnSham import *
from Nanotube import *

aCC = 1.45*Ang    # literature values vary from 1.43 to 1.45 Ang
n = 4
m = 4
element1 = Boron
element2 = Nitrogen

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

vnl_file=VNLFile("bn_44.vnl")
vnl_file.addToSample(nanotube,"B-N (4,4) nanotube")

Step 2: Drop the created file on the NanoLanguage Scripter in VNL and modify the following parameters:


Step 3: Drop the script from the NanoLanguage Scripter to the Job Manager to run it! It should take 5-10 minutes depending on your hardware.

Step 4: When the calculation finishes, drop the VNL file with the band structure on the Result Browser. Zooming in a bit, you should be able to indeed see the band gap for the (4,4) B-N nanotube as in the attached plot!
Title: Re: Script for creating nanotubes
Post by: serhan on January 13, 2009, 04:57
Dear Dr. Blom,

Thanks again, I'll try the script as soon as possible  ::)

Serhan
Title: Re: Script for creating nanotubes
Post by: Anders Blom on February 9, 2009, 13:46
A bug (for two-probe systems) was found and corrected in the script Nanotube.py in the initial post. The current version attached should be ok now.
Title: Re: Script for creating nanotubes
Post by: carbn9 on March 11, 2009, 12:30
Dear all, When I tried to generate a (3,3) CNT as TwoProbe, the script gave the following error. How can I correct it? Regards, Maresh

Code
Traceback (most recent call last):
  File "c:/docume~1/master1/locals~1/temp/tmplp9jqf.nl", line 254, in ?
    nanotube = createPerfectNanotubeAsTwoProbe (n,m,1,(element1,element2),aCC)
  File "c:/docume~1/master1/locals~1/temp/tmplp9jqf.nl", line 232, in createPerfectNanotubeAsTwoProbe
    electrode = createNanotubeAsPAC (n,m,elec_reps,elements,bondlength)
  File "c:/docume~1/master1/locals~1/temp/tmplp9jqf.nl", line 187, in createNanotubeAsPAC
    elements = myTube.siteCount()*[elements[0],]+myTube.siteCount()*[elements[1],]
AttributeError: PhysicalQuantity instance has no attribute '__getitem__'
Terminated Abnormally
Title: Re: Script for creating nanotubes
Post by: Anders Blom on March 11, 2009, 13:24
Your statement that calls the function has a mistake, you have only one repetition argument.

The correct syntax for a (3,3) carbon nanotube should be

Code
nanotube = createPerfectNanotubeAsTwoProbe(3,3,1,1,(Carbon,Carbon),1.422*Ang)

or shorter (relying on defaults)

Code
nanotube = createPerfectNanotubeAsTwoProbe(3,3,1,1)

With your variable definitions, you could write

Code
nanotube = createPerfectNanotubeAsTwoProbe (n,m,1,1,(element1,element2),aCC)

If you have further questions, please post your statement that generates the error.

Note 1: A (3,3) nanotube is on the border of being realistic...

Note 2: A single electrode / central region repetition may be too small... I would use 2 as minimum (for the electrode) to be on the safe side, and 3-4 at least for the central region. Otherwise your results may be wrong, or the calculation might not converge.
Title: Re: Script for creating nanotubes
Post by: carbn9 on March 11, 2009, 23:30
Thank tou for your answers Sir.
Title: Re: Script for creating nanotubes
Post by: privador on March 13, 2009, 17:00
I tried to work this script,but i failed.
As i see,there are 2 scripts
1-st one is Nanotube.py what i downloaded here

2-nd one is script to define nanotube parametres
Quote
from ATK.KohnSham import *
from Nanotube import *

aCC = 1.45*Ang    # literature values vary from 1.43 to 1.45 Ang
n = 4
m = 4
element1 = Boron
element2 = Nitrogen

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

vnl_file=VNLFile("bn_44.vnl")
vnl_file.addToSample(nanotube,"B-N (4,4) nanotube")

My question is where to save Nanotube.py file?Because he didnt find that nanotube.py(classes) when i tried to run second script
what is  file "bn_44.vnl"?Should it be end with file extension .py?
Title: Re: Script for creating nanotubes
Post by: Anders Blom on March 13, 2009, 20:27
The Nanotube.py script should be in the same directory as your main script, if you are running the whole thing using ATK directly on the command line, that is.

If you, as many do, run it by dropping the script on the Job Manager or directly to the Nanoscope, you need to take care of the path a little bit. There are basically two options; this is also discussed in another post (http://), but there is a slight difference because that case primarily dealed with running a calculation while here we are generating a geometry.

So, the options are:

A) Create a special directory where you keep all "utility" scripts like Nanotube.py. Let's say this directory is c:/users/me/nlfiles (always use forward slashes / in Python, never backslash \ even on Windows).

Then, in each script that needs to access such utility files, add these two lines at the top:

Code
import sys
sys.path.append('c:/users/me/nlfiles')

B) A simpler way is to use a special directory called site-packages in the ATK installation inside VNL. Create this directory and place any script you want to be able to import there. The exact location of this directory differs a bit in Windows and Linux.


Here %vnl% symbolically denotes the VNL installation directory.

The slight disadvantage of alternative B) is that you must remember to move your utility scripts along when you upgrade to a new version of VNL. Also, the scripts will only work inside VNL, not when run with a stand-alone installation of ATK, unless you create a mirror copy of the directory in the ATK installation tree too (on Linux, this can quite conveniently be done with a softlink!).
Title: Re: Script for creating nanotubes
Post by: Anders Blom on March 13, 2009, 20:35
You had one more question: About the "bn_44.vnl" file, this is the file where the geometry will be saved (and so it should indeed have extension .vnl). If you instead drop the geometry directly on the Nanoscope or NanoLanguage Scripter, and follow the advise above to make it work :) , then you had better remove the two last lines from your main script. Or create the VNL file with a specific path, where you also store the results from the calculation, to overcome the small issue discussed here (http://quantumwise.com/forum/index.php?topic=135.msg683#msg683).
Title: Re: Script for creating nanotubes
Post by: serhan on April 16, 2009, 05:28
Hello,

When creating nanotube as two-probe, we do not need screening layers since electrodes are the same type with scattering region. Am I right?

Cheers,
Serhan
Title: Re: Script for creating nanotubes
Post by: Nordland on April 16, 2009, 07:33
It depends - if you are ever going to apply bias or perform pertubation of the system of kind, you will need some screening layers, however if it is zero bias transmission spectrum, then there is no need for additional screening.
Title: Re: Script for creating nanotubes
Post by: Anders Blom on April 16, 2009, 08:56
Well, screening layers are always necessary, if by that we just mean "layers in the central region". Perhaps what you meant, Serhan, is that if the system is perfect anyway, we can just skip the central region and attach the electrodes back-to-back. Geometrically that would be equivalent, and it would seem you could save a lot of time in the calculation this way (fewer atoms!).

However, the algorithms used in ATK are not designed for perfect systems, which are trivial; we don't even need to do the two-probe calculation, we can just inspect the band structure to figure out the transmission spectrum. Therefore, in the general formalism, we always need a central region. In fact, there is a crucial requirement that there is no basis set overlap between atoms in the left and right electrodes, or else the algorithm breaks down.
Title: Re: Script for creating nanotubes
Post by: carbn9 on April 16, 2009, 15:47
Thanks Anders, but how can we insert screening layers in perfect nanotube two probe geometry of the code of this thread?

Cheers,
Serhan
Title: Re: Script for creating nanotubes
Post by: Anders Blom on April 16, 2009, 16:20
There is no real difference between screening layers and central region layers in this case, so just use the repetition factor the central region.
Title: Re: Script for creating nanotubes
Post by: serhan on April 16, 2009, 17:34
Thanks, I've posted from my friends's computer thus the user name was different on the above post...:)

Thanks again.

Cheers,
Serhan
Title: Re: Script for creating nanotubes
Post by: serhan on May 4, 2009, 17:55
Hi,

I've made a (6,6) CNT with the script provided in this thread. I've plotted its voltage drop along z-direction. Attached is this Figure. However, I'm surprised that a voltage drop also occurs in the electrodes (the first and last 0.9nm correspond to the electrodes). Is this true? Does ATK take the voltage drop in the electrodes into account? Or am I missing something?

Cheers,
Serhan
Title: Re: Script for creating nanotubes
Post by: Nordland on May 4, 2009, 18:18
Well it is not into the electrode entirely. When ATK performs a twoprobe calculation, it does on a system formed by adding an electrode repetitions ( I call this the padding layers ) to each side of the scattering region. All real space properties are calculated in this region, and hence the voltage drop will be allowed to vary in the padding layers. So it is not in the electrode, but in the extra repetitions of the electrode.
Title: Re: Script for creating nanotubes
Post by: Anders Blom on May 5, 2009, 03:42
Although, from the user's perspective of how the geometry is defined, it is the electrode ;)

For definiteness, the system which ATK actually performs the calculation on, looks like

L-LP-C-RP-R           (p for padding)

where C=central region and L/LP and R/RP are the left and right electrode geometries. During the self-consistent two-probe calculation, the real space quantities in L and R are fixed to their bulk values, while those in LP and RP are allowed to vary.

So, again, from the perspective of how the system is defined (names of variables etc), the system is L-C-R, and the real space density and effective potential vary freely across this region.
Title: Re: Script for creating nanotubes
Post by: serhan on May 5, 2009, 05:26
Thanks again  :)

OK, the voltage drops in the padding layers (as you've shown it as LP ans RP). However, the drop also occurs in L and P, is it right?

Cheers,
Serhan
Title: Re: Script for creating nanotubes
Post by: Nordland on May 5, 2009, 07:32
The drops does not occour in L and R.
Title: Re: Script for creating nanotubes
Post by: Anders Blom on May 5, 2009, 14:37
I guess you meant R, not P.

Just to be clear: padding is NOT the same thing as screening. The screening layers are part of C.

Again, from the perspective of how you set up the geometry, you specify to the program a "left electrode", a "right electrode", and a "central region" geometry. These are L, R, and C, and they are stitched together as L-C-R. The voltage drop etc occurs over this region. The whole padding idea is really just related to how the code handles things internally.
Title: Re: Script for creating nanotubes
Post by: serhan on May 5, 2009, 20:44
Thank you very much,

Cheers,
Serhan