-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExampleA1.m
56 lines (51 loc) · 1.85 KB
/
ExampleA1.m
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
close all
clear options
% Add directory to current path
addpath('..')
addpath('/Users/nataliesheils/Dropbox (uwamath)/InterfaceProblems/Heat_Imperfect/MultDiff-master')
addpath('/Users/nataliesheils/Dropbox (uwamath)/InterfaceProblems/Heat_Imperfect/MultDiff-master/analytical')
addpath('/Users/nataliesheils/Documents/MATLAB')
% Parameters
m = 3; % Number of layers
kappa = ones(m,1); % Diffusivities
l0 = 0.0; % Left end of slab
lm = 1.0; % Right end of slab
dx = (lm-l0)/m; l = dx:dx:lm-dx; % Location of interfaces
u0 = @(x) x.^3; % Initial condition
Lbnd = {'Dirichlet',1.0,0.0,0.0}; % Boundary condition (x = l0)
Rbnd = {'Dirichlet',1.0,0.0,1.0}; % Boundary condition (x = lm)
tspan = [0.01, .1, 1.]; % Times at which to compute solution
options.NX = 25; % Number of places to evaluate solution
options.N = 100; % Number of eigenvalues
tic
[umd,xmd] = multdiff(m,kappa,l0,lm,l,u0,Lbnd,Rbnd,tspan,'Perfect',options);
toc
[ug,xg] = multdiff_global(m,kappa,l0,lm,l,u0,Lbnd,Rbnd,tspan,'Perfect',options);
% Plot
figure;
for i = 1:m-1,
plot([l(i),l(i)],[-0.1,1.1],'Color',[0.9,0.9,0.9])
hold on
end
plot(xmd,umd,'b','LineWidth',2.0)
plot(xf,u,'r--','LineWidth',2.0)
plot(xg,ug,'go')
axis([0,1,0,1.1])
xlabel('$x$','Interpreter','LaTeX','FontSize',20)
ylabel('$u(x,t)$','Interpreter','LaTeX','FontSize',20)
set(gca,'FontSize',14,'Layer','top')
saveas(gcf,'ExA_compare.pdf')
%%For Paper
figure;
for i = 1:n+1,
plot([xj(i),xj(i)],[min(min(u))-.1,max(max(u))+.1],'Color',[0.9,0.9,0.9], 'LineWidth',1.)
hold on
end
plot(xf,uexact,'black-','LineWidth',2.0)
plot(xf,u,'r--','LineWidth',2.0)
plot(xg,ug,'go')
axis([0,1,0,1])
ax=gca;
ax.XTickLabel={};
ax.YTickLabel={};
saveas(gcf,'ExA_p.pdf')