首页 产生碳纳米管坐标的Matlab程序

产生碳纳米管坐标的Matlab程序

举报
开通vip

产生碳纳米管坐标的Matlab程序产生碳纳米管坐标的Matlab程序以下是一个产生任意(m,n)碳管坐标的一个Matlab程序。只需把下面的程序copy,存成creatCNT.m,即可用Matlab直接运行。比如在Matlab提示符下输入>>creatCNT(8,0)则产生(8,0)碳纳米管的坐标,输出文件为nanotube.xyz和nanotube.pdb格式。可以用其他的可视化软件打开。%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function[XTransVecNumAtomDiameterChi...

产生碳纳米管坐标的Matlab程序
产生碳纳米管坐标的Matlab程序以下是一个产生任意(m,n)碳管坐标的一个Matlab程序。只需把下面的程序copy,存成creatCNT.m,即可用Matlab直接运行。比如在Matlab提示符下输入>>creatCNT(8,0)则产生(8,0)碳纳米管的坐标,输出文件为nanotube.xyz和nanotube.pdb格式。可以用其他的可视化软件打开。%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function[XTransVecNumAtomDiameterChiralAngle]=createCNT(n,m)%Thisfunctioncreatesthecoordinatesofa(n,m)nanotube,withn>m%Usage:%[XTransVecNumAtomDiameterChiralAngle]=createCNT(8,0);%X--coordinatesofatomsinthenanotubeunitcell%TransVec--TranslationalVectorTofthenanotube%NumAtom--Numberofatomsinoneunitcellofnanotube%Diamter--diameterofthenanotube%ChiralAngle--chiralangleofthenanotube%bybshan2005%changeorderifn0)&&(j1=2)error('morethan1pairp,qstrange!!')end%symmetryvector(np,nq)np=nnp(1);nq=nnq(1);%msg=sprintf('thesymmetryvectoris%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:thenumberofhexagonintheunitcellN%rs:radiusofthetubeif((2*nn)>nk)error('parameternkistoosmall!')endrs=c/(2.0d0*pi);%msg=sprintf('radius=%f,t=%f',rs,t);%disp(msg);%q1:thechiralangleforC_h%q2:thechiralangleforR%q3:thechiralbetweenC_handRq1=atan((sq3*m)/(2*n+m));q2=atan((sq3*nq)/(2*np+nq));q3=q1-q2;%q4:aperiodofananglefortheAatom%q5:thedifferenceoftheanglebetweentheAandBatomq4=2.0*pi/nn;q5=acc*cos((pi/6.0d0)-q1)/c*2.0*pi;%h1:%h2:DeltazbetweentheAandBatomh1=abs(t)/abs(sin(q3));h2=acc*sin((pi/6.0)-q1);%TheAatomii=0;fori=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(q3);kk2=abs(floor((z1+0.0001)/t));%ChecktheAatomisintheunitcell0<=z1=t-0.0001)z1=z1-t*kk2;elseif(z1<0)z1=z1+t*kk2;elseendii=ii+1;x(ii)=x1;y(ii)=y1;z(ii)=z1;%TheBatomz3=(i*abs(r)-k*h1)*sin(q3)-h2;ii=ii+1;%ChecktheBatomisintheunitcell0<=z3=0)&&(z3=t-0.0001)z2=z2-t*kk;elseif(z2<0)z2=z2+t*kk;elseendx(ii)=x2;y(ii)=y2;z(ii)=z2;endend%totalnumberofatomsntotal=2*nn;fori=1:ntotalX(i,)=[x(i)y(i)z(i)];endTransVec=t;NumAtom=ntotal;Diameter=rs*2;ChiralAngle=atan((sq3*n)/(2*m+n))/pi*180;%writecoordinatestoxyzfileformatfid=fopen('nanotube.xyz','w');fprintf(fid,'%d\n',size(X,1));fprintf(fid,'createdbyGUI_TBprogram\n');fori=1:ntotalfprintf(fid,'C%f%f%f\n',X(i,1),X(i,2),X(i,3));endfclose(fid);%writecoordinatestopdbfileformat(forvisualizationusingrasmol)fid=fopen('nanotube.pdb','w');fori=1:ntotalfprintf(fid,'ATOM%6dCADE1%8.3f%8.3f%8.3f1.0.\n',i,X(i,1),X(i,2),X(i,3));endfprintf(fid,'TER\n');fclose(fid);o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/o/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%o/o/o/o/o/o/%%%%%%
本文档为【产生碳纳米管坐标的Matlab程序】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
星空万里
暂无简介~
格式:doc
大小:12KB
软件:Word
页数:7
分类:高中语文
上传时间:2022-07-27
浏览量:0