1 function l = ei_error_convergence(detailed_data,detailed_path, ...
2 ei_operator_path, params)
3 %
function l = ei_error_convergence(detailed_data,detailed_path, ...
4 % ei_operator_path, params)
6 %
function generating a error-convergence graph over the set
7 % of parameters given in the paths. The handle to the plot is returned.
8 % The function performs the detailed_ei_interpolated simulation for
9 % increasing number of basis vectors M until the value given in params.M.
10 % (1) the maximum approximation error is plotted, i.e. projection of all
11 % ei-snapshots on the increasing ei-spaces, and computation of the
12 % maximum L^infty(L2)-error, (2) the interpolation error,
13 % i.e. interpolation of all snapshots, error computation and maximum
14 % search and (3) the error between detailed-ei-simulation and the real
15 % detailed simulations is computed.
16 % the detailed_path must contain detailed simulations, e.g. generated by
18 % corresponding space-discretization operator results, e.g. generated by
19 % save_ei_operator_trajectories
21 % Bernard Haasdonk 7.9.2007
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24 %%%%% general settings to be used
25 Msamples = params.Msamples;
26 % Mmax = size(detailed_data.BM,2);
27 Mmax = params.Mmax; % size(detailed_data.BM,2);
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 % detailed_path = params.RB_detailed_train_savepath;
31 % ei_operator_path = params.ei_operator_savepath;
33 errnames = {
'approximation',
'interpolation',
'ei-simulation'}
35 Ms = round((0:(Msamples-1)) * ...
36 (Mmax-1)/(Msamples-1)+1);
38 settings = load(fullfile(rbmatlabtemp,...
39 detailed_path,
'settings.mat'));
41 % storage
for maximum l2-errors (i.e. linfty([0,T],l2)-norm)
42 approx_errs = zeros(Msamples,1);
43 interpol_errs = zeros(Msamples,1);
44 ei_simulation_errs = zeros(Msamples,1);
46 for mu_ind = 1:size(settings.M,2);
48 disp([
'processing parameter vector ',num2str(mu_ind),...
49 '/',num2str(size(settings.M,2))]);
50 params = set_mu(settings.M(:,mu_ind),params);
51 if ismember(
'ei-simulation',errnames)
60 % detailed simulation with ei of the operator
61 if ismember('ei-simulation',errnames)
62 U_ei_H = detailed_ei_nonlin_evol_simulation(detailed_data, ...
66 max_l2err = max(l2err);
67 if max_l2err > ei_simulation_errs(Mind)
68 ei_simulation_errs(Mind) = max_l2err;
73 fname = ['LU',num2str(mu_ind)];
74 tmp = load(fullfile(rbmatlabtemp,ei_operator_path,fname));
78 if ismember('approximation',errnames)
79 % for each discrete function in LU
80 % compute best-l2-approximation in current space spanned by Q
82 % if <u_H,v_H> = u' * W * v (u,v coefficient vectors)
83 % then min_p (u_H - sum p(i) q_i) is minimized by
85 % p = (Q' W Q)^(-1) Q^T W u
87 % So compute whole array of p-vectors and resulting approximation Q*p
88 W = feval(params.get_inner_product_matrix(detailed_data),...
89 detailed_data.grid,...
91 A = (detailed_data.QM(:,1:M)' * W * ...
92 detailed_data.QM(:,1:M))^(-1) * ...
93 detailed_data.QM(:,1:M)' * W;
95 L_E_U_appr = detailed_data.QM(:,1:M) * A * L_E_U;
97 l2err =
fv_l2_error(L_E_U_appr,L_E_U,detailed_data.W);
98 max_l2err = max(l2err);
99 if max_l2err > approx_errs(Mind)
100 approx_errs(Mind) = max_l2err;
105 % interpolation error
106 if ismember('interpolation',errnames)
107 % for each discrete function in LU
108 % compute interpolation in current space spanned by Q
109 W = params.get_inner_product_matrix(detailed_data);
111 QM = detailed_data.QM(:,1:M);
113 % get interpolation coefficients
114 coeff = detailed_data.BM(1:M,1:M) \ L_E_U(detailed_data.TM(1:M),:);
115 L_E_U_interpol = QM * coeff;
117 l2err =
fv_l2_error(L_E_U_interpol,L_E_U,detailed_data.W);
118 max_l2err = max(l2err);
119 if max_l2err > interpol_errs(Mind)
120 interpol_errs(Mind) = max_l2err;
122 clear('L_E_U_interpol');
127 disp('workspace is saved in ws.mat in case of break....');
131 l = plot(Ms,[approx_errs,interpol_errs,ei_simulation_errs]);
132 set(l,'Linewidth',2);
133 set(l(1),'LineStyle','-');
134 set(l(2),'LineStyle','-.');
135 set(l(3),'LineStyle',':');
136 set(gca,'Yscale','log');
137 legend({
'max approx-error',
'max interpol-error',
'max-ei-simulation-error'});
138 title(
'empirical interpolation error');
142 disp(
'workspace is saved in ws.mat for modification of plots.');
144 % TO BE ADJUSTED TO NEW SYNTAX