1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| function araud
%initialisation
%boucle de calcul sur la largeur du convergent divergent
clear all
close all
%format long
global g;
cfl=0.8;
m=2;
g=9.81;
L=1;
nx=10;
dx=2*L/nx;
%q1=0.1*zeros(2,nx);
h0=1.0;
u0=0;
hl=0.1;
ul=0;
x0=0;
t=0;
tstop=0.5;
x=(-L+dx/2:dx:L-dx/2);
%q1=finit(x0,dx,h0,hl,u0,ul)
q1=zeros(2,nx);
q2=zeros(size(q1));
%conditions initiale
for i=1:nx/2
if x<=x0
q1(1,i)=h0;
q1(2,i)=h0*u0;
else
%for i=nx/2+1:nx
q1(1,i)=hl;
q1(2,i)=hl*ul;
end
end
n=0;
% conditions aux limites libres
q2(:,1)=q2(:,2);
q2(:,nx+1)=q2(:,nx);
%while (t<tstop)
% n=n+1;
for j=1:m
dt=0.5*cfl*dx/max(abs(q1(2,:)./q1(1,:)+(g*q1(1,:)).^.5))
if t+dt>tstop
dt=tstop-t;
end
t=t+dt;
h=dt/dx;
%q2(1,:)=q1(1,:);
%q2(2,:)=q1(1,:)*q1(2,:);
for i=2:nx-1
x(i)=i*dx
% q2(:,i)=q1(:,i)-h*(flux_sv(q1(:,i)-flux_sv(q1(:,i-1))))
%q2(:,i)=q1(:,i)-h*(flux_centre(q1(:,i),q1(:,i+1),h)-flux_centre(q1(:,i-1),q1(:,i),h))
q2(:,i)=q1(:,i)-h*(flux_centre_wendroff(q1(:,i),q1(:,i+1),h)-flux_centre_wendroff(q1(:,i-1),q1(:,i),h))
% q3(:,i)=q1(:,i)-h*(flux_centre_wendroff(q1(:,i),q1(:,i+1),h)-flux_centre_wendroff(q1(:,i-1),q1(:,i),h));
%q4=0.5*(q2+q3);
end
plot(x(i),q2(1,:));
F(j)=getframe;
movie(F,m)
%end
end |
Partager