Plotting a 2D crystal lattice from two primitive lattice vectors

Asked by Jennifer Garrison

Jennifer Garrison (view profile)

on 7 Sep 2019
Latest activity Answered by John D'Errico

John D'Errico (view profile)

on 8 Sep 2019
Accepted Answer by John D'Errico

John D'Errico (view profile)

I am trying generate a plot of a crystal lattice based on two prmitive lattice vectors:
v1= -0.5i + -sqrt(3)/2j
v2= 1i
where i and j are orhtogonal unit vecotors to represent the x and y directions.
I am not sure where to begin.

darova

darova (view profile)

on 8 Sep 2019
That is what you want?
Jennifer Garrison

Jennifer Garrison (view profile)

on 8 Sep 2019
It only needs to be 2D but yes. I basically need to define my own coordinate system that is not the standard cartesian one with those vectors and display the lattice points like you did.

John D'Errico (view profile)

Answer by John D'Errico

John D'Errico (view profile)

on 8 Sep 2019

First, you need to understand that MATLAB does not understand what you intend by this notation:
v1= -0.5i + -sqrt(3)/2j
Both i and j are sqrt(-1) in MATLAB. They are not distinct. Instead, just write them as vectors:
v1= [-0.5, -sqrt(3)/2];
v2= [1 , 0];
[x,y] = meshgrid(0:10,0:5);
xy = [x(:),y(:)];
T = [v1;v2];
xyt = xy*T;
xt = reshape(xyt(:,1),size(x));
yt = reshape(xyt(:,2),size(y));
plot(xt,yt,'ro-')
hold on
plot(xt',yt','r-')
axis equal
axis square

Bjorn Gustavsson (view profile)

Answer by Bjorn Gustavsson

Bjorn Gustavsson (view profile)

on 8 Sep 2019

If you do it stepwise it becomes "not too tricky":
e1 = [-0.5; -sqrt(3)/2]; % Your unit
e2 = [1; 0]; % vectors
[I1,I2] = meshgrid(-10:10,-8:8); % A 2-D set of points
r_crystal = [e1,e2]*[I1(:)';I2(:)']; % calculate r_c = n*e1 + m*e2 for all points
plot(r_crystal(1,:),r_crystal(2,:),'.')
You can dood.e with how big crystal you want or what shape, but this should give you something.
HTH

1 Comment

Jennifer Garrison

Jennifer Garrison (view profile)

on 8 Sep 2019
Thank you so much that's exactly what I needed!