How to Calculate Nearest Neighbours in Graphene?

  • Thread starter Thread starter barana
  • Start date Start date
  • Tags Tags
    Graphene
Click For Summary
SUMMARY

This discussion focuses on programming the calculation of nearest neighbours in armchair graphene nanoribbons using MATLAB. The provided code initializes a lattice structure, computes nearest neighbour indices, and calculates the energy spectrum using eigenvalue decomposition. Key suggestions include adding comments for clarity, simplifying the code by removing redundant commands, organizing the code into functions, and utilizing vectorized operations for efficiency. These enhancements will improve code readability and adaptability for various graphene structures.

PREREQUISITES
  • MATLAB programming skills
  • Understanding of lattice structures in materials science
  • Familiarity with eigenvalue problems in quantum mechanics
  • Knowledge of vectorized operations in MATLAB
NEXT STEPS
  • Learn about MATLAB function creation for modular coding
  • Explore vectorization techniques in MATLAB for performance optimization
  • Study eigenvalue problems and their applications in solid-state physics
  • Research different types of graphene structures and their properties
USEFUL FOR

Researchers, physicists, and materials scientists working on computational modeling of graphene and other two-dimensional materials, as well as MATLAB programmers seeking to enhance their coding practices.

barana
Messages
17
Reaction score
0
Can help me for the write program for calculating nearest neighbours in graphene?
Program the nearest neighbours for armchair graphene nanoribbon same as the follow:
close all
clear all
clc
L = 2;
H = 4;

lineatoms = 2 * H + 1;

for i = 1:lineatoms

if mod(i,2)==1
x(1,i) = .71;
else
x(1,i) = 0;
end

y(1,i) = (i-1)*1.23;
end

index = 1;

for i = lineatoms +1 : 2*lineatoms

if mod(i,2)==0
x(1,i) = 2.13;
else
x(1,i)= 2.84;
end

y(1,i) = y(1,i -index);

index = index+2; end
for i = 2:L
for j = 1: 2*lineatoms
x(i,j) = x(1,j) + 4.26*(i-1);
y(i,j) = y(1,j);
end
end

figure;
for i = 1:L
plot (x(i,:),y(i,:), 'bo','MarkerFaceColor','b');
hold on;
end
axis equal;

z = size(x)
lastatm = z(2)
atomnums = 1: lastatm;
corneratms = [1 lastatm/2 lastatm/2+1 lastatm];
nn(1,1) = 1+1;
nn(1,2) = lastatm;
nn(lastatm,1) = 1;
nn(lastatm,2) = lastatm-1; nn(corneratms(2),1) = corneratms(2)-1;
nn(corneratms(2),2) = corneratms(2)+1;
nn(corneratms(3),1) = corneratms(3)-1;
nn(corneratms(3),2) = corneratms(3)+1;

X = x(1,:); Y = y(1,:);
batm = lastatm-3;

for i = 2:lastatm/2 -1

nn(i,1) = i-1;
nn(i,2) = i+1;
nn(i,3) = i+batm;

nnf(i,1) = i-1;
nnf(i,2) = i+1;
batm = batm -2;
end

batm = 3;
for i = lastatm/2+2:lastatm-1

nn(i,1) = i-batm;
nn(i,2) = i-1;
nn(i,3) = i+1;
batm = batm + 2;
end
a = 2.46;
e2p =0; t=-2.550; s=.2;
kx = -1*pi/a:.01:1*pi/a;
ky = -.05*pi/a:.01:.05*pi/a;

a1 = 0.71; a2 = 1.23; a3 = 1.42;

for m = 1: length(kx)
for n = 1:length(ky)

KX = kx(m);
KY = ky(n);

for i = 1:2*lineatoms
for j = 1:3

nene = nn(i,j); % three nearest neighbours

if nene ~= 0
num = (Y(nene)-Y(i))
denom = (X(nene)-X(i));

if (denom > 0 && num > 0)
H(i,nene) = exp(1i*KX*a1 + 1i*KY*a2);
S(i,nene) = s * H(i,nene);
elseif (denom < 0 && num < 0)
H(i,nene) = exp(-1i*KX*a1 - 1i*KY*a2);
S(i,nene) = s * H(i,nene);
elseif (denom < 0 && num > 0)
H(i,nene) = exp(-1i*KX*a1 + 1i*KY*a2);
S(i,nene) = s * H(i,nene);
elseif (denom > 0 && num < 0)
H(i,nene) = exp(1i*KX*a1 - 1i*KY*a2);
S(i,nene) = s * H(i,nene);
elseif (denom > 0 && num == 0 && denom ==1.42)
H(i,nene) = exp(1i*KX*a3);
S(i,nene) = s * H(i,nene);
elseif (denom > 0 && num == 0 && denom == 2*1.42)
H(i,nene) = exp(-1i*KX*a3);
S(i,nene) = s * H(i,nene);
elseif (denom < 0 && num == 0 && denom == -1.42)
H(i,nene) = exp(-1i*KX*a3);
S(i,nene) = s * H(i,nene);
elseif (denom < 0 && num == 0 && denom == -2*1.42)
H(i,nene) = exp(1i*KX*a3);
S(i,nene) = s * H(i,nene);
end

end
end
H(i,i) = 0;
S(i,i) = 1;
end

ee = eig(t*H,S); % Eigen value calculation
% ee = eig( H ); for k = 1:2*lineatoms
E(m,n,k) = ee(k);
end

end
end

figure;
for k = 1 :2*lineatoms
plot(kx, E(:,:,k));
hold on;
end
 
Technology news on Phys.org

xlabel('kx');
ylabel('Energy');
title('Energy Spectrum for Armchair Graphene Nanoribbon');
hold off;
Thank you for reaching out for assistance with calculating nearest neighbours in graphene. I have taken a look at your code and made some suggestions for improvements.

Firstly, it is important to always include comments in your code to explain what each section or line of code is doing. This will make it easier for others to understand and modify your code in the future.

Next, I noticed that you have used both "clear all" and "clc" in your code. While "clear all" clears all variables from the workspace, "clc" simply clears the command window. It is not necessary to use both, so I would suggest using "clear all" at the beginning of your code to avoid confusion.

In terms of the logic of your code, it looks like you are creating a lattice of atoms with x and y coordinates, and then using the nearest neighbour indices to calculate the energy spectrum. This is a good approach, but I would suggest breaking your code into smaller, more manageable functions. For example, you could have a function for creating the lattice, another for calculating the nearest neighbours, and another for calculating the energy spectrum. This will make your code more organized and easier to debug.

Additionally, I noticed that your code is specific to armchair graphene nanoribbons. It would be beneficial to make your code more general so that it can be easily applied to other types of graphene structures as well.

Finally, I would recommend using vectorized operations wherever possible, as this can greatly improve the efficiency and speed of your code.

I hope these suggestions are helpful in improving your code for calculating nearest neighbours in graphene. Good luck with your research!
 

Similar threads

Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
2
Views
2K
Replies
2
Views
1K
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
693
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 10 ·
Replies
10
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K