rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
simtech_fuelcell_gdl.m
Go to the documentation of this file.
1 % small script demonstrating RB-approach for the fuelcell-gdl with
2 % the simtech image initial data
3 
4 % Bernard Haasdonk 24.5.2008
5 
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
10 step = 5; % demo_rb_gui with modified fuel cell
11 detailedfname = 'simtech_detailed.mat';
12 
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]};
18 
19 % display params
20 %params.name_convective_num_flux = 'enquist_osher';
21 
22 params.name_init_values = 'grey_image';
23 params.c_init_filename = 'simtech_binary.bmp';
24 %params.c_init = 0.0;
25 params.c_init = 1.0;
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));
32 
33 params.k = 0;
34 
35 params.name_convective_num_flux = 'engquist-osher';
36 
37 grid = construct_grid(params);
38 %params.lxf_lambda = 1.0194e+003;
39 %fv_search_max_lxf_lambda([],params);
40 params.nt = params.nt;
41 
42 % output settings
43 params.verbose = 10;
44 params.axis_equal = 1;
45 params.clim = [0,1];
46 
47 detailed_data.grid = grid;
48 
49 switch step
50  case 1
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);
65 
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')
72  detailed_data = rb_basis_generation(detailed_data, ...
73  params);
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');
79 
80  case 4
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);
85  params.k = 0.0001;
86  reduced_data = rb_online_prep(offline_data, params);
87  tic;
88  simulation_data = rb_simulation(reduced_data,params);
89  t = toc;
90  disp(['time for online phase: t = ',num2str(t)]);
91 
92  disp('full simulation:')
93  tic;
94  U = detailed_simulation(detailed_data.grid, params);
95  t = toc;
96  disp(['time for detailed simulation: t = ',num2str(t)]);
97 
98  case 5
99  load(fullfile(rbmatlabresult,detailedfname));
100  demo_rb_gui(detailed_data,[],params);
101  otherwise
102  error('step number unknown!');
103 end;
104 
105 
106 return;
107 
108 
109 % TO BE ADJUSTED TO NEW SYNTAX
110 %| \docupdate