How to write FCC lattice vector with MATLAB?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Description;
T (Inverse lattice vector), a, b, c are atoms vector. T= n1*a + n2*b+ n3*c a= a/2*(i+j) b= a/2*(j+k) c= a/2*(i+k)
-3<n1<3 -3<n2<3 -3<n3<3
I want to calculate T vector by the using of above equations.
0 comentarios
Respuestas (1)
Karan Singh
el 20 de Feb. de 2025
Below is an example MATLAB code snippet that computes the FCC lattice vector T. The vectors a, b, and c are defined using the given formulas. Each is scaled by half the lattice constant a0. The integer parameters are set from –2 to 2. In the end three nested loops iterate over all combinations of n1, n2, and n3. For each combination, the T vector is computed and stored in the array "T_all".
% Define the lattice constant (change as needed)
a0 = 1;
% Define the FCC basis vectors
a = (a0/2) * [1, 1, 0]; % a = a0/2*(i + j)
b = (a0/2) * [0, 1, 1]; % b = a0/2*(j + k)
c = (a0/2) * [1, 0, 1]; % c = a0/2*(i + k)
% Define the range for n1, n2, n3 (here from -2 to 2 as an example)
n_range = -2:2;
% Preallocate an array to store T vectors (optional)
% There will be length(n_range)^3 vectors (here 5^3 = 125)
T_all = zeros(length(n_range)^3, 3);
count = 1;
% Loop over all integer combinations of n1, n2, n3
for n1 = n_range
for n2 = n_range
for n3 = n_range
T = n1*a + n2*b + n3*c; % Compute T vector
T_all(count, :) = T; % Store in the matrix (each row is a T vector)
count = count + 1;
end
end
end
% Display all calculated T vectors
disp('Calculated FCC lattice vectors T:');
disp(T_all);
Karan
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!