rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
ulm_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 
12 %load demo_lin_evol_params;
13 model = convdiff_model;
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;
20 
21 % display params
22 %params.name_convective_num_flux = 'enquist_osher';
23 
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';
28 %params.c_init = 0.0;
29 model.c_init = 1.0;
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));
36 
37 model.k = 0;
38 
39 model.operators_conv_explicit = @fv_operators_conv_explicit_engquist_osher;
40 
41 %grid = construct_grid(model);
42 %params.lxf_lambda = 1.0194e+003;
43 %fv_search_max_lxf_lambda([],model);
44 model.nt = model.nt;
45 
46 % output settings
47 model.verbose = 10;
48 model.axis_equal = 1;
49 model.clim = [0,1];
50 
51 model = model;
52 model_data = gen_model_data(model);
53 
54 %detailed_data.grid = grid;
55 
56 switch step
57  case 1
58  disp('performing single detailed simulation')
59  sim_data = detailed_simulation(model, model_data);
60  plot_sim_data(model, model_data, sim_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);
73 
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);
81 % detailed_data = rb_basis_generation(detailed_data, ...
82 % model);
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');
88 
89  case 4
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);
94  model.k = 0.0001;
95  reduced_data = rb_online_prep(offline_data, model);
96  tic;
97  simulation_data = rb_simulation(reduced_data,model);
98  t = toc;
99  disp(['time for online phase: t = ',num2str(t)]);
100 
101  disp('full simulation:')
102  tic;
103  U = detailed_simulation(detailed_data.grid, model);
104  t = toc;
105  disp(['time for detailed simulation: t = ',num2str(t)]);
106 
107  case 5
108  load(fullfile(rbmatlabresult,model.detailedfname));
109  plot_params = [];
110  plot_params.axis_tight = 1;
111  demo_rb_gui(model,detailed_data,[],plot_params);
112  otherwise
113  error('step number unknown!');
114 end;
115 
116 
117 return;
118 
119 
120 % TO BE ADJUSTED TO NEW SYNTAX
121 %| \docupdate