BuildCstruct is a python script used to build the following allotropes graphite structures:

  1. square/rectangular sheet of HOPG graphite;
  2. armchair carbon nanotube;1
  3. zigzag carbon nanotubes.2

Those structure can also be build as periodic (TINKER definition), so that infinite surface or CNT can be modeled. Structures generated with the last version (1.1) of BuildCstruct can be saved in different formats:

  1. TINKER XYZ (slow, due to the determination of the connectivity)
  2. XYZ
  3. Gromacs GRO

For the gromacs format, the cell is cubic and the default length of the vectors is 10nm. If periodicity has been used, the proper lengths are used.


BuildCstruct requires python and python-numpy installed


To run buildCstruct simply type:

buildCstruct [options] outfile

The available options are:


show program's version number and exit.

-h, —help

show this help message and exit.

-c, —credits

display credits.

-s, —structure

specify the kind of structure to build. Valid structures are: armcnt, zigzagcnt and hopg.

-p, —periodicity

build a periodic structure for TINKER.

-g, —geometry

specify the geometry of the structure. For CNTs, use -g index_n cnt_length while for hopg use -g size_x size_y (see examples below). Size_x, size_y and cnt_length are in Å.


save structure in XYZ format (version 1.1 only).


save structure in gromacs GRO format (version 1.1 only).


is the name of the file where to save the structure.


Build a non-periodic, armchair, CNT having (n,m)=(10,10) and length 30Å


buildCstruct -s armcnt -g 10 30

This will build a non-periodic, armchair CNT having (n,m)=(10,10) and length 30Å. The program print out some structural information that are worthy to be saved in a file for late. Below the output for this particular CNT:

armchair CNT: n=  10  l (ang)=  30.7439018343
periodicity (if apply) (ang)=  31.9736579077
diameter (ang):  13.5600011514
Atoms:  560
saving structure...

Since we built a non-periodic CNT, the real length is of 30.7439Å. The output file is in TINKER format (Hs are at the end of the file), but without assignment of the atom types:
   1  C      6.780001    0.000000    0.000000     0    20    21   521
   2  C      6.193839    0.000000    2.757675     0     3    22   522
   3  C      5.485136    0.000000    3.985184     0     2    23   523
   4  C      3.390000    0.000000    5.871653     0     5    24   524
   5  C      2.095135    0.000000    6.448164     0     4    25   525
   6  C     -0.708703    0.000000    6.742859     0     7    26   526
   7  C     -2.095135    0.000000    6.448164     0     6    27   527
   8  C     -4.536706    0.000000    5.038522     0     9    28   528
   9  C     -5.485136    0.000000    3.985184     0     8    29   529


551  H     -7.287859  -31.687870   -0.708703     0   511
552  H     -5.903164  -31.687870   -2.095135     0   512
553  H     -5.583522  -31.687870   -4.536706     0   513
554  H     -3.440184  -31.687870   -5.485136     0   514
555  H     -1.954641  -31.687870   -6.631841     0   515
556  H      0.545000  -31.687870   -6.780001     0   516
557  H      2.212675  -31.687870   -6.193839     0   517
558  H      4.530184  -31.687870   -5.485136     0   518
559  H      5.326653  -31.687870   -3.390000     0   519
560  H      6.993164  -31.687870   -2.095135     0   520

Atom types can be fixed using the script fixtnkatypes.
The main axis of the CNT is along the cartesian Y-axis and the result is shown in the image below.


Please note that the weird orientation of the Hydrogen atoms is due to the way I build the CNT. You just need to cleanup the geometry by doing a short minimization (steep or cg in Gromacs, minimize in Tinker).

Build a periodic, zigzag, CNT having (n,m)=(10,0) and length 30Å

All the considerations made for the previous example are valid. This time the flag -p is used to build a periodic (infinite) CNT:

buildCstruct -s zigzagcnt -g 10 30 -p

The structural informations are:

zigzag CNT: n=  10  l (ang)=  32.66
periodicity (if apply) (ang)=  34.08
diameter (ang):  7.82887031499
Atoms:  320
saving structure...

Since the nanotube is periodic, this time the length to use to set the size of the periodic box in TINKER (b-axis) is 34.08Å. The result is shown below.

Please note that since the CNT is infinite, no Hydrogen atoms are present in the structure.

Multiwalls CNTs

BuildCstruct can build only single wall nanotubes (SWNT). To create a multiwall CNT, you have to build individually the SWNT and then merge them together using, for example, the TINKER utility xyzedit. This is possible since all the SWNT share the same position and orientation for their main axis. The images below show a periodic, armchair multiwall CNT obtained by merging together a (10,10), a (15,15) and a (20,20) SWNT.


Front view. Three SWNT with index (10,10) (red), (15,15) (yellow) and (20,20) (blue) are used to build a multiwall CNT.


Side view of the multiwall CNT.

Graphite slab

Slabs of HOPG graphite can be built with buildCstruct:

buildCstruct -s hopg -g 30 30 -p

The command above will generate a periodic slab of graphite of about 30Åx30Å in size:
HOPG graphite: a=  32.66  b=  30.7439018343
Periodic (if apply) (ang): a=  34.08  b=  31.9736579077
Atoms:  416
saving structure...

The result is shown in the picture below:


Periodic slab of HOPG graphite.


Do you like this program? Do you have suggestions? Drop me a mail at or leave a comment.


You are free to use, modify and redistribute buildCstruct as far as you keep it free as in beer.
As free(as in beer)ware software, buildCstruct comes with _ABSOLUTE_ _NO_ (as in NOTHING, NADA, NICTHS, NIENTE, RIEN) WARRANTY. The author is _NOT_ responsible if this software will erase your hard disks, empty your bank account, stole your car, seduce your wife, shave your dog or make any kind of mess and damages, including loss of data or worst. By using buildCstruct, you _ACCEPT_ these terms.



v 1.1 - March 2010:

  • improved connectivity search algorithm
  • added support XYZ format
  • added support gromacs GRO format

v 1.0 - April 2009:

  • first release of buildCstruct


BuildCstruct (1.1) (1.0)

Rate this page:

rating: 0+x


Add a New Comment
or Sign in as Wikidot user
(will not be published)
- +
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License