Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> a=.142; %Bond length in nanometers
- locations=[];
- %get user inputs
- prompt = 'What is the length of the sheet in the X direction in nanometers? X:';
- length=input(prompt);
- prompt = 'What is the length of the sheet in the Y direction in nanometers? Y:';
- height=input(prompt);
- %setting the starting heights for the 4 rows
- r1=0;
- r2=a/2;
- r3=3/2*a;
- r4=2*a;
- while(true)
- %Row 1
- if(r1>height)
- break;
- end
- x=0;
- %Adding points from this row to the matrix
- while(x<=length)
- str="C\t"+x+"\t"+r1+"\t"+0;
- locations=[locations;str];
- x=x+a*sqrt(3);
- end
- r1=r1+3*a;
- %Row 2
- if(r2>height)
- break;
- end
- x=a/2*sqrt(3);
- %Adding points from this row to the matrix
- while(x<=length)
- str="C\t"+x+"\t"+r2+"\t"+0;
- locations=[locations;str];
- x=x+a*sqrt(3);
- end
- r2=r2+3*a;
- %Row 3
- if(r3>height)
- break;
- end
- x=a/2*sqrt(3);
- %Adding points from this row to the matrix
- while(x<=length)
- str="C\t"+x+"\t"+r3+"\t"+0;
- locations=[locations;str];
- x=x+a*sqrt(3);
- end
- r3=r3+3*a;
- %Row 4
- if(r4>height)
- break;
- end
- x=0;
- %Adding points from this row to the matrix
- while(x<=length)
- str="C\t"+x+"\t"+r4+"\t"+0;
- locations=[locations;str];
- x=x+a*sqrt(3);
- end
- r4=r4+3*a;
- end
- %Finding number of carbon atoms
- eh=size(locations);
- numloc=eh(1);
- %Setting file to print out the points to
- fid=fopen('graphene.xyz','wt');
- %Beginning of the file formatting
- fprintf(fid,""+numloc+"\n\n");
- %Printing each point from matrix to xyz file named 'graphene.xyz' in the correct formatting
- for i=1:numloc
- fprintf(fid,locations(i)+"\n");
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement