%%%%%%%%%%%%%%%%
% dispersion.m %
%%%%%%%%%%%%%%%%

clf;
loadf;
mesh = 100;
nu_max = 22;
label_nu = - nu_max / 26.6;
% k nodes in Cartesian Pi/A:
kn = [
% gamma
    0   0   0;
% K
    1.5 1.5 0;
% X
    2.  0.  0;
% gamma^prime
    2   2   2;
% L
    1   1   1;
% W 
    2   1   0; ];
nn = {'\Gamma', 'K', 'X', '\Gamma^\prime', 'L', 'W'};
lk = [1 3 4 5 6 3]; 
n = size(lk);
for s = 1 : n(2)-1,
  len(s) = norm(kn(lk(s+1),:)-kn(lk(s),:));
end;
% k nodes in G-vector:
kn = kn * [0 0.5 0.5; 0.5 0 0.5; 0.5 0.5 0] / 2;

r = 0;
x = [];
nu = [];
for s = 1 : n(2)-1,
  for j = 0 : mesh-1,
    k = kn(lk(s),:) + (kn(lk(s+1),:)-kn(lk(s),:)) / mesh * j;
    nu = [nu sqrt(sort(dk(k))) / 2 / pi /1e12 ];
    x = [x r];
    r = r + len(s) / mesh;
  end;
end;
for i = 1 : 3*npa,
  plot(x, nu(i,:));
  if (i == 1) hold on; end;
end;

r = 0;
for s = 1 : n(2),
  plot ([r r], [0 nu_max], 'k');
  text (r, label_nu, nn(lk(s)));
  if (s < n(2)) r = r + len(s); end;
end;

axis ([0 r 0 nu_max]);
ylabel ('\nu [THz]');
set (gca, 'XTick', []);
title ('Phonon Dispersion of Rocksalt ZrC');

% print -depsc dispersion.eps %
