%   ondes02.m
%   fd, 13 decembre 2010, 06 mars 2025  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   clear ; format long

fprintf('ondes02 \n') ; 
fprintf('equation des ondes avec les series de Fourier \n') 
fprintf('mode de Fourier d ordre superieur  \n')



n = 180  

niter = 135  %% 60 %% 180 

dx = 1/n ; 
kmode=2
xx = zeros(1,n+1) ; y1 = xx ; 
xa    = 0 ; 
for j = 1:n+1 ; xx(j) = xa ; y1(j) = sin(kmode*pi*xa) ; 
xa = xa + dx ; end 


plot (xx,y1,'k;;' )
axis ([ -.02 , 1.02 , -1.05 , 1.05]) 
delete (findobj ("tag", "legend"))
title ('condition initiale : fonction sinus sur une periode complete') ;
print('02a-sinus-initial', '-djpg','-S891,630'); 
pause (1) 

sigma = 2
dt    = sigma * dx ; 




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

hold off
t     = 0   ; 
for jtime = 1 : niter  
for j = 1:n+1 ; 
yy(j)    =  cos(kmode*pi*t) * y1(j) ; end 
t     = t + dt ; 
plot ( xx,y1,'k;inf;' ,   xx,yy,'b;t;' )
delete (findobj ("tag", "legend")) 
axis ([ -.02 , 1.02 , -1.05 , 1.05])
title ('second mode de vibration d une corde') ;


if jtime==60 ; 
print('02b-sinus-en-evolution' , '-djpg','-S891,630'); 
end ; 

pause (.001) ; end ; pause (1) 




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



kmode=3
xx = zeros(1,n+1) ; y1 = xx ; 
xa    = 0 ; 
for j = 1:n+1 ; xx(j) = xa ; y1(j) = sin(kmode*pi*xa) ; 
xa = xa + dx ; end 


plot (xx,y1,'k;;' )
axis ([ -.02 , 1.02 , -1.05 , 1.05]) 
delete (findobj ("tag", "legend"))
title ('condition initiale : fonction sinus avec deux noeuds') ;
print('02c-sinus-initial', '-djpg','-S891,630'); 
pause (1) 




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

hold off
niter = 90 
t     = 0   ; 
for jtime = 1 : niter  
for j = 1:n+1 ; 
yy(j)    =  cos(kmode*pi*t) * y1(j) ; end 
t     = t + dt ; 
plot ( xx,y1,'k;inf;' ,   xx,yy,'b;t;' )
delete (findobj ("tag", "legend")) 
axis ([ -.02 , 1.02 , -1.05 , 1.05])
title ('second mode de vibration d une corde') ;

if jtime==20 ; 
print('02d-sinus-en-evolution' , '-djpg','-S891,630'); 
end ; 

pause (.001) ; end ; 


