How to generate a fcc crystal matrice?

24 次查看(过去 30 天)
I would like to generate a fcc crystal lattice with its atomic positions in a matrice of 3 columns. I tried to expand the crystal by translating the unit cell, but I struggle with the translation vectors and loops. Can someone suggest me a fast method? Thanks!
  4 个评论
John D'Errico
John D'Errico 2017-7-10
Then my answer provides the desired coordinates.
Chenyue Xu
Chenyue Xu 2017-7-10
Yes, it's perfect if you can help me on the coordinates! Thanks

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2017-7-10
编辑:John D'Errico 2017-7-10
Easy enough if all you need are the FCC nodes in an unstructured sequence.
fccbase = [dec2bin(0:7) - '0';.5 .5 0;.5 .5 1;.5 0 .5;.5 1 .5;0 .5 .5;1 .5 .5];
[latx,laty,latz] = ndgrid(0:2,0:2,0:2);
latxyz = [latx(:),laty(:),latz(:)];
latxyz = repmat([latx(:),laty(:),latz(:)],14,1);
latxyz = latxyz + reshape(permute(repmat(fccbase,[1,1,prod(size(latx))]),[3 1 2]),[],3);
latxyz = unique(latxyz,'rows');
plot3(latxyz(:,1),latxyz(:,2),latxyz(:,3),'o')
The basic idea should be clear. I've taken advantage of one nice fact, that unique will be exactly able to locate numbers that are integers, or integers plus 0.5. All of those numbers are exactly representable in double precision. So there is no need even to use a tolerance.

更多回答(2 个)

Jose Martinez
Jose Martinez 2019-5-26
function FCCLattice = FCCMake(a,V)
% "a" is the Lattice Parameter:
a = a;
%Set the Volume of the cube in variable V:
V = V; %This means your cube will be of dimensions VxVxV.
%%%----Code-----%%%
%Create an array that stores all your coordinates:
%First you will need to establish the number of atoms
%that the array will have, we will do this by establishing
%the known number of atoms, in this case FCC 4xVxVxV.
N = V*V*V*4;
%This array will gives is a matrix of Nx3, that will store data.
FCCLattice = zeros(N,3);
%Create the vectors for the atoms position in the FCC Lattice:
FCCatoms = [0 0 0;(a/2) (a/2) 0;(a/2) 0 (a/2);0 (a/2) (a/2)];
%Set a variable to change rows in the array storing the coordinates:
n = 0;
%Create 3 For loops to mix the positions between xyz
for x = 0:V-1
for y = 0:V-1
for z = 0:V-1
for i = 1:4
%Create a vector that translate your location in the
%coordinate system into the position in the crystal:
coordinatestranslation = a*[x y z];
%Add 1 to move one row down in the array:
n = n+1;
FCCLattice(n,:) = coordinatestranslation +FCCatoms(i,:);
end
end
end
end
end
I have created this code for my undergraduate research if it works!
  1 个评论
Muthukumar
Muthukumar 2024-2-5
I tried this code I couldn't get the expected results. I could use some help

请先登录,再进行评论。


Jean-Marie Becker
Jean-Marie Becker 2020-12-23
编辑:Walter Roberson 2024-2-5
%Here is a simple solution:
k=4; a=1/2;
[X,Y,Z]=meshgrid(0:k);
x=X(:);x=[x;x+a;x+a;x];
y=Y(:);y=[y;y;y+a;y+a];
z=Z(:);z=[z;z+a;z;z+a];
plot3(x,y,z,'or');view(-40,20);

类别

Help CenterFile Exchange 中查找有关 Crystals 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by