Matrix form for a square lattice arrangement.
1 view (last 30 days)
Show older comments
Question: I want to have a matrix form for hopping between nearest points on a square lattice.
My Attempt: To start and explain the idea I do that on a 1D lattice like shown in the figure
The matrixForm for this case comes from this.
I create a 1D chain using the following code (I use a fucntion SquareGrid defined below)
N = 3; % Number of points
pts = squareGrid([0 0 (N-1) 0], [1 1]);
scatter(pts(:,1),pts(:,2),50,'o', 'filled')
Now I want a matrixform such that I can see hopping between the sites which are neigbors. First and last sites are linked. For this i do the following.
N =5; % Number of sites
t = 1; % value for hopping
t_vec = repmat(t, [1,N-1]); % making a vector of size N-1 with t
H_tb = diag(t_vec, 1) + diag(t_vec, -1);
H_tb(1,5) = t; H_tb(5,1) = t; % linking first and last points
H_tb
Now I have the matricform as shown above which does what I wanted for a 1D chain. Now i want to do the same for 2D, square lattice. This is where I am stuck. How do make a matrixform such as above which takes into account all the hoppings between nearest sites? Any help would be appreciated. Thank You.
pts = squareGrid([0 0 1 1], [1 1]);
scatter(pts(:,1),pts(:,2),50,'o', 'filled')
For this I use a function SquareGrid as below.
function varargout = squareGrid(bounds, dim)
%bounds(xmin,ymin,xmax,ymax)
% dim(xsep, ysep) eg. dim(4,2) makes separation b/w points xpoints as 4 and
% ypoints as 2
x1 = bounds(1);
x2 = bounds(3);
lx = (x1: dim(1):x2)';
y1 = bounds(2);
y2 = bounds(4);
ly = (y1: dim(2):y2)';
%number of points in each coordinate
nx = length(lx);
ny = length(ly);
np = nx * ny;
%Creating Points
pts = zeros(np,2);
for i = 1:ny
pts((1:nx)' + (i-1) * nx, 1) =lx;
pts( (1:nx)'+(i-1)*nx, 2) = ly(i);
end
if nargout > 0 % if number of function arguments is > zero
varargout{1} = pts;
end
end
Accepted Answer
Matt J
on 6 Oct 2021
For an arbitray lattice, you can always just use pdist2,
D=pdist2(pts,pts,'cityblock');
H_tp=(D==1);
This is without your circulant end conditions. The circulancy doesn't generalize in any obvious way to hexagonal or other arbitrary lattices, so I don't know in general what you would want to do. For a rectangular lattice, you would do,
e11=pts(:,1)==1; e1N=pts(:,1).'==N;
e21=pts(:,2)==1; e2N=pts(:,2).'==N;
E1=(e11&e1N); E1=E1|E1.';
E2=(e21&e2N); E2=E2|E2.';
H_tp=(D==1) | E1 | E2;
See Also
Categories
Find more on Discrete Math in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!