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
12 %load demo_lin_evol_params;
14 model.detailedfname =
'ulm_detailed.mat';
15 model.RB_generation_mode =
'greedy_uniform_fixed';
16 model.RB_numintervals = [10 4 4];
17 model.mu_names ={
'c_init' 'beta' 'k'};
18 model.mu_ranges ={[0 1] [0 1] [0 5.0000e-008]};
19 model.RB_stop_Nmax = 100;
22 %params.name_convective_num_flux =
'enquist_osher';
24 model.init_values_ptr = @init_values_grey_image;
25 %model.name_init_values =
'grey_image';
26 %model.c_init_filename =
'simtech_binary.bmp';
27 model.c_init_filename =
'uulm_grey_inv_scaled_resized.bmp';
30 model.c_init_xmin = model.xrange(1);
31 model.c_init_xmax = model.xrange(2);
32 model.c_init_ymin = model.yrange(1);
33 model.c_init_ymax = model.yrange(2);
34 model.c_init_xdivisions = (0.1:0.1:1.0) *...
35 (model.xrange(2)-model.xrange(1));
41 %grid = construct_grid(model);
42 %params.lxf_lambda = 1.0194e+003;
43 %fv_search_max_lxf_lambda([],model);
52 model_data = gen_model_data(model);
54 %detailed_data.grid = grid;
58 disp(
'performing single detailed simulation')
59 sim_data = detailed_simulation(model, model_data);
61 % plot_element_data_sequence(detailed_data.grid,U,model);
62 case 2 % construct dummy reduced basis by single trajectory and simulate
63 U = detailed_simulation(detailed_data.grid,model);
64 A = feval(model.inner_product_matrix_algorithm,detailed_data.grid,model);
65 UON = orthonormalize(U,A);
66 detailed_data.RB = UON;
67 disp('reduced simulation:')
68 offline_data = rb_offline_prep(detailed_data,model);
69 model.N = size(detailed_data.RB,2);
70 reduced_data = rb_online_prep(offline_data, model);
71 simulation_data = rb_simulation(reduced_data,model);
72 Uappr = rb_reconstruction(detailed_data,simulation_data);
74 model.title = 'reduced simulation result';
75 plot_element_data_sequence(detailed_data.grid,Uappr,model);
76 model.title = 'detailed simulation result';
77 plot_element_data_sequence(detailed_data.grid,U,model);
78 case 3 % generate good reduced basis
79 disp('constructing reduced basis')
80 detailed_data = gen_detailed_data(model,model_data);
83 save(fullfile(rbmatlabresult,model.detailedfname),...
84 'detailed_data','model');
85 plot(detailed_data.RB_info.max_err_sequence);
86 set(gca,'Yscale','log');
87 title('RB-generation error convergence');
90 load(fullfile(rbmatlabresult,model.detailedfname));
91 disp('reduced simulation:')
92 offline_data = rb_offline_prep(detailed_data,model);
93 model.N = size(detailed_data.RB,2);
95 reduced_data = rb_online_prep(offline_data, model);
97 simulation_data = rb_simulation(reduced_data,model);
99 disp(['time for online phase: t = ',num2str(t)]);
101 disp('full simulation:')
103 U = detailed_simulation(detailed_data.grid, model);
105 disp(['time for detailed simulation: t = ',num2str(t)]);
108 load(fullfile(rbmatlabresult,model.detailedfname));
110 plot_params.axis_tight = 1;
113 error('step number unknown!');
120 % TO BE ADJUSTED TO NEW SYNTAX