How to generate a fcc crystal matrice?

조회 수: 22 (최근 30일)
Chenyue Xu
Chenyue Xu 2017년 7월 10일
편집: Walter Roberson 2024년 2월 5일
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