%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     GV0
%
% ZEROTH PROGRAM TO STUDY GROUP VELOCITY
%
% SIMPLE CASE: two waves with close wavenumbers,
%               one stationary, one moving.
%

XLEN = 40E6; XNUM = 1001; 
x=linspace(0,XLEN,XNUM);
TDAYS = 100;
TLEN=TDAYS*24*3600; TNUM = 501;
t=linspace(0,TLEN,TNUM);

ubar = 0;
m1 = 25;
m2 = 26;
k1 = 2*pi*m1/XLEN;
k2 = 2*pi*m2/XLEN;

beta=1.6E-11;

sig1 = k1*ubar - beta/k1;
sig2 = k2*ubar - beta/k2; sig2 = 0;

c1 = sig1/k1; 
c2 = sig2/k2; 

w10 = sin(k1*x);
w20 = sin(k2*x);
ws0 = (w10+w20);
XU = ubar*t(1);
axis('off')
subplot(3,1,1); plot(x,w10); title('WAVE 1');
hold on; plot(XU,0,'x'); hold off
subplot(3,1,2); plot(x,w20); title('WAVE 2');
hold on; plot(XU,0,'x'); hold off
subplot(3,1,3); plot(x,ws0); title(' SUM ');
hold on; plot(XU,0,'x'); hold off
pause
for nt=1:TNUM
   tt = t(nt);
   w1 = sin(k1*x-sig1*tt);
   w2 = sin(k2*x-sig2*tt);
   ws = (w1+w2);
   XU = ubar*tt; XU = rem(XU,XLEN);
   subplot(3,1,1); plot(x,w1);title('WAVE 1');
   hold on; plot(XU,0,'x'); hold off
   subplot(3,1,2); plot(x,w2);title('WAVE 2');
   hold on; plot(XU,0,'x'); hold off
   subplot(3,1,3); plot(x,ws);title(' SUM ');
   hold on; plot(XU,0,'x'); hold off
   drawnow
   %pause
end

return   
