1 function res = vi_rb(step)
3 % experiments
for SINUM ARticle 2012, VI-RB paper from Julien script
4 %
this means, that
this just reprograms the results,
while results
5 % of paper have been obtained by non-RBmatlab code.
9 if nargin == 0 || isempty(step)
13 %model = elastic_rope_model_old;
14 model = elastic_rope_model;
15 model_data = gen_model_data(model);
18 case 0 % check detailed discretization by grid refinement
20 % model = set_mu(model,[21.7157/200, 0.1111])
21 model = set_mu(model,[21.7157/200, 0.1111])
22 % detailed simulation and plot
23 disp('begin detailed simulation');
24 sim_data = detailed_simulation(model,model_data);
26 plot_params.plot_title = 'detailed solution & obstacle';
28 title('xnumintervals=200');
30 params.xnumintervals = 400;
31 model = elastic_rope_model(params);
32 model_data = gen_model_data(model);
33 model = set_mu(model,[21.7157/200, 0.1111])
34 % detailed simulation and plot
35 disp('begin detailed simulation');
36 sim_data = detailed_simulation(model,model_data);
38 plot_params.plot_title = 'detailed solution & obstacle';
41 title('xnumintervals = 400');
44 case 1 % demonstration of model methods
46 % model = set_mu(model,[21.7157/200, 0.1111])
47 % model = set_mu(model,[21.7157/200, 0.1111])
48 model = set_mu(model,[0.075, 0.4])
49 % detailed simulation and plot
50 disp('begin detailed simulation');
51 sim_data = detailed_simulation(model,model_data);
53 plot_params.plot_title = 'detailed solution & obstacle';
54 plot_params.solution_component = 'lambda';
57 disp('press enter to continue');
60 % basis generation, reduced simulation, error comp.
63 disp('compute snapshots');
64 detailed_data = gen_detailed_data(model,model_data);
65 %save('detailed_data_vi.mat','model','detailed_data');
67 reduced_data = gen_reduced_data(model,detailed_data);
69 % rb simulation and plot
70 mus = {[30/200,0],detailed_data.RB_info.mu_train(1,:)};
71 % model = model.set_mu(model,[30,0]); % outside training-sample
75 disp(
'-------------------------------------')
76 disp('simulation for non-training parameter');
78 disp('-------------------------------------')
79 disp('simulation for training parameter');
81 model = model.set_mu(model,mus{mui});
83 sim_data = detailed_simulation(model,model_data);
85 plot_params.plot_title =
'detailed solution & obstacle';
90 disp(
'begin reduced simulation');
91 rb_sim_data = rb_simulation(model,reduced_data);
92 rb_sim_data = rb_reconstruction(model,detailed_data,rb_sim_data);
94 plot_params.plot_title =
'reduced solution & obstacle';
99 disp(
'compute errors and norms');
100 K = model.get_inner_product_matrix(model,model_data);
101 U_err = sqrt((rb_sim_data.U-sim_data.U)
' * K * (rb_sim_data.U- ...
103 L_R = K \ (rb_sim_data.L-sim_data.L);
104 L_err = sqrt((rb_sim_data.L-sim_data.L)' * L_R);
105 disp([
'error (U-UN): ',num2str(U_err)]);
106 disp([
'error (L-LN): ',num2str(L_err)]);
108 U_norm = sqrt(sim_data.U
' * K * sim_data.U);
109 L_R = K \ sim_data.L;
110 L_norm = sqrt(sim_data.L' * L_R);
111 disp([
'norm U: ',num2str(U_norm)]);
112 disp([
'norm L: ',num2str(L_norm)]);
115 model.enable_error_estimator = 1;
116 reduced_data = gen_reduced_data(model,detailed_data);
117 rb_sim_data = rb_simulation(model,reduced_data);
118 disp([
'error estimator (U-UN) <= Delta_u = ',num2str(rb_sim_data.Delta_u)]);
119 disp([
'error estimator (L-LN) <= Delta_l = ',num2str(rb_sim_data.Delta_lambda)]);
124 case 1.5 % check accuracy of rb-scheme
for large Lagrange basis: 289 vectors
125 % IMPORTANT STEP HIGHLIGHTING ACCURACY PROBLEM
127 model.RB_numintervals = [16,16];
128 model.RB_generation_mode =
'pure_snapshots'; % no supr.
129 model.enable_error_estimator = 1;
130 % model.detailed_simulation = @my_new_detailed_simulation;
131 disp(
'generating Lagrange basis');
133 save(
'lagrange-basis-detailed-data',
'model',
'detailed_data');
135 reduced_data = gen_reduced_data(model,detailed_data);
138 disp(
'searching maximum error estimator over train set')
140 max_Delta_lambda = 0;
142 model = set_mu(model,detailed_data.RB_info.mu_train(m,:));
143 rb_sim_data = rb_simulation(model,reduced_data);
144 if max_Delta_u < rb_sim_data.Delta_u
145 max_Delta_u = rb_sim_data.Delta_u
146 disp(['found for m = ',num2str(m)]);
148 if max_Delta_lambda < rb_sim_data.Delta_lambda
149 max_Delta_lambda = rb_sim_data.Delta_lambda
150 disp(['found for m = ',num2str(m)]);
153 disp('maximum error estimators:')
157 %%%% max_Delta_u = 0.0024 !!!!!
158 %%%% max_Delta_lambda = 0.0721 !!!!!!
159 % for parameter m = 256
162 disp('searching maximum rb error over train set')
165 K = model.get_inner_product_matrix(model,model_data);
167 model = set_mu(model,detailed_data.RB_info.mu_train(m,:));
168 rb_sim_data = rb_simulation(model,reduced_data);
169 rb_sim_data = rb_reconstruction(model,detailed_data,rb_sim_data);
170 sim_data = detailed_simulation(model,model_data);
171 err_u = sqrt((rb_sim_data.U-sim_data.U)' * K * (rb_sim_data.U- ...
173 L_R = K \ (rb_sim_data.L-sim_data.L);
174 err_lambda = sqrt((rb_sim_data.L-sim_data.L)' * L_R);
177 disp(['found for m = ',num2str(m)]);
179 if max_err_lambda < err_lambda
180 max_err_lambda = err_lambda
181 disp(['found for m = ',num2str(m)]);
184 disp('maximum rb errors:')
187 %%%%%%%% RESULT with standard quadprog options:
188 %%%% max_err_u = 0.0010 !!!!!
189 %%%% max_err_lambda = 0.0313 !!!!!!
190 % for parameter m = 256!!!
192 % NEW RESULTS with MaxIter=1000 as quadprog options :-) !!!
193 %max_err_u = 4.4909e-009
194 %max_err_lambda = 1.3476e-007
196 case 1.6 % check accuracy of rb-scheme for large Lagrange basis: 289 vectors
197 % IMPORTANT STEP HIGHLIGHTING ACCURACY PROBLEM
199 model.RB_numintervals = [16,16];
200 model.RB_generation_mode = 'pure_snapshots'; % no supr.
201 model.enable_error_estimator = 1;
202 % model.detailed_simulation = @my_new_detailed_simulation;
203 disp('generating Lagrange basis');
205 save('lagrange-basis-detailed-data','model','detailed_data');
207 reduced_data = gen_reduced_data(model,detailed_data);
209 K = model.get_inner_product_matrix(model,model_data);
211 model = set_mu(model,detailed_data.RB_info.mu_train(m,:));
212 rb_sim_data = rb_simulation(model,reduced_data);
213 rb_sim_data = rb_reconstruction(model,detailed_data,rb_sim_data);
214 sim_data = detailed_simulation(model,model_data);
215 err_u = sqrt((rb_sim_data.U-sim_data.U)' * K * (rb_sim_data.U- ...
217 L_R = K \ (rb_sim_data.L-sim_data.L);
218 err_lambda = sqrt((rb_sim_data.L-sim_data.L)' * L_R);
219 disp('rb errors for single nasty sample:')
222 %%%%%%%% RESULT for standard QUADPROG parameter:
223 %%%% max_err_u = 0.0010 !!!!!
224 %%%% max_err_lambda = 0.0313 !!!!!!
225 %%%%%%%% RESULT with maxiter = 1000:
226 % err_u = 5.2329e-013
227 % err_lambda = 1.0892e-011
228 % Very nice, but 5 seconds "reduced" computation time.
230 case 1.7 % generate coarse lagrange basis
232 model.RB_numintervals = [4,4];
233 model.RB_generation_mode = 'pure_snapshots'; % no supr.
234 model.enable_error_estimator = 1;
235 model.supremizer_enrichment = 0;
236 % model.detailed_simulation = @my_new_detailed_simulation;
237 disp('generating Lagrange basis');
239 save('lagrange-basis-5x5-no-supr-detailed-data','model','detailed_data');
240 model.supremizer_enrichment = 1;
241 save('lagrange-basis-5x5-with-supr-detailed-data','model','detailed_data');
243 case 2 % greedy basis generation for paper!
245 % model.RB_numintervals = [4,4]; % works perfect: N=25 exact representation
246 % model.RB_numintervals = [8,8];
247 model.RB_numintervals = [16,16];
248 % weights of error components
251 model.RB_stop_Nmax = 210;
252 model.RB_stop_epsilon = 1e-8;
253 model.supremizer_enrichment = 1; % on/off
256 % rb-estimator with W subbasis for dual reduced basis:
257 model.RB_generation_mode = 'greedy-rb-estimator';
258 model.supremizer_enrichment = 1; % on/off
259 model.enable_error_estimator = 1;
260 model.RB_stop_Nmax = 10; % 4 suffice here!
261 %model.RB_numintervals = [16,16];
263 model.dual_lin_independence_mode = 1; % use W subbasis
265 disp('--------------------------------------------------');
266 disp(model.RB_generation_mode);
268 save('greedy-rb-estimator-with-supr-detailed-data-lin-indep-1',...
269 'model','detailed_data');
270 max_err_sequence = detailed_data.RB_info.max_err_sequence;
271 plot(max_err_sequence);
272 set(gca,'Yscale','log');
273 title('greedy rb-estimator, with supr.-enrichment, lin-indep=1');
274 disp('press enter to continue');
275 plot_detailed_data(model,detailed_data,[]);
279 model.RB_generation_mode = 'greedy-rb-estimator';
280 model.dual_lin_independence_mode = 0; % use dual snapshots
281 model.supremizer_enrichment = 1; % on/off
282 model.enable_error_estimator = 1;
283 % model.RB_stop_Nmax = 300;
284 model.RB_stop_Nmax = 50;
285 disp('--------------------------------------------------');
286 disp(model.RB_generation_mode);
288 save('greedy-rb-estimator-with-supr-detailed-data-50',...
289 'model','detailed_data');
290 max_err_sequence = detailed_data.RB_info.max_err_sequence;
291 plot(max_err_sequence);
292 set(gca,'Yscale','log');
293 title('greedy rb-estimator convergence, with supr.-enrichment');
294 disp('press enter to continue');
295 plot_detailed_data(model,detailed_data,[]);
298 case 2.1 % greedy error convergence for different error indicators
300 % model.RB_numintervals = [4,4]; % works perfect: N=25 exact representation
301 % model.RB_numintervals = [8,8];
302 model.RB_numintervals = [16,16];
303 % weights of error components
306 model.RB_stop_Nmax = 210;
307 model.RB_stop_epsilon = 1e-8;
308 model.supremizer_enrichment = 1; % on/off
309 model.enable_error_estimator = 0;
310 model.dual_lin_independence_mode = 0; % use dual snapshots
311 % model.dual_lin_independence_mode = 1; % use W basis vectors
313 % model.RB_generation_mode = 'greedy-true-projection-error';
314 % disp('--------------------------------------------------');
315 % disp(model.RB_generation_mode);
318 % save('greedy-true-projection-error-detailed-data','model','detailed_data');
319 % max_err_sequence1 = detailed_data.RB_info.max_err_sequence;
320 % plot(max_err_sequence1);
321 % set(gca,'Yscale','log');
322 % title('greedy true projection error convergence');
323 % % plot_detailed_data(model,detailed_data,[]);
325 % disp('press enter to continue');
328 % rb-estimator with W subbasis for dual reduced basis:
329 model.RB_generation_mode = 'greedy-rb-estimator';
330 model.supremizer_enrichment = 1; % on/off
331 model.enable_error_estimator = 1;
332 model.RB_stop_Nmax = 20; % 4 suffice here!
333 model.RB_numintervals = [128,128];
334 model.dual_lin_independence_mode = 1; % use W subbasis
336 disp('--------------------------------------------------');
337 disp(model.RB_generation_mode);
339 save('greedy-rb-estimator-with-supr-detailed-data-lin-indep-1-128sqr',...
340 'model','detailed_data');
341 max_err_sequence7 = detailed_data.RB_info.max_err_sequence;
342 plot(max_err_sequence7);
343 set(gca,'Yscale','log');
344 title('greedy rb-estimator, with supr.-enrichment, lin-indep=1');
345 disp('press enter to continue');
346 plot_detailed_data(model,detailed_data,[]);
349 % rb-estimator with W subbasis for dual reduced basis:
350 model.RB_generation_mode = 'greedy-rb-estimator';
351 model.supremizer_enrichment = 1; % on/off
352 model.enable_error_estimator = 1;
353 model.RB_stop_Nmax = 10; % 4 suffice here!
354 model.RB_numintervals = [16,16];
356 model.dual_lin_independence_mode = 1; % use W subbasis
358 disp('--------------------------------------------------');
359 disp(model.RB_generation_mode);
361 save('greedy-rb-estimator-with-supr-detailed-data-lin-indep-1',...
362 'model','detailed_data');
363 max_err_sequence7 = detailed_data.RB_info.max_err_sequence;
364 plot(max_err_sequence7);
365 set(gca,'Yscale','log');
366 title('greedy rb-estimator, with supr.-enrichment, lin-indep=1');
367 disp('press enter to continue');
368 plot_detailed_data(model,detailed_data,[]);
371 % rb-estimator with W subbasis for dual reduced basis:
372 model.RB_generation_mode = 'greedy-rb-estimator';
373 model.supremizer_enrichment = 0; % on/off
374 model.enable_error_estimator = 1;
375 model.RB_stop_Nmax = 100; % must suffice here!
376 model.RB_numintervals = [16,16];
377 model.dual_lin_independence_mode = 1; % use W subbasis
379 disp('--------------------------------------------------');
380 disp(model.RB_generation_mode);
382 save('greedy-rb-estimator-no-supr-detailed-data-lin-indep-1',...
383 'model','detailed_data');
384 max_err_sequence7 = detailed_data.RB_info.max_err_sequence;
385 plot(max_err_sequence7);
386 set(gca,'Yscale','log');
387 title('greedy rb-estimator, no supr.-enrichment, lin-indep=1');
388 disp('press enter to continue');
389 plot_detailed_data(model,detailed_data,[]);
395 model.RB_numintervals = [16,16];
399 % rb-estimator with real large training data set
400 model.RB_generation_mode = 'greedy-rb-estimator';
401 model.supremizer_enrichment = 1; % on/off
402 model.enable_error_estimator = 1;
403 model.RB_stop_Nmax = 100; % 100 must suffice for now.
404 model.RB_numintervals = [128,128];
405 disp('--------------------------------------------------');
406 disp(model.RB_generation_mode);
408 save('greedy-rb-estimator-with-supr-detailed-data-128sqr_train',...
409 'model','detailed_data');
410 max_err_sequence7 = detailed_data.RB_info.max_err_sequence;
411 plot(max_err_sequence7);
412 set(gca,'Yscale','log');
413 title('greedy rb-estimator convergence, with supr.-enrichment');
414 disp('press enter to continue');
415 plot_detailed_data(model,detailed_data,[]);
418 model.RB_numintervals = [16,16];
420 model.RB_generation_mode = 'greedy-rb-estimator';
421 model.supremizer_enrichment = 1; % on/off
423 model.w_lambda = 0.01;
424 model.enable_error_estimator = 1;
425 model.RB_stop_Nmax = 50;
426 disp('--------------------------------------------------');
427 disp(model.RB_generation_mode);
429 save('greedy-rb-estimator-with-supr-detailed-data-50-w0p01',...
430 'model','detailed_data');
431 max_err_sequence = detailed_data.RB_info.max_err_sequence;
432 plot(max_err_sequence);
433 set(gca,'Yscale','log');
434 title('greedy rb-estimator convergence, with supr.-enrichment');
435 disp('press enter to continue');
436 plot_detailed_data(model,detailed_data,[]);
442 model.RB_generation_mode = 'greedy-rb-estimator';
443 model.supremizer_enrichment = 1; % on/off
444 model.enable_error_estimator = 1;
445 model.RB_stop_Nmax = 300;
446 disp('--------------------------------------------------');
447 disp(model.RB_generation_mode);
449 save('greedy-rb-estimator-with-supr-detailed-data-300',...
450 'model','detailed_data');
451 max_err_sequence7 = detailed_data.RB_info.max_err_sequence;
452 plot(max_err_sequence7);
453 set(gca,'Yscale','log');
454 title('greedy rb-estimator convergence, with supr.-enrichment');
455 disp('press enter to continue');
456 plot_detailed_data(model,detailed_data,[]);
459 % model.RB_generation_mode = 'greedy-rb-estimator';
460 % model.supremizer_enrichment = 1; % on/off
461 % model.enable_error_estimator = 1;
462 % model.RB_stop_Nmax = 210;
463 % disp('--------------------------------------------------');
464 % disp(model.RB_generation_mode);
466 % save('greedy-rb-estimator-with-supr-detailed-data','model','detailed_data');
467 % max_err_sequence4 = detailed_data.RB_info.max_err_sequence;
468 % plot(max_err_sequence4);
469 % set(gca,'Yscale','log');
470 % title('greedy rb-estimator convergence, supr.-enrichment');
471 % disp('press enter to continue');
472 % plot_detailed_data(model,detailed_data,[]);
475 % model.RB_generation_mode = 'greedy-rb-estimator';
476 % model.supremizer_enrichment = 0; % on/off
477 % model.RB_stop_Nmax = 210;
478 % disp('--------------------------------------------------');
479 % disp(model.RB_generation_mode);
481 % save('greedy-rb-estimator-no-supr-detailed-data','model','detailed_data');
482 % max_err_sequence1 = detailed_data.RB_info.max_err_sequence;
483 % plot(max_err_sequence1);
484 % set(gca,'Yscale','log');
485 % title('greedy rb-estimator convergence, no supr.-enrichment');
486 % disp('press enter to continue');
487 % plot_detailed_data(model,detailed_data,[]);
490 model.RB_generation_mode = 'greedy-rb-estimator';
491 model.supremizer_enrichment = 0; % on/off
492 model.RB_stop_Nmax = 300;
493 disp('--------------------------------------------------');
494 disp(model.RB_generation_mode);
496 save('greedy-rb-estimator-no-supr-detailed-data-300',...
497 'model','detailed_data');
498 max_err_sequence5 = detailed_data.RB_info.max_err_sequence;
499 plot(max_err_sequence5);
500 set(gca,'Yscale','log');
501 title('greedy rb-estimator convergence, no supr.-enrichment');
502 disp('press enter to continue');
503 plot_detailed_data(model,detailed_data,[]);
506 model.RB_generation_mode = 'greedy-true-rb-error';
507 model.supremizer_enrichment = 0; % on/off
508 model.RB_stop_Nmax = 210; % such that VN = V, WN = W;
509 disp('--------------------------------------------------');
510 disp(model.RB_generation_mode);
512 save('greedy-true-rb-error-no-supr-detailed-data','model','detailed_data');
513 max_err_sequence3 = detailed_data.RB_info.max_err_sequence;
514 plot(max_err_sequence3);
515 set(gca,'Yscale','log');
516 title('greedy true rb-error convergence, no supremizers');
517 % plot_detailed_data(model,detailed_data,[]);
518 disp('press enter to continue');
522 model.RB_generation_mode = 'greedy-true-rb-error';
523 model.supremizer_enrichment = 1; % on/off
524 model.RB_stop_Nmax = 210; % takes too
long for larger values
525 disp('--------------------------------------------------');
526 disp(model.RB_generation_mode);
528 save('greedy-true-rb-error-with-supr-detailed-data','model','detailed_data');
529 max_err_sequence2 = detailed_data.RB_info.max_err_sequence;
530 plot(max_err_sequence2);
531 set(gca,'Yscale','log');
532 title('greedy true rb-error convergence, supr.-enrichment');
533 disp('press enter to continue');
534 plot_detailed_data(model,detailed_data,[]);
538 % plot all convergence curves: non comparable!!!!!
541 % plot([max_err_sequence1;max_err_sequence3;max_err_sequence2;max_err_sequence4]')
542 % legend('true-projection-error','true-rb-error-wo-supr',...
543 % 'true-rb-error-with-supr',...
546 % plot([max_err_sequence3;max_err_sequence2;max_err_sequence4]')
547 % legend('true-rb-error-wo-supr',...
548 % 'true-rb-error-with-supr',...
549 % 'rb-estimator-with-supr');
552 % separate greedy: first u then lambda based on projection error
554 disp('please implement monotonicity check on lamdba before running!');
557 % model.RB_numintervals = [4,4]; % works perfect: N=25 exact representation
558 % model.RB_numintervals = [8,8];
560 model.RB_numintervals = [16,16];
561 % weights of error components
564 % model.RB_stop_Nmax = 100;
565 model.RB_stop_Nmax = 100;
566 model.RB_stop_epsilon = 1e-13; % very accurate!
567 model.supremizer_enrichment = 0; % on/off
568 model.enable_error_estimator = 0;
570 model.RB_generation_mode = 'separate-greedy';
571 disp('--------------------------------------------------');
572 disp(model.RB_generation_mode);
575 detailed_data = gen_detailed_data(model, model_data);
576 save('separate-greedy-detailed-data','model','detailed_data');
577 figure,plot(detailed_data.RB_info.max_u_err_sequence);
578 set(gca,'Yscale','log');
579 title('greedy u projection error convergence');
580 % plot_detailed_data(model,detailed_data,[]);
581 figure,plot(detailed_data.RB_info.max_lambda_err_sequence);
582 set(gca,'Yscale','log');
583 title('greedy lambda projection error convergence');
584 % plot_detailed_data(model,detailed_data,[]);
586 disp('press enter to continue');
590 case 3 % check all bases from 2!! interactive demo of mu distribution
592 % fn = 'greedy-true-rb-error-with-supr-detailed-data'; % N_V = 200, N_S = 210
593 % fn = 'greedy-true-rb-error-no-supr-detailed-data'; % N_V = 200, N_S = 210
594 %fn = 'greedy-rb-estimator-no-supr-detailed-data-300.mat'; % N_V = 200, N_S = 289
595 % fn = 'greedy-rb-estimator-with-supr-detailed-data'; % N_V = 200, N_S = 210
596 % fn = 'greedy-rb-estimator-with-supr-detailed-data-300';
597 % fn = 'separate-greedy-detailed-data'; % N_S = 100, N_V = 70;
598 % fn = 'greedy-rb-estimator-with-supr-detailed-data-300';
599 % fn = 'greedy-rb-estimator-with-supr-detailed-data-50-w0p01';
601 fn = 'greedy-rb-estimator-with-supr-detailed-data-lin-indep-1';
605 plot_detailed_data(model,detailed_data);
607 if isfield(detailed_data.RB_info,'mu_sequence');
608 mu_sequence = detailed_data.RB_info.mu_sequence;
609 inspect_mu_distribution(mu_sequence,model);
611 if isfield(detailed_data.RB_info,'mu_u_sequence');
612 mu_sequence = detailed_data.RB_info.mu_u_sequence;
613 inspect_mu_distribution(mu_sequence,model);
615 if isfield(detailed_data.RB_info,'mu_lambda_sequence');
616 mu_sequence = detailed_data.RB_info.mu_lambda_sequence;
617 inspect_mu_distribution(mu_sequence,model);
622 case 3.1 % investigate basis from 2
624 load('greedy-true-rb-error-detailed-data','model','detailed_data');
626 % detect duplicate lambda columns:
629 % compute gramian matrix of lambda snapshots
631 K = model.get_inner_product_matrix(model,model_data);
632 L = detailed_data.RB_L;
637 set(gca,'Yscale','log')
639 % about 60 dominant eigenvalues => 66 dimensional space should suffice
640 % but larger set to be expected.
642 case 3.2 % investigate greedy-separate basis from 2.1
644 % test error for maximum accuracy
645 % without supremizers (supremizers not sufficient for stabilita
646 % due to different snapshot sets.)
648 % is error comparable to train projection error?
650 % test rb-error: comparable to traing error?
652 case 4 % determine statistics of the different bases from 2
656 %fn = 'greedy-rb-estimator-with-supr-detailed-data-lin-indep-1';
657 %par.numintervals = [16,16]; % for training data
660 fn = 'greedy-rb-estimator-with-supr-detailed-data-50';
661 par.numintervals = [16,16]; % for training data
666 % fn='separate-greedy-detailed-data';
667 % par.numintervals = [16,16]; % for training data
668 % Ns = [1:50, 60,70,80];
671 % fn = 'greedy-rb-estimator-with-supr-detailed-data-300';
672 % par.numintervals = [16,16]; % for training data
673 % Ns = [1:50, 60:10:280, 289, 290:10:300];
675 % fn = 'lagrange-basis-5x5-with-supr-detailed-data';
676 % % 'lagrange-basis-5x5-no-supr-detailed-data'};
677 % par.numintervals = [4,4]; % for training data
679 % 'greedy-true-projection-error-detailed-data'
682 % fns = {
'greedy-rb-estimator-with-supr-detailed-data'};
683 %
'greedy-true-rb-error-no-supr-detailed-data',...
684 % fns = {
'lagrange-basis-detailed-data'};
685 %
'greedy-rb-estimator-no-supr-detailed-data',...
686 %
'greedy-true-rb-error-with-supr-detailed-data',...
688 % Desired statistics
for evaluation of basis:
689 % maximum train rb-error
for different basis sizes
690 % mean train rb-error
for different basis sizes + std
691 % maximum test rb-error
for different basis sizes
692 % mean test rb-error
for different basis sizes + std
693 % maximum train rb-error-estimator
for different basis sizes
694 % mean train rb-error-estimator
for different basis sizes + std
695 % maximum test rb-error-estimator
for different basis sizes
696 % mean test rb-error-estimator
for different basis sizes + std
697 % average online runtime
698 % tilde_N_V, N_V, N_S
699 % List of
Test-parameters
701 % generate train and test data
703 %
for rb-error on training-grid:
704 %par.numintervals = [16,16];
705 par.range = model.mu_ranges;
707 mu.train =
get(mu_mesh,
'vertex')
';
708 % for rb-error on test-grid:
709 par.numintervals = [32,32];
710 mu_mesh = cubegrid(par);
711 mu.test = get(mu_mesh,'vertex
')';
712 % mu_test = rand_uniform(ntest,model.mu_ranges);
714 modes = {
'test',
'train'};
715 error_indicators = {
'estimator',
'error'};
717 % initialize empty statistics fields of bases
if not existing
718 %
for fni = 1:length(fns)
720 clear(
'model',
'detailed_data');
722 if ~isfield(model,
'supremizer_enrichment')
723 model.supremizer_enrichment = 1;
725 if ~isfield(model,'dual_lin_independence_mode')
726 model.dual_lin_independence_mode = 0;
729 % computing rb sizes of ceil(Nfact*N_S), etc.
730 %Nfactors = [0:0.05:1]; % 21 sampling points should be fine
731 % compute Nfactors from desired N_S list:
732 if ~isfield(detailed_data,'L_no_post_processing')
733 N_S = size(detailed_data.RB_L,2);
734 Ns = Ns(find(Ns<=N_S));
741 % Nfactors = [0,0.5,1];
743 % nfact = length(Nfactors);
746 if ~isfield(detailed_data,'statistics')
747 % detailed_data.statistics.Nfactors = Nfactors;
748 detailed_data.statistics.Ns = Ns;
749 detailed_data.statistics.train.error.absolute.max = NaN * Ns;
750 detailed_data.statistics.train.error.absolute.mean = NaN * Ns;
751 detailed_data.statistics.train.error.absolute.std = NaN * Ns;
752 detailed_data.statistics.train.estimator.absolute.max = NaN * Ns;
753 detailed_data.statistics.train.estimator.absolute.mean = NaN * Ns;
754 detailed_data.statistics.train.estimator.absolute.std = NaN * Ns;
755 detailed_data.statistics.test.error.absolute.max = NaN * Ns;
756 detailed_data.statistics.test.error.absolute.mean = NaN * Ns;
757 detailed_data.statistics.test.error.absolute.std = NaN * Ns;
758 detailed_data.statistics.test.estimator.absolute.max = NaN * Ns;
759 detailed_data.statistics.test.estimator.absolute.mean = NaN * Ns;
760 detailed_data.statistics.test.estimator.absolute.std = NaN * Ns;
761 detailed_data.statistics.train.error.relative.max = NaN * Ns;
762 detailed_data.statistics.train.error.relative.mean = NaN * Ns;
763 detailed_data.statistics.train.error.relative.std = NaN * Ns;
764 detailed_data.statistics.train.estimator.relative.max = NaN * Ns;
765 detailed_data.statistics.train.estimator.relative.mean = NaN * Ns;
766 detailed_data.statistics.train.estimator.relative.std = NaN * Ns;
767 detailed_data.statistics.test.error.relative.max = NaN * Ns;
768 detailed_data.statistics.test.error.relative.mean = NaN * Ns;
769 detailed_data.statistics.test.error.relative.std = NaN * Ns;
770 detailed_data.statistics.test.estimator.relative.max = NaN * Ns;
771 detailed_data.statistics.test.estimator.relative.mean = NaN * Ns;
772 detailed_data.statistics.test.estimator.relative.std = NaN * Ns;
773 detailed_data.statistics.runtime.std = NaN * Ns;
774 detailed_data.statistics.runtime.mean = NaN * Ns;
775 detailed_data.statistics.tildeNV = NaN * Ns;
776 detailed_data.statistics.NV = NaN * Ns;
777 detailed_data.statistics.NS = NaN * Ns;
778 detailed_data.statistics.NW = NaN * Ns;
779 detailed_data.statistics.test.mu_sequence = mu.test ;
780 detailed_data.statistics.train.mu_sequence = mu.train ;
782 save(fn,'model','detailed_data');
785 % for all nfactors in bisecting order:
786 % for nfi = 1:length(Nfactors);
788 % for nfi = [21,1,10,5,15,3,7,13,18,2,4,6,8,9,11,12,14,16,17,19,20];
789 % for nfi = 1:length(Nfactors)
790 % Nfactor = Nfactors(nfi);
791 % disp(['Starting evaluation for Nfactor ',num2str(Nfactor)]);
793 disp(['Starting evaluation for N ',num2str(NS)]);
794 % for fni = 1:length(fns)
796 disp([
' Starting evaluation for file ',fn]);
798 K = model.get_inner_product_matrix(model,model_data);
800 for modei = 2:-1:1 % train / test
802 disp([
' Starting mode ',mode]);
803 disp(
' computing all snapshots');
804 mu_sequence = getfield(mu,mode); %
get train/test-sequence
805 nsamples = size(mu_sequence,2);
807 @compute_test_snapshots,model,model_data,mu_sequence);
810 % err_indicator = error_indicators{erri};
811 model.enable_error_estimator = 1;
812 % disp([
' Starting error indicator: ', ...
814 err_struct = getfield(...
815 detailed_data.statistics,mode);
817 if isnan(err_struct.error.absolute.mean(nfi)) %
if result not already existing
818 det_data = detailed_data;
819 if isfield(detailed_data,
'L_no_post_processing')
820 tildeNVmax = size(detailed_data.RB_U_no_supr,2);
821 NSmax = size(detailed_data.L_no_post_processing,2);
823 tildeNV = ceil(tildeNVmax*Nfactor);
824 % NS = ceil(NSmax*Nfactor);
825 U_no_supr = det_data.RB_U_no_supr(:,1:tildeNV);
826 elseif isfield(detailed_data,'RB_U_no_supr')
827 tildeNVmax = size(detailed_data.RB_U_no_supr,2);
828 NSmax = size(detailed_data.RB_L,2);
830 tildeNV = ceil(tildeNVmax*Nfactor);
831 % NS = ceil(NSmax*Nfactor);
832 U_no_supr = det_data.RB_U_no_supr(:,1:tildeNV);
834 tildeNVmax = size(detailed_data.RB_U,2);
835 NSmax = size(detailed_data.RB_L,2);
837 tildeNV = ceil(tildeNVmax*Nfactor);
838 % NS = ceil(NSmax*Nfactor);
839 U_no_supr = det_data.RB_U(:,1:tildeNV);
841 det_data.RB_L = det_data.RB_L(:,1:NS);
842 if model.dual_lin_independence_mode == 1
843 det_data.RB_L = det_data.L_no_post_processing(:,1:NS);
844 dual_speye = speye(size(det_data.RB_L,1));
845 L_dofs = find(max(abs(det_data.RB_L),[],2)>1e-11);
846 det_data.RB_L = full(dual_speye(:,L_dofs));
848 NW = size(det_data.RB_L,2);
849 if model.supremizer_enrichment
850 det_data.RB_U = improve_conditioning(...
851 [U_no_supr,K\det_data.RB_L],K);
852 NV = size(det_data.RB_U,2);
853 else % no supr.-enrichment
854 det_data.RB_U = improve_conditioning(U_no_supr,K);
857 reduced_data = gen_reduced_data(model,det_data);
858 err_us = zeros(1,nsamples);
859 err_lambdas = zeros(1,nsamples);
860 delta_us = zeros(1,nsamples);
861 delta_lambdas = zeros(1,nsamples);
862 norm_us = zeros(1,nsamples);
863 norm_lambdas = zeros(1,nsamples);
864 runtimes = zeros(1,nsamples);
868 model = model.set_mu(model,mu_sequence(:,mui));
869 rb_sim_data = rb_simulation(model,reduced_data);
870 rb_sim_data = rb_reconstruction(model,det_data,rb_sim_data);
871 err_us(mui) = sqrt((rb_sim_data.U-Utest(:,mui))'*K*...
872 (rb_sim_data.U-Utest(:,mui)));
873 err_lambdas(mui) = sqrt((rb_sim_data.L-Ltest(:,mui))'*(K\ ...
876 norm_us(mui) = sqrt(Utest(:,mui)'*K*Utest(:,mui));
877 norm_lambdas(mui) = sqrt(Ltest(:,mui)'*(K\Ltest(:,mui)));
878 delta_us(mui) = rb_sim_data.Delta_u;
879 delta_lambdas(mui) = rb_sim_data.Delta_lambda;
880 % if delta_lambdas(mui)<err_lambdas(mui)
881 % disp('check accuracy!');
884 % if delta_us(mui)<err_us(mui)
885 % disp('check accuracy!');
891 % compute relative errors
893 rel_delta_us = delta_us;
894 i = find(norm_us~=0);
896 rel_err_us(i) = err_us(i).*(norm_us(i).^-1);
897 rel_delta_us(i) = delta_us(i).*(norm_us(i).^-1);
899 i = find(norm_us==0);
902 rel_delta_us(i) = NaN;
905 rel_err_lambdas = err_lambdas;
906 rel_delta_lambdas = delta_lambdas;
907 i = find(norm_lambdas~=0);
909 rel_err_lambdas(i) = err_lambdas(i).*(norm_lambdas(i).^-1);
910 rel_delta_lambdas(i) = delta_lambdas(i).*(norm_lambdas(i).^-1);
912 i = find(norm_lambdas==0);
914 rel_err_lambdas(i) = NaN;
915 rel_delta_lambdas(i) = NaN;
918 err_struct.error.absolute.max(nfi) = max(err_us + err_lambdas);
919 err_struct.error.absolute.mean(nfi) = mean(err_us + err_lambdas);
920 err_struct.error.absolute.std(nfi) = std(err_us + err_lambdas);
921 err_struct.error.relative.max(nfi) = max(rel_err_us + rel_err_lambdas);
922 err_struct.error.relative.mean(nfi) = max(rel_err_us + rel_err_lambdas);
923 err_struct.error.relative.std(nfi) = std(rel_err_us + rel_err_lambdas);
925 err_struct.estimator.absolute.max(nfi) = max(delta_us + delta_lambdas);
926 err_struct.estimator.absolute.mean(nfi) = mean(delta_us + delta_lambdas);
927 err_struct.estimator.absolute.std(nfi) = std(delta_us + delta_lambdas);
928 err_struct.estimator.relative.max(nfi) = max(rel_delta_us + rel_delta_lambdas);
929 err_struct.estimator.relative.mean(nfi) = mean(rel_delta_us + rel_delta_lambdas);
930 err_struct.estimator.relative.std(nfi) = std(rel_delta_us + rel_delta_lambdas);
932 detailed_data.statistics.tildeNV(nfi) = tildeNV;
933 detailed_data.statistics.NV(nfi) = NV;
934 detailed_data.statistics.NW(nfi) = NW;
935 detailed_data.statistics.NS(nfi) = NS;
937 detailed_data.statistics.runtime.mean(nfi) = mean(runtimes);
938 detailed_data.statistics.runtime.std(nfi) = std(runtimes);
940 eval(['detailed_data.statistics.',mode,' = err_struct;']);
941 % disp('check correct setting of detailed_data');
944 save(fn,'model','detailed_data');
945 end; % if result not already existing
950 case 5 % plots of different statistics from case 4
952 fn = 'greedy-rb-estimator-with-supr-detailed-data-lin-indep-1';
954 stat = detailed_data.statistics
955 p1 = plot(stat.NS,stat.train.error.absolute.max,'ko');
957 p2 = plot(stat.NS,stat.train.estimator.absolute.max,'b*');
958 % p3 = plot(detailed_data.RB_info.max_err_sequence);
959 legend({
'error',
'estimator'});
960 xlabel(
'cone spanning elements');
962 title(
'training set error/estimator convergence');
963 set(gca,
'Yscale',
'log');
967 fn =
'greedy-rb-estimator-with-supr-detailed-data-lin-indep-1';
969 stat = detailed_data.statistics
970 p1 = plot(stat.NS,stat.test.error.absolute.max,
'ko');
972 p2 = plot(stat.NS,stat.test.estimator.absolute.max,
'b*');
973 legend({
'error',
'estimator'});
974 xlabel(
'cone spanning elements');
976 title(
'test set error/estimator convergence');
977 set(gca,
'Yscale',
'log');
981 % separate greedy basis
985 fn =
'separate-greedy-detailed-data';
987 stat = detailed_data.statistics
988 p1 = plot(stat.NS,stat.train.error.absolute.max,
'ko');
990 p2 = plot(stat.NS,stat.train.estimator.absolute.max,
'b*');
991 % p3 = plot(detailed_data.RB_info.max_err_sequence);
992 legend({
'error',
'estimator'});
993 xlabel(
'cone spanning elements N_S');
995 title(
'training set error/estimator convergence');
996 set(gca,
'Yscale',
'log');
1000 fn =
'separate-greedy-detailed-data';
1002 stat = detailed_data.statistics
1003 p1 = plot(stat.NS,stat.test.error.absolute.max,
'ko');
1005 p2 = plot(stat.NS,stat.test.estimator.absolute.max,
'b*');
1006 legend({
'error',
'estimator'});
1007 xlabel(
'cone spanning elements N_S');
1009 title(
'test set error/estimator convergence');
1010 set(gca,
'Yscale',
'log');
1015 % PLOTS FOR PAPER!!!
1019 fn =
'greedy-rb-estimator-with-supr-detailed-data-50';
1020 % fn =
'greedy-rb-estimator-with-supr-detailed-data-300';
1022 stat = detailed_data.statistics
1023 p1 = plot(stat.NS(1:50),stat.test.error.absolute.max(1:50),
'-b+');
1024 set(p1,
'Markersize',10);
1026 p2 = plot(stat.NS(1:50),stat.train.error.absolute.max(1:50),
'-.g*');
1027 set(p2,
'Color',[0,0.5,0],
'Linewidth',2,
'Markersize',10);
1028 set(gca,
'Fontsize',15);
1029 legend({
'test-error',
'train-error'},
'Fontsize',20);
1030 xlabel(
'N_W',
'Fontsize',20);
1031 ylabel(
'accuracy',
'Fontsize',20);
1032 title(
'test/train error convergence, W_N^{(1)}',
'Fontsize',20);
1033 set(gca,
'Yscale',
'log');
1034 set(gca,
'Ylim',[0.02,2]);
1035 % set(gca,
'Yticklabel',[
'1e-01';
'1e-00']);
1036 % set(gca,
'Xticklabel',[
' 0';
' ';
'10';
' ';
'20';
' ';
'30';
' ';
'40';
' ';
'50']);
1037 % saveas(gcf,
'greedy-test-train-error-WN1-new.eps',
'epsc');
1038 saveas(gcf,
'greedy-test-train-error-WN1-newest.eps',
'epsc');
1040 % plot of better basis
1042 fn =
'greedy-rb-estimator-with-supr-detailed-data-lin-indep-1';
1044 stat = detailed_data.statistics
1045 p1 = plot(stat.NW(1:4),stat.test.error.absolute.max(1:4),
'-b+');
1046 set(p1,
'Markersize',10);
1048 p2 = plot(stat.NW(1:4),stat.train.error.absolute.max(1:4),
'-.g*');
1049 set(p2,
'Color',[0,0.5,0],
'Linewidth',2,
'Markersize',10);
1050 set(gca,
'Fontsize',15);
1051 legend({
'test-error',
'train-error'},
'Location',
'SouthWest',...
1053 xlabel(
'N_W',
'Fontsize',20);
1054 ylabel(
'accuracy',
'Fontsize',20);
1055 title(
'test/train error convergence, W_N^{(2)}',
'Fontsize',20);
1056 set(gca,
'Yscale',
'log');
1057 set(gca,
'Xlim',[10,60]);
1058 set(gca,
'Ylim',[1e-14,11]);
1059 % set(gca,
'Xticklabel',...
1060 % [
'10';
' ';
'20';
' ';
'30';
' ';
'40';
' ';
'50';
' ';
'60']);
1061 % set(gca,
'Yticklabel',...
1062 % [
'1e-14';
'1e-12';
'1e-10';
'1e-08';
'1e-06';
'1e-04';
'1e-02';
'1e-00']);
1063 % saveas(gcf,
'greedy-test-train-error-WN2-new.eps',
'epsc');
1064 saveas(gcf,
'greedy-test-train-error-WN2-newest.eps',
'epsc');
1066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
1070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
1074 % plot of maximum training rb-error and estimator over dimension N
1075 %
for rb-estimator-wo-supr-300
1076 % plot of maximum test rb-error and estimator over online-runtime
1077 %
for rb-estimator-wo-supr-300
1079 disp(
'rb-estimator-greedy-with-supr-300: train and test error decay:')
1082 fn =
'greedy-rb-estimator-with-supr-detailed-data-300';
1084 stat = detailed_data.statistics
1085 p1 = plot(stat.NS,stat.train.error.absolute.max,
'ko');
1087 p2 = plot(stat.NS,stat.train.estimator.absolute.max,
'b*');
1088 p3 = plot(detailed_data.RB_info.max_err_sequence);
1089 legend({
'error',
'estimator',
'estimator'});
1090 xlabel(
'cone spanning elements N_S');
1092 title(
'training set error/estimator convergence');
1093 set(gca,
'Yscale',
'log');
1097 fn =
'greedy-rb-estimator-with-supr-detailed-data-300';
1099 stat = detailed_data.statistics
1100 p1 = plot(stat.NS,stat.test.error.absolute.max,
'ko');
1102 p2 = plot(stat.NS,stat.test.estimator.absolute.max,
'b*');
1103 legend({
'error',
'estimator'});
1104 xlabel(
'cone spanning elements N_S');
1106 title(
'test set error/estimator convergence');
1107 set(gca,
'Yscale',
'log');
1110 disp(
'enter dbcont for continuing');
1113 % => bad news: slow convergence and non-monotonocity...
1114 % => good news: error and estimator quite close!!
1115 % => good message: train error comparable to test error
1117 disp(
'Lagrange basis 5x5: nice training error, bad test error decay')
1119 fn = 'lagrange-basis-5x5-with-supr-detailed-data';
1120 % 'lagrange-basis-5x5-no-supr-detailed-data'};
1122 % fn = 'greedy-rb-estimator-no-supr-detailed-data-300';
1124 stat = detailed_data.statistics
1125 p1 = plot(stat.NS,stat.train.error.max,'ko');
1127 p2 = plot(stat.NS,stat.train.estimator.max,'b*');
1128 % p3 = plot(detailed_data.RB_info.max_err_sequence);
1129 legend({
'error',
'estimator'});
1130 xlabel(
'cone spanning elements N_S');
1132 title(
'lagrange basis 5x5 training set error/estimator convergence');
1133 set(gca,
'Yscale',
'log');
1137 % fn =
'greedy-rb-estimator-no-supr-detailed-data-300';
1139 stat = detailed_data.statistics
1140 p1 = plot(stat.NS,stat.test.error.max,
'ko');
1142 p2 = plot(stat.NS,stat.test.estimator.max,
'b*');
1143 legend({
'error',
'estimator'});
1144 xlabel(
'cone spanning elements N_S');
1146 title(
'lagrange basis 5x5 test set error/estimator convergence');
1147 set(gca,
'Yscale',
'log');
1149 disp(
'enter dbcont for continuing');
1152 % comparison of different lagrange basis sizes
1154 fn =
'lagrange-basis-5x5-with-supr-detailed-data';
1155 %
'lagrange-basis-5x5-no-supr-detailed-data'};
1157 % fn =
'greedy-rb-estimator-no-supr-detailed-data-300';
1159 stat = detailed_data.statistics
1160 p1 = plot(stat.NS,stat.test.error.max,
'ko');
1162 p2 = plot(stat.NS,stat.test.estimator.max,
'k*');
1163 fn =
'lagrange-basis-detailed-data';
1164 % fn =
'greedy-rb-estimator-no-supr-detailed-data-300';
1166 stat = detailed_data.statistics
1167 p1 = plot(stat.NS,stat.test.error.max,
'ko');
1169 p2 = plot(stat.NS,stat.test.estimator.max,
'k*');
1170 % p3 = plot(detailed_data.RB_info.max_err_sequence);
1171 legend({
'error, 5x5',
'estimator 5x5',
'error 17x17',
'estimator 17x17'});
1172 xlabel(
'cone spanning elements N_S');
1174 title(
'lagrange-bases: test set error/estimator convergence');
1175 set(gca,
'Yscale',
'log');
1177 % plot of train rb-estimator with and without supremizers o. online-runtime
1178 % plot of test rb-estimator with and without supremizers over online-runtime
1182 % plot of train rb-estimator
for greedy-rb-estim and
1183 % greedy-rb-error wo supr over online-runtime
1184 % plot of test rb-estimator
for greedy-rb-estim and
1185 % greedy-rb-error wo supr over online-runtime
1189 % plot of training rb-error
for separate greedy basis
1190 % plot of test rb-error
for separate greedy basis
1196 % set(gca,
'Yscale',
'log')
1197 % title([
'rb-error decay on n=',num2str(ntest),
' gridpoints']);
1200 % good news: rb_error estimator yields quite good rb-error
1201 % even better than greedy-proj-error approach!!!
1203 case 10 % interactive demo of reduced simulation
1207 fn =
'greedy-rb-estimator-with-supr-detailed-data-50';
1208 % fn =
'greedy-rb-estimator-detailed-data';
1210 % model = elastic_rope_model;
1211 model.enable_error_estimator = 0;
1212 % model.enable_error
1213 params.plot_title =
'elastic rope';
1214 params.no_lines = 0;
1215 params.axis_equal = 0;
1216 params.axis_tight = 1;
1217 params.solution_component =
'u';
1218 % params.solution_component =
'lambda';
1222 case 11 % interactive demo of detailed simulation
1224 % fn =
'greedy-rb-estimator-detailed-data';
1226 detailed_data = gen_model_data(model);
1227 detailed_data.RB_U = [];
1228 detailed_data.RB_lambda = [];
1229 params.plot_title =
'elastic rope';
1230 params.no_lines = 0;
1231 params.axis_equal = 0;
1232 params.axis_tight = 1;
1233 params.solution_component =
'u';
1234 % params.solution_component =
'lambda';
1237 case 12 % interactive demo
for error in u or lambda:
1238 fn =
'greedy-rb-estimator-detailed-data';
1240 params.plot_title =
'elastic rope';
1241 params.no_lines = 0;
1242 params.axis_equal = 0;
1243 params.axis_tight = 1;
1247 % params.solution_component =
'u';
1248 % model.set_dofs_in_sim_data = @my_set_u_dofs_in_sim_data;
1250 % select here, whether u or lambda is to be visualized
1251 params.solution_component =
'lambda';
1252 model.set_dofs_in_sim_data = @my_set_lambda_dofs_in_sim_data;
1253 model.get_dofs_from_sim_data = @my_get_lambda_dofs_from_sim_data;
1256 case 13 % debugging of detailed solver
1258 model = elastic_rope_model;
1259 model.xnumintervals = 202;
1260 model = set_mu(model,[0.075, 0.4])
1261 % detailed simulation and plot
1262 model_data = gen_model_data(model);
1263 disp(
'begin detailed simulation');
1264 sim_data = detailed_simulation(model,model_data);
1265 disp(
'plotting ...');
1266 plot_params.plot_title =
'detailed solution & obstacle';
1267 % plot_params.solution_component =
'lambda';
1269 save(
'debug_rope.mat',
'sim_data',
'model');
1275 julien.A = A(2:200,2:200);
1277 julien.B = B(2:200,2:200);
1279 julien.f = f(2:200);
1281 julien.g = g(2:200);
1283 julien.u = U(2:200);
1285 julien.lambda = Lambda(2:200);
1287 load debug_rope.mat;
1291 case 15 % CPOD Basis generation
1293 % model.RB_numintervals = [16,16];
1294 % % weights of error components
1296 % model.w_lambda = 1;
1297 %% model.RB_stop_Nmax = 210;
1298 % model.RB_stop_epsilon = 1e-8;
1299 % model.supremizer_enrichment = 1; % on/off
1301 % model.RB_generation_mode =
'greedy-true-rb-error';
1302 % model.supremizer_enrichment = 1; % on/off
1303 % model.enable_error_estimator = 0;
1304 % model.RB_stop_Nmax = 10; % 4 suffice here!
1306 % %model.RB_numintervals = [16,16];
1308 % model.dual_lin_independence_mode = 1; % use W subbasis, i.e. WN^(2)
1310 % disp(
'--------------------------------------------------');
1311 % disp(model.RB_generation_mode);
1313 % save(
'greedy-rb-estimator-with-supr-detailed-data-lin-indep-1',...
1314 %
'model',
'detailed_data');
1315 % max_err_sequence = detailed_data.RB_info.max_err_sequence;
1316 % plot(max_err_sequence);
1317 % set(gca,
'Yscale',
'log');
1318 % title(
'greedy rb-error, with supr.-enrichment, lin-indep=1');
1319 % disp(
'press enter to continue');
1320 % plot_detailed_data(model,detailed_data,[]);
1323 model.RB_generation_mode =
'CPOD_space_projection_error';
1326 %
for n = 1:length(NWs);
1327 model.RB_numintervals = [16,16];
1329 model.RB_stop_Nmax = NW;
1330 model.supremizer_enrichment = 1; % on/off
1331 model.dummy = rand(1);
1333 disp(
'--------------------------------------------------');
1334 disp(model.RB_generation_mode);
1336 save(
'CPOD-space-projection-with-supr-detailed-data',...
1337 'model',
'detailed_data');
1338 max_err_sequence = detailed_data.RB_info.max_err_sequence;
1339 plot(max_err_sequence);
1340 set(gca,
'Yscale',
'log');
1341 title(
'CPOD-space-projection, with supr.-enrichment');
1342 disp(
'press enter to continue');
1343 plot_detailed_data(model,detailed_data,[]);
1347 error(
'step unknown')
1350 % later: check projection-greedy basis and determine maximum RB
1351 % error => what factor?
1352 function sim_data = my_set_u_dofs_in_sim_data(sim_data,dofs)
1354 function sim_data = my_set_lambda_dofs_in_sim_data(sim_data,dofs)
1356 function dofs = my_get_lambda_dofs_from_sim_data(sim_data)
1359 function [Utest,Ltest] = compute_test_snapshots(model,model_data,mu_test);
1360 ntest = size(mu_test,2);
1361 Utest = zeros(length(model_data.grid.X)-2,0);
1362 Ltest = zeros(length(model_data.grid.X)-2,0);
1365 model = model.set_mu(model,mu_test(:,mui));
1366 sim_data = detailed_simulation(model,model_data);
1367 Utest = [Utest,sim_data.U];
1368 Ltest = [Ltest,sim_data.L];
function demo_rb_error_gui(varargin)
demo gui for detailed simulations and reduced simulation and plotting the error
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.
A hierarchical cubegrid of arbitrary dimension.
function demo_rb_gui(varargin)
reduced basis demo with sliders
Test reduced basis implementation.
function demo_detailed_gui(varargin)
demo gui for detailed simulations (calling demo_rb_gui after switching some pointers) ...
function p = plot_sim_data(model, model_data, sim_data, plot_params)
function performing the plot of the simulation results as specified in model.
function demo_vi()
function testing the implementation of the RB-Method for Parametrized Variational Inequalities...