1 % small script demonstrating RB-approach for the fuelcell-gdl with
2 % the MoRePaS09 initial data, i.e. Logo for the Workshop
3 % Model Reduction of Parametrized Systems
5 % Bernard Haasdonk 24.5.2008
7 %step = 1; % single simulation
8 %step = 2; % dummy reduced basis & comparison of reduced to detailed simulation
9 %step = 3; % real reduced basis generation and store as detailed_data
10 %step = 4; % time comparison
12 step = 6; % export some pictures
13 %detailedfname =
'simtech_detailed.mat';
14 detailedfname =
'MoRePaS09_detailed.mat';
16 load demo_lin_evol_params;
17 params.RB_generation_mode:
'uniform_fixed'
18 params.RB_numintervals = [10 4 4];
19 params.mu_names ={
'c_init' 'beta' 'k'};
20 params.mu_ranges ={[0 1] [0 1] [0 5.0000e-008]}
23 %params.name_convective_num_flux =
'enquist_osher';
25 params.name_init_values =
'grey_image';
26 %params.c_init_filename =
'simtech_binary.bmp';
27 params.c_init_filename =
'MoRePaS09_binary.bmp';
30 params.c_init_xmin = params.xrange(1);
31 params.c_init_xmax = params.xrange(2);
32 params.c_init_ymin = params.yrange(1);
33 params.c_init_ymax = params.yrange(2);
34 params.c_init_xdivisions = (0.1:0.1:1.0) *...
35 (params.xrange(2)-params.xrange(1));
39 params.name_convective_num_flux =
'engquist-osher';
41 grid = construct_grid(params);
42 %params.lxf_lambda = 1.0194e+003;
43 %fv_search_max_lxf_lambda([],params);
44 params.nt = params.nt;
48 params.axis_equal = 1;
51 detailed_data.grid = grid;
55 disp(
'performing single detailed simulation')
56 U = detailed_simulation(detailed_data.grid, params);
57 plot_element_data_sequence(detailed_data.grid,U,params);
58 case 2 % construct dummy reduced basis by single trajectory and simulate
59 U = detailed_simulation(detailed_data.grid,params);
60 A = feval(params.inner_product_matrix_algorithm,detailed_data.grid,params);
61 UON = orthonormalize(U,A);
62 detailed_data.RB = UON;
63 disp('reduced simulation:')
64 offline_data = rb_offline_prep(detailed_data,params);
65 params.N = size(detailed_data.RB,2);
66 reduced_data = rb_online_prep(offline_data, params);
67 simulation_data = rb_simulation(reduced_data,params);
68 Uappr = rb_reconstruction(detailed_data,simulation_data);
70 params.title = 'reduced simulation result';
71 plot_element_data_sequence(detailed_data.grid,Uappr,params);
72 params.title = 'detailed simulation result';
73 plot_element_data_sequence(detailed_data.grid,U,params);
74 case 3 % generate good reduced basis
75 disp('constructing reduced basis')
78 save(fullfile(rbmatlabresult,detailedfname),...
79 'detailed_data','params');
80 plot(detailed_data.RB_info.max_err_sequence);
81 set(gca,'Yscale','log');
82 title('RB-generation error convergence');
85 load(fullfile(rbmatlabresult,detailedfname));
86 disp('reduced simulation:')
87 offline_data = rb_offline_prep(detailed_data,params);
88 params.N = size(detailed_data.RB,2);
90 reduced_data = rb_online_prep(offline_data, params);
92 simulation_data = rb_simulation(reduced_data,params);
94 disp(['time for online phase: t = ',num2str(t)]);
96 disp('full simulation:')
98 U = detailed_simulation(detailed_data.grid, params);
100 disp(['time for detailed simulation: t = ',num2str(t)]);
103 load(fullfile(rbmatlabresult,detailedfname));
107 disp('performing single detailed simulation')
108 U = detailed_simulation(detailed_data.grid, params);
112 slices = [1, 26, 51, 76, 101, 126,151,176,201];
113 colormaps = {h(end:-1:1,:)};
115 % colormaps = {h(end:-1:1,:),h,p,p(end:-1:1,:),jet(256)};
116 for s=1:length(slices)
117 for cm = 1:length(colormaps)
118 params.show_colorbar=0;
119 plot_element_data(grid,U(:,slices(s)),params);
120 colormap(colormaps{cm});
121 % a = reshape(U(:,slices(s)),200,40)
';
122 % a = uint8(a(end:-1:1,:)*255);
123 % imshow(a,colormaps{cm});
124 set(gca,'XTickLabel
',{})
125 set(gca,'YTickLabel
',{})
126 saveas(gca,['MoRePaS09_logo_t
',num2str(slices(s)),'_col
',num2str(cm)],...
133 error('step number unknown!
');
140 % TO BE ADJUSTED TO NEW SYNTAX