Gen Coord - Sce

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

clear;

// function for generating the coordinate of a particle using the lattice points of
craystal
function [a1,a2,a3] = lattice_pos(index,Lx,Ly,Lz,lattice_const)
l=1; // start count the particle number
for i = -Lx/2:Lx/2
x=i*lattice_const;
for j = -Ly/2:Ly/2
y=j*lattice_const;
for k = -Lz/2:Lz/2
z=k*lattice_const;
if (abs(x)<Lx/2) & (abs(y)<Ly/2) & (abs(z)<Lz/2) & (l<=index)
then // condition to run loop upto index
a1=x; a2=y; a3=z;
l=l+1;
end
end
end
end
endfunction

You might also like