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

fprintf('ondes05 \n') ; 
fprintf('differences finies \n') 
fprintf('condition limites de Neumann homogenes aux deux bouts')
fprintf('condition initiale en cosinus : evolution modale')
 
n = 16   ,  niter = 40   %%%%%%%%%%%%% 
sigma = .8  %%%%%%%%%      regle pour une periode 
dx = 1/n ; 

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

plot (xx,y1,'r;;' ) 
 
 
dt    = sigma * dx ; 

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

t     = 0   ; 
yy   = y1 ; yym  = yy ;  yyp  = yy ;  yye  = y1 ; 

for jtime = 1 : niter  
for j = 1:n+1 ; yyp(j) = 0 ; end 

d2x0   = 2*(yy(2)-yy(1))  ; 
yyp(1) = 2*yy(1) - yym(1) +  (sigma**2) * d2x0  ; 

d2x1   = 2*(yy(n)-yy(n+1))  ; 
yyp(n+1) = 2*yy(n+1) - yym(n+1) +  (sigma**2) * d2x1  ; 



for j = 2:n ; 
yyp(j) = 2*yy(j) - yym(j) + (sigma**2) *  (yy(j+1)-2*yy(j)+yy(j-1))  ;  end 
t     = t + dt ; 
plot ( xx,y1,'k;inf;' ,   xx,yyp,'*-b*;t;' )  
axis ([ -.01 , 1.01 ,  -1.1  , 1.1  ])
delete (findobj ("tag", "legend"))
title ('differences finies ; conditions limites de Neumann homogenes aux deux bouts')
pause (.005) ;

if jtime==27 ;  print('07-differences-finies-conditions-limites-neumann' , '-djpg','-S891,630'); end ;



yym = yy ; yy = yyp ; 
end 


 

