1、产生碳纳米管坐标的 Matlab 程序以下是一个产生任意(m,n)碳管坐标的一个 Matlab 程序。只需把下面的程序 copy,存成creatCNT.m,即可用 Matlab 直接运行。比如在 Matlab 提示符下输入creatCNT(8,0)则产生(8,0)碳纳米管的坐标,输出文件为 nanotube.xyz 和 nanotube.pdb 格式。可以用其他的可视化软件打开。%function X TransVec NumAtom Diameter ChiralAngle=createCNT(n,m)%This function creates the coordinates of a (
2、n,m) nanotube, with nm%Usage:% X TransVec NumAtom Diameter ChiralAngle=createCNT(8,0);% X - coordinates of atoms in the nanotube unit cell% TransVec - Translational Vector T of the nanotube% NumAtom - Number of atoms in one unit cell of nanotube% Diamter - diameter of the nanotube% ChiralAngle - chi
3、ral angle of the nanotube% by bshan 2005%change order if n0)nq = nnq(1);%msg=sprintf(the symmetry vector is %d %d,np,nq);%disp(msg);% % r:|R| , c:|C_h|, t:|T|%lp = np*np + nq*nq + np*nq;r=a*sqrt(lp);c=a*l;t=sq3*c/ndr;% nn: the number of hexagon in the unit cell N% rs: radius of the tubeif(2*nn)nk)er
4、ror(parameter nk is too small!)endrs=c/(2.0d0*pi);%msg=sprintf(radius=%f ,t=%f,rs,t);%disp(msg);% q1: the chiral angle for C_h% q2: the chiral angle for R% q3: the chiral between C_h and Rq1=atan(sq3*m)/(2*n+m);q2=atan(sq3*nq)/(2*np+nq);q3=q1-q2;% q4: a period of an angle for the A atom% q5: the dif
5、ference of the angle between the A and B atomq4=2.0*pi/nn;q5=acc*cos(pi/6.0d0)-q1)/c*2.0*pi;% h1:% h2: Delta z between the A and B atomh1=abs(t)/abs(sin(q3);h2=acc*sin(pi/6.0)-q1);% The A atomii=0;for i=0:nn-1x1=0;y1=0;z1=0;k=floor(i*abs(r)/h1);x1=rs*cos(i*q4);y1=rs*sin(i*q4);z1=(i*abs(r)-k*h1)*sin(
6、q3);kk2=abs(floor(z1+0.0001)/t); % Check the A atom is in the unit cell 0=t-0.0001)z1=z1-t*kk2;elseif(z1=0)elseif(z20)z2 =z2+t*kk;elseendx(ii)=x2;y(ii)=y2;z(ii)=z2;endend%total number of atomsntotal=2*nn;for i=1:ntotalX(i,) =x(i) y(i) z(i);end TransVec=t;NumAtom=ntotal;Diameter=rs*2;ChiralAngle=atan
7、(sq3*n)/(2*m+n)/pi*180;%write coordinates to xyz file formatfid=fopen(nanotube.xyz,w);fprintf(fid,%dn,size(X,1);fprintf(fid,created by GUI_TB programn);for i=1:ntotalfprintf(fid,C %f %f %f n,X(i,1),X(i,2),X(i,3);endfclose(fid);%write coordinates to pdb file format(for visualization using rasmol)fid=fopen(nanotube.pdb,w);for i=1:ntotalfprintf(fid,ATOM %6d C ADE 1 %8.3f%8.3f%8.3f 1. 0.n,i,X(i,1),X(i,2),X(i,3);endfprintf(fid,TERn);fclose(fid);%