1 % small script demonstrating RB-approach for the fuelcell-gdl with
2 % the simtech image initial data
4 % Bernard Haasdonk 24.5.2008
6 %step = 1; % single simulation
7 %step = 2; % dummy reduced basis & comparison of reduced to detailed simulation
8 %step = 3; % real reduced basis generation and store as detailed_data
9 %step = 4; % time comparison
11 detailedfname =
'simtech_detailed.mat';
13 load demo_lin_evol_params;
14 params.RB_generation_mode =
'uniform_fixed';
15 params.RB_numintervals = [10 4 4];
16 params.mu_names ={
'c_init' 'beta' 'k'};
17 params.mu_ranges ={[0 1] [0 1] [0 5.0000e-008]};
20 %params.name_convective_num_flux =
'enquist_osher';
22 params.name_init_values =
'grey_image';
23 params.c_init_filename =
'simtech_binary.bmp';
26 params.c_init_xmin = params.xrange(1);
27 params.c_init_xmax = params.xrange(2);
28 params.c_init_ymin = params.yrange(1);
29 params.c_init_ymax = params.yrange(2);
30 params.c_init_xdivisions = (0.1:0.1:1.0) *...
31 (params.xrange(2)-params.xrange(1));
35 params.name_convective_num_flux =
'engquist-osher';
37 grid = construct_grid(params);
38 %params.lxf_lambda = 1.0194e+003;
39 %fv_search_max_lxf_lambda([],params);
40 params.nt = params.nt;
44 params.axis_equal = 1;
47 detailed_data.grid = grid;
51 disp(
'performing single detailed simulation')
52 U = detailed_simulation(detailed_data.grid, params);
53 plot_element_data_sequence(detailed_data.grid,U,params);
54 case 2 % construct dummy reduced basis by single trajectory and simulate
55 U = detailed_simulation(detailed_data.grid,params);
56 A = feval(params.inner_product_matrix_algorithm,detailed_data.grid,params);
57 UON = orthonormalize(U,A);
58 detailed_data.RB = UON;
59 disp('reduced simulation:')
60 offline_data = rb_offline_prep(detailed_data,params);
61 params.N = size(detailed_data.RB,2);
62 reduced_data = rb_online_prep(offline_data, params);
63 simulation_data = rb_simulation(reduced_data,params);
64 Uappr = rb_reconstruction(detailed_data,simulation_data);
66 params.title = 'reduced simulation result';
67 plot_element_data_sequence(detailed_data.grid,Uappr,params);
68 params.title = 'detailed simulation result';
69 plot_element_data_sequence(detailed_data.grid,U,params);
70 case 3 % generate good reduced basis
71 disp('constructing reduced basis')
74 save(fullfile(rbmatlabresult,detailedfname),...
75 'detailed_data','params');
76 plot(detailed_data.RB_info.max_err_sequence);
77 set(gca,'Yscale','log');
78 title('RB-generation error convergence');
81 load(fullfile(rbmatlabresult,detailedfname));
82 disp('reduced simulation:')
83 offline_data = rb_offline_prep(detailed_data,params);
84 params.N = size(detailed_data.RB,2);
86 reduced_data = rb_online_prep(offline_data, params);
88 simulation_data = rb_simulation(reduced_data,params);
90 disp(['time for online phase: t = ',num2str(t)]);
92 disp('full simulation:')
94 U = detailed_simulation(detailed_data.grid, params);
96 disp(['time for detailed simulation: t = ',num2str(t)]);
99 load(fullfile(rbmatlabresult,detailedfname));
102 error('step number unknown!');
109 % TO BE ADJUSTED TO NEW SYNTAX