How to generate a fcc crystal matrice?
23 ビュー (過去 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
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
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
2024 年 2 月 5 日
I tried this code I couldn't get the expected results. I could use some help
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);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Crystals についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!