Author Topic: Script for creating nanotubes  (Read 42833 times)

0 Members and 1 Guest are viewing this topic.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Script for creating nanotubes
« 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
  • 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.
« Last Edit: February 9, 2009, 13:47 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: Script for creating nanotubes
« Reply #1 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.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: Script for creating nanotubes
« Reply #2 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:
  • Brillouin zone integration parameters: (1,1,50) is a reasonable k-point sampling
  • Specify a VNL file name where to store the band structure (for instance, the same VNL file as the geometry is in). Remember to enter the full absolute file name, with path!
  • Add Energy Bands to the analysis options. Delete all k-points, by right-clicking them, except the two first. Thus, we will obtain the band structure from Gamma to Z=(0,0,0.5).
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!

Offline serhan

  • Heavy QuantumATK user
  • ***
  • Posts: 98
  • Reputation: 1
    • View Profile
Re: Script for creating nanotubes
« Reply #3 on: January 13, 2009, 04:57 »
Dear Dr. Blom,

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

Serhan

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: Script for creating nanotubes
« Reply #4 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.
« Last Edit: February 21, 2009, 18:15 by Anders Blom »

Offline carbn9

  • Regular QuantumATK user
  • **
  • Posts: 24
  • Reputation: 0
    • View Profile
Re: Script for creating nanotubes
« Reply #5 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

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: Script for creating nanotubes
« Reply #6 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.
« Last Edit: March 11, 2009, 13:28 by Anders Blom »

Offline carbn9

  • Regular QuantumATK user
  • **
  • Posts: 24
  • Reputation: 0
    • View Profile
Re: Script for creating nanotubes
« Reply #7 on: March 11, 2009, 23:30 »
Thank tou for your answers Sir.

Offline privador

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Reputation: 0
    • View Profile
Re: Script for creating nanotubes
« Reply #8 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?
« Last Edit: March 13, 2009, 17:03 by privador »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: Script for creating nanotubes
« Reply #9 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, 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.
  • Windows: Create the directory site-packages in %vnl%/atk/lib
  • Linux: Create the directory site-packages in %vnl%/atk/lib/python2.4
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!).

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: Script for creating nanotubes
« Reply #10 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.
« Last Edit: March 13, 2009, 20:38 by Anders Blom »

Offline serhan

  • Heavy QuantumATK user
  • ***
  • Posts: 98
  • Reputation: 1
    • View Profile
Re: Script for creating nanotubes
« Reply #11 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

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Re: Script for creating nanotubes
« Reply #12 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.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: Script for creating nanotubes
« Reply #13 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.

Offline carbn9

  • Regular QuantumATK user
  • **
  • Posts: 24
  • Reputation: 0
    • View Profile
Re: Script for creating nanotubes
« Reply #14 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