94 lines
1.4 KiB
Matlab
Executable File
94 lines
1.4 KiB
Matlab
Executable File
%% eulero forward DIrichlet
|
|
L=pi;
|
|
T=2;
|
|
f=@(x,t) 0*x.*t;
|
|
c1=@(t) 1+0*t;
|
|
c2=@(t) 0*t;
|
|
u0=@(x) 0*x;
|
|
D=0.5;
|
|
%uex=@(x,t) cos(x).*exp(t);
|
|
|
|
N=10;
|
|
K=200;
|
|
[x,t,u]=Dirichlet_EA(L,N,T,K,c1,c2,f,u0,D);
|
|
|
|
figure(1)
|
|
for ii=1:K+1
|
|
plot(x,u(:,ii)');
|
|
xlim([0 L])
|
|
pause(0.05);
|
|
end
|
|
|
|
space=linspace(0,L,101);
|
|
time=linspace(0,T,201);
|
|
[xx,yy]=meshgrid(time,space);
|
|
%exsol=uex(yy,xx);
|
|
figure(2)
|
|
mesh(t,x,u)
|
|
%figure(2)
|
|
%mesh(xx,yy,exsol)
|
|
|
|
%% Eulero forward Mixed BC
|
|
|
|
L=2*pi;
|
|
T=5;
|
|
f=@(x,t) 0*x.*t;
|
|
c1=@(t) 1+0*t;
|
|
c2=0;
|
|
u0=@(x) 0*x;
|
|
D=1.1;
|
|
%uex=@(x,t) cos(x).*exp(t);
|
|
|
|
N=25;
|
|
K=200;
|
|
[x,t,u]=Mixed_EA(L,N,T,K,c1,c2,f,u0,D);
|
|
|
|
figure(1)
|
|
for ii=1:K+1
|
|
plot(x,u(:,ii)');
|
|
xlim([0 L])
|
|
ylim([0 1.5])
|
|
pause(0.02);
|
|
end
|
|
|
|
space=linspace(0,L,101);
|
|
time=linspace(0,T,201);
|
|
[xx,yy]=meshgrid(time,space);
|
|
%exsol=uex(yy,xx);
|
|
figure(2)
|
|
mesh(t,x,u)
|
|
%figure(2)
|
|
%mesh(xx,yy,exsol)
|
|
|
|
%% Eulero Backward Mixed BC
|
|
|
|
L=2*pi;
|
|
T=5;
|
|
f=@(x,t) 0*x.*t;
|
|
c1=@(t) 1+0*t;
|
|
c2=0;
|
|
u0=@(x) 0*x;
|
|
D=1;
|
|
%uex=@(x,t) cos(x).*exp(t);
|
|
|
|
N=25;
|
|
K=200;
|
|
[x,t,u]=Mixed_EI(L,N,T,K,c1,c2,f,u0,D);
|
|
|
|
figure(1)
|
|
for ii=1:K+1
|
|
plot(x,u(:,ii)');
|
|
xlim([0 L])
|
|
ylim([0 1.5])
|
|
pause(0.02);
|
|
end
|
|
|
|
space=linspace(0,L,101);
|
|
time=linspace(0,T,201);
|
|
[xx,yy]=meshgrid(time,space);
|
|
%exsol=uex(yy,xx);
|
|
figure(2)
|
|
mesh(t,x,u)
|
|
%figure(2)
|
|
%mesh(xx,yy,exsol)
|