Skip to content
Snippets Groups Projects
Commit 002e5d92 authored by Lisa Schätzle's avatar Lisa Schätzle
Browse files

Update example_5_1.m

parent 708bb31c
No related branches found
No related tags found
No related merge requests found
%% Example 5.1 (Splitting only) for varying size:
%% Example 5.1 (Splitting only) for varying distance:
clear all
close all
......@@ -26,7 +26,7 @@ R = [3.5, 5]; % radii of circles containing source components
znut = [26;-3];
v = [-2;-1]/norm([-2;-1]);
dist = [15 20 25 30 35 40];
dist = [10 15 20 25 30 35 40 45];
zkite = zeros(2,length(dist));
nr_rep = length(dist);
......@@ -54,8 +54,8 @@ end
% Numerical reconstruction with least squares approach:
tol = 1e-5;
kmax = 100;
tol = 1e-8;
kmax = 300;
Anut = cell(1,nr_rep);
Akite = cell(1,nr_rep);
......@@ -77,14 +77,8 @@ for iteri = 1:nr_rep
clear A z
relerrnut(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
end
disp('Table 5.1 (left): Relative errors of far field operator splitting with least squares approach for varying distance:')
fprintf(' |c_1-c_2| epsilon_nut epsilon_kite\n')
for iteri = 1:nr_rep
fprintf(' %d %.3f %.3f\n', dist(iteri), round(relerrnut(iteri),3), round(relerrkite(iteri),3))
relerrnut1_cg(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite1_cg(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
end
% Numerical reconstruction with l1xl1-minimization:
......@@ -106,15 +100,31 @@ for iteri = 1:nr_rep
clear A z
relerrnut(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
relerrnut1_fista(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite1_fista(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
end
disp('Table 5.1 (left): Relative errors of far field operator splitting with l1xl1-minimization for varying distance:')
fprintf(' |c_1-c_2| epsilon_nut epsilon_kite\n')
for iteri = 1:nr_rep
fprintf(' %d %.3f %.3f\n', dist(iteri), round(relerrnut(iteri),3), round(relerrkite(iteri),3))
end
% Plot relative errors:
figure()
semilogy(dist, relerrnut1_cg, 'r--o', dist, relerrkite1_cg, 'b--*', dist, relerrnut1_fista, 'r-o', dist, relerrkite1_fista, 'b-*', 'LineWidth', 1.2)
title('Relative errors for varying distance', 'Interpreter', 'latex')
xlabel('$|c_1-c_2|$', 'Interpreter', 'latex')
ylabel('$\epsilon_{\mathrm{rel}}$', 'Interpreter', 'latex')
legend({'$\epsilon_{\mathrm{rel}}^1$ using cg','$\epsilon_{\mathrm{rel}}^2$ using cg', '$\epsilon_{\mathrm{rel}}^1$ using FISTA', '$\epsilon_{\mathrm{rel}}^2$ using FISTA'}, 'Interpreter','latex', 'Location','northeast')
xlim([dist(1) dist(end)])
ylim([10^(-2) 1])
grid on
ax = gca;
ax.FontSize = 16;
print ../figures/errors_vary_distance.eps -depsc
% Plot of geometry:
......@@ -134,7 +144,7 @@ hold on
% Other kites:
for iteri = 1:nr_rep
if iteri~=3
if iteri~=7
zhelp = zkite(:,iteri);
paramshelp = [1 .5 zhelp.' 135 3];
......@@ -150,7 +160,7 @@ for iteri = 1:nr_rep
end
% Special kite:
zhelp = zkite(:,3);
zhelp = zkite(:,7);
paramshelp = [1 .5 zhelp.' 135 3];
[x_kite,~,~,~] = kurve(100, 'kite', paramshelp);
......@@ -165,10 +175,13 @@ hold on
title('Geometry and a priori information for varying distance', 'Interpreter', 'Latex')
grid on
axis equal
axis([-20 35.5 -30 10])
text(26.2,-1.8,'$D_1$','Color','blue','FontSize',16, 'Interpreter','latex')
text(-11.7,-19.5,'$D_2$','Color','blue','FontSize',16, 'Interpreter','latex')
ax = gca;
ax.FontSize = 12;
ax.FontSize = 16;
print ../figures/geometry_vary_distance.eps -depsc
......@@ -195,7 +208,9 @@ noiselevel = 0.05;
% Vary Size of one scatterer:
R_kite = 5;
R_nut = [2 3.5 5 6.5 8 9.5]/3.2;
R_nut = [2 3.5 5 6.5 8 9.5];
scaling_nut = R_nut*3/3.4;
znut = [26;-3];
v = [-2;-1]/norm([-2;-1]);
......@@ -211,8 +226,8 @@ Fkite = cell(1,nr_rep);
Fall = cell(1,nr_rep);
for iteri = 1:nr_rep
params = [(R_nut(iteri)^2*1) (R_nut(iteri)^2*.5) znut.' 45 3; 1 .5 [zkite-[.5;-.5]].' 135 3];
params = [1 .5 znut.' 45 scaling_nut(iteri); 1 .5 [zkite-[.5;-.5]].' 135 3];
[Fnut{iteri}, ~, ~] = evaluateFarfieldNystrom({'nut'}, params(1,:), q(1), k, sampling.nxhat, 0);
[Fkite{iteri}, ~, ~] = evaluateFarfieldNystrom({'kite'}, params(2,:), q(2), k, sampling.nxhat, 0);
[Fall{iteri}, ~, ~] = evaluateFarfieldNystrom({'nut', 'kite'}, params, q, k, sampling.nxhat, 0);
......@@ -225,8 +240,8 @@ end
% Numerical reconstruction:
tol = 1e-3;
kmax = 100;
tol = 1e-8;
kmax = 300;
Anut = cell(1,nr_rep);
Akite = cell(1,nr_rep);
......@@ -237,9 +252,9 @@ indOfInterest = sub2ind([nr_of_scatterers,nr_of_scatterers],1:nr_of_scatterers,1
for iteri = 1:nr_rep
z = [znut, zkite];
R = [R_nut(iteri)*3.2, R_kite];
R = [R_nut(iteri), R_kite];
[A, ~, ~] = CG_secondOrder(G{iteri}, sampling, k, P_Omega, z, R, kmax, tol);
[A, nr_of_iterations, Res] = CG_secondOrder(G{iteri}, sampling, k, P_Omega, z, R, kmax, tol);
Aall{iteri} = A{2} + A{3} + A{4} + A{5};
A = {A{1},A{indOfInterest+1}};
......@@ -249,14 +264,8 @@ for iteri = 1:nr_rep
clear A z
relerrnut(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
end
disp('Table 5.1 (right): Relative errors of far field operator splitting with least squares approach for varying size of the nut:')
fprintf(' R_nut epsilon_nut epsilon_kite\n')
for iteri = 1:nr_rep
fprintf(' %.1f %.3f %.3f\n', R_nut(iteri)*3.2, round(relerrnut(iteri),3), round(relerrkite(iteri),3))
relerrnut2_cg(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite2_cg(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
end
% Numerical reconstruction with l1xl1-minimization:
......@@ -278,17 +287,32 @@ for iteri = 1:nr_rep
clear A z
relerrnut(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
relerrnut2_fista(iteri) = norm(Anut{iteri}-Fnut{iteri})/norm(Fnut{iteri});
relerrkite2_fista(iteri) = norm(Akite{iteri}-Fkite{iteri})/norm(Fkite{iteri});
end
disp('Table 5.1 (right): Relative errors of far field operator splitting with l1xl1-minimization for varying size of the nut:')
fprintf(' R_nut epsilon_nut epsilon_kite\n')
for iteri = 1:nr_rep
fprintf(' %.1f %.3f %.3f\n', R_nut(iteri)*3.2, round(relerrnut(iteri),3), round(relerrkite(iteri),3))
end
% Plot relative errors:
% Plot of geometry:
figure()
semilogy(R_nut, relerrnut2_cg, 'r--o', R_nut, relerrkite2_cg, 'b--*', R_nut, relerrnut2_fista, 'r-o', R_nut, relerrkite2_fista, 'b-*', 'LineWidth', 1.2)
title('Relative errors for varying size', 'Interpreter', 'latex')
xlabel('$R_1$', 'Interpreter', 'latex')
ylabel('$\epsilon_{\mathrm{rel}}$', 'Interpreter', 'latex')
legend({'$\epsilon_{\mathrm{rel}}^1$ using cg','$\epsilon_{\mathrm{rel}}^2$ using cg', '$\epsilon_{\mathrm{rel}}^1$ using FISTA', '$\epsilon_{\mathrm{rel}}^2$ using FISTA'}, 'Interpreter','latex', 'Location','southeast')
xlim([R_nut(1) R_nut(end)])
grid on
ax = gca;
ax.FontSize = 16;
print ../figures/errors_vary_radius.eps -depsc
%% Plot of geometry:
figure()
......@@ -306,31 +330,36 @@ hold on
% Other nuts:
for iteri = 1:nr_rep
paramshelp = [(R_nut(iteri)^2*1) (R_nut(iteri)^2*.5) znut.' 45 3];
paramshelp = [1 .5 znut.' 45 scaling_nut(iteri)];
[x_nut,~,~,~] = kurve(100,'nut', paramshelp);
x_nut = [x_nut;x_nut(1,:)];
plot(x_nut(:,1),x_nut(:,2),'LineWidth', 1.5, 'Color', [0.678 0.847 0.902])
hold on
plot(3.2*R_nut(iteri)*cos(d)+znut(1),3.2*R_nut(iteri)*sin(d)+znut(2),'LineStyle', '--', 'LineWidth', 1, 'Color', [.5 .5 .5])
plot(R_nut(iteri)*cos(d)+znut(1),R_nut(iteri)*sin(d)+znut(2),'LineStyle', '--', 'LineWidth', 1, 'Color', [.5 .5 .5])
end
% Special nut:
paramshelp = [(R_nut(3)^2*1) (R_nut(3)^2*.5) znut.' 45 3];
% paramshelp = [(R_nut(3)^2*1) (R_nut(3)^2*.5) znut.' 45 3];
paramshelp = [1 .5 znut.' 45 scaling_nut(3)];
[x_nut,~,~,~] = kurve(100,'nut', paramshelp);
x_nut = [x_nut;x_nut(1,:)];
plot(x_nut(:,1),x_nut(:,2),'LineWidth', 1.5, 'Color', 'blue')
hold on
plot(3.2*R_nut(3)*cos(d)+znut(1),3.2*R_nut(3)*sin(d)+znut(2),'LineStyle', '--', 'LineWidth', 1.2, 'Color', 'black')
% plot(3.2*R_nut(3)*cos(d)+znut(1),3.2*R_nut(3)*sin(d)+znut(2),'LineStyle', '--', 'LineWidth', 1.2, 'Color', 'black')
plot(R_nut(3)*cos(d)+znut(1),R_nut(3)*sin(d)+znut(2),'LineStyle', '--', 'LineWidth', 1.2, 'Color', 'black')
hold on
scatter(znut(1), znut(2),100,'Marker','+','LineWidth', 1.2,'MarkerEdgeColor', 'black')
title('Geometry and a priori information for varying size of nut', 'Interpreter', 'Latex')
title('Geometry and a priori information for varying size', 'Interpreter', 'Latex')
grid on
axis equal
axis([-20 35.5 -30 10])
text(26.2,-1.8,'$D_1$','Color','blue','FontSize',16, 'Interpreter','latex')
text(-12.5,-19.5,'$D_2$','Color','blue','FontSize',16, 'Interpreter','latex')
ax = gca;
ax.FontSize = 12;
ax.FontSize = 16;
print ../figures/geometry_vary_radius.eps -depsc
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment