% limits of dispersion relation of gravity waves: shallow, deep,
% finite depth.  for EPS131, Eli, Spring 2008.
close all; clear all;

% MKS:
H=5;
g=9.8;
i=0;
for lambda=0.1:0.1:300
  i=i+1;
  k=2*pi/lambda;
  lambda_axis(i)=lambda;
  omega_shallow(i)=sqrt(g*H)*k;
  omega_deep(i)=sqrt(g*k);
  omega_finite(i)=sqrt(g*k*tanh(k*H));
end

hl1=plot(lambda_axis,2*pi./omega_shallow,'r');
hold on;
hl2=plot(lambda_axis,2*pi./omega_deep,'g');
hl3=plot(lambda_axis,2*pi./omega_finite,'b');
h1=legend('shallow','deep','finite');
set(h1,'location','northwest');
axis([0 200 0 30]);
h2=xlabel('wavelength \lambda=2\pi/k, meters');
h3=ylabel('period T=2\pi/\omega, seconds');
h4=title('gravity wave dispersion relations');
set([gca,h1,h2,h3,h4],'fontsize',14);
set([hl1,hl2,hl3],'linewidth',1.5);

%% save as pdf:
set(gcf, 'PaperUnits', 'inches'); set(gcf, 'PaperSize', [4 4]);
set(gcf, 'PaperPosition', [0 0 4 4]); % [left, bottom, width, height];
saveas(gcf,sprintf('4a-gravity-waves-dispersion-relations.pdf'));
