rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
MoRePaS09_fuelcell_gdl.m
Go to the documentation of this file.
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
4 
5 % Bernard Haasdonk 24.5.2008
6 
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
11 %step = 5; % demo_rb_gui with modified fuel cell
12 step = 6; % export some pictures
13 %detailedfname = 'simtech_detailed.mat';
14 detailedfname = 'MoRePaS09_detailed.mat';
15 
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]}
21 
22 % display params
23 %params.name_convective_num_flux = 'enquist_osher';
24 
25 params.name_init_values = 'grey_image';
26 %params.c_init_filename = 'simtech_binary.bmp';
27 params.c_init_filename = 'MoRePaS09_binary.bmp';
28 %params.c_init = 0.0;
29 params.c_init = 1.0;
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));
36 
37 params.k = 0;
38 
39 params.name_convective_num_flux = 'engquist-osher';
40 
41 grid = construct_grid(params);
42 %params.lxf_lambda = 1.0194e+003;
43 %fv_search_max_lxf_lambda([],params);
44 params.nt = params.nt;
45 
46 % output settings
47 params.verbose = 10;
48 params.axis_equal = 1;
49 params.clim = [0,1];
50 
51 detailed_data.grid = grid;
52 
53 switch step
54  case 1
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);
69 
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')
76  detailed_data = rb_basis_generation(detailed_data, ...
77  params);
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');
83 
84  case 4
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);
89  params.k = 0.0001;
90  reduced_data = rb_online_prep(offline_data, params);
91  tic;
92  simulation_data = rb_simulation(reduced_data,params);
93  t = toc;
94  disp(['time for online phase: t = ',num2str(t)]);
95 
96  disp('full simulation:')
97  tic;
98  U = detailed_simulation(detailed_data.grid, params);
99  t = toc;
100  disp(['time for detailed simulation: t = ',num2str(t)]);
101 
102  case 5
103  load(fullfile(rbmatlabresult,detailedfname));
104  demo_rb_gui(detailed_data,[],params);
105  case 6
106  %save image series
107  disp('performing single detailed simulation')
108  U = detailed_simulation(detailed_data.grid, params);
109  % slice 26 is good
110  h = hot(256);
111  p = pink(256);
112  slices = [1, 26, 51, 76, 101, 126,151,176,201];
113  colormaps = {h(end:-1:1,:)};
114 % slices = [26];
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)],...
127  'epsc2')
128  close(gcf);
129 % keyboard;
130  end;
131  end;
132  otherwise
133  error('step number unknown!');
134 end;
135 
136 
137 return;
138 
139 
140 % TO BE ADJUSTED TO NEW SYNTAX
141 %| \docupdate