1 % script constructing a reduced basis from a single trajectory and
2 % performing a detailed simulation where the data is projected on the
3 % dummy reduced basis space after each time step.
5 % required variables that need to be set:
10 % -
'ei_rb_proj_data': output of detailed_ei_rb_proj_simulation() with
11 % dummy reduced basis space.
13 tmp=load(fullfile(rbmatlabresult,CRBfname));
14 detailed_data=tmp.detailed_data;
15 disp('detailed interpolated simulation for basis construction:')
16 if ~isfield(model,'Mstrich')
18 model.enable_error_estimator = 0;
21 model.M = cellfun(@(x)(size(x,2) - model.Mstrich), detailed_data.BM, 'UniformOutput', true);
24 ei_sim_data = model.detailed_ei_simulation(model,detailed_data);
27 % in case of
newton scheme add temporary results of
newton steps to dummy
29 if model.newton_solver
30 U = ei_sim_data.Unewton;
36 UON = UON / (full(sqrt(detailed_data.W(1))));
38 %UON = model.orthonormalize(model, detailed_data, ei_sim_data.U,1e-7);
40 detailed_data.RB = UON;
42 disp('reduced simulation:')
43 reduced_data = gen_reduced_data(model, detailed_data);
44 model.N = size(detailed_data.RB,2);
46 smodel.enable_error_estimator = 0;
49 rb_sim_data = rb_simulation(smodel, reduced_data);
52 rb_sim_data = rb_reconstruction(smodel, detailed_data, rb_sim_data);
55 if ~isfield(rb_sim_data, 'Delta')
56 smodel.enable_error_estimator = 0;
58 Delta = rb_sim_data.Delta(end);
60 disp(['Error estimator returned: ', num2str(Delta)]);
63 disp('detailed interpolated and rb-projected simulation:')
64 model.M = cellfun(@(x)(size(x,2) - model.Mstrich), detailed_data.BM, 'UniformOutput', true);
65 model.N = size(detailed_data.RB,2);
66 %ei_rb_proj_data = detailed_ei_rb_proj_simulation(smodel, detailed_data);
68 plot_params.title = 'reduced simulation result';
69 plot_sim_data(model, detailed_data, rb_sim_data, plot_params);
70 plot_params.title = 'detailed ei_interpol simulation result';
71 plot_sim_data(model, detailed_data, ei_sim_data, plot_params);
72 %plot_params.title = 'detailed ei_interpol and rb_projected simulation result';
73 %
plot_sim_data(model, detailed_data, ei_rb_proj_data, plot_params);
77 diff_data = rb_sim_data;
78 %diff_data.U = abs(diff_data.U - ei_rb_proj_data.U);
79 diff_data.U = abs(diff_data.U - ei_sim_data.U);
80 epp.clim = [0,max(max(diff_data.U))];
82 disp(['maximum l-infty error:',num2str(max(max(diff_data.U)))]);
84 if model.debug && smodel.enable_error_estimator
85 ei_res = rb_sim_data.eilog(end);
86 max_ei_error = max(cellfun(@(X) X.max_err_sequence(model.M), ...
87 detailed_data.ei_info));
88 ei_rel_diff = abs(ei_res - max_ei_error) / abs(ei_res);
90 if ei_rel_diff < 0.1 || ei_rel_diff > 10
91 disp(['Oh no! The EI residuum has a different order of magnitude ', ...
92 'than the empirical interpolation error.']);
94 disp(['EI residuum has same order of magnitude as empirical ', ...
95 'interpolation error.']);
97 disp(['EI residuum returned: ', num2str(ei_res)]);
98 disp(['maximum EI error: ', num2str(max_ei_error)]);
100 proj_res = rb_sim_data.reslog(end);
101 % proj_res_exa = ei_rb_proj_data.reslog(end);
102 % proj_res_diff = abs(proj_res_exa - proj_res) / abs(proj_res);
104 % if proj_res_diff < 0.1 || proj_res_diff > 10
105 % disp(['Oh no! The exact projection residuum has a different order of ', ...
106 % 'magnitude than the estimated.']);
108 % disp(['Exact projection residuum has same order of magnitude as ', ...
109 % 'estimated projection residuum.']);
111 disp(['estimated projection residuum: ', num2str(proj_res)]);
112 disp(['exact projection residuum: ', num2str(proj_res_exa)]);
115 disp(['runtime detailed : ', num2str(dtime)]);
116 disp(['runtime rb_sim : ', num2str(rbtime), ' factor: ', num2str(dtime/rbtime)]);
117 disp(['runtime reconstruction : ', num2str(rectime), ' factor: ', num2str(dtime/(rbtime+rectime))]);
function [ descr , rdescr , dmodel , rmodel ] = newton(steps, combined, M_by_N_ratio, noof_ei_extensions, use_laplacian, model_size, random, num_cpus, Mstrich)
small script demonstrating a buckley leverett problem discretization and RB model reduction ...
function p = plot_sim_data(model, model_data, sim_data, plot_params)
function performing the plot of the simulation results as specified in model.