rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules 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 disp('THIS SCRIPT STILL USES VERY OLD MECHANISM')
7 disp('MUST BE UPDATED!');
8 
9 step = 1; % single simulation
10 %step = 2; % dummy reduced basis & comparison of reduced to detailed simulation
11 %step = 3; % real reduced basis generation and store as detailed_data
12 %step = 4; % time comparison
13 %step = 5; % demo_rb_gui with modified fuel cell
14 
15 %load demo_lin_evol_params;
16 model = convdiff_model;
17 model.detailedfname = 'ulm_detailed.mat';
18 model.RB_generation_mode = 'greedy_uniform_fixed';
19 model.RB_numintervals = [10 4 4];
20 model.mu_names ={'c_init' 'beta' 'k'};
21 model.mu_ranges ={[0 1] [0 1] [0 5.0000e-008]};
22 model.RB_stop_Nmax = 100;
23 
24 % display params
25 %params.name_convective_num_flux = 'enquist_osher';
26 
27 model.init_values_ptr = @init_values_grey_image;
28 %model.name_init_values = 'grey_image';
29 %model.c_init_filename = 'simtech_binary.bmp';
30 model.c_init_filename = 'uulm_grey_inv_scaled_resized.bmp';
31 %params.c_init = 0.0;
32 model.c_init = 1.0;
33 model.c_init_xmin = model.xrange(1);
34 model.c_init_xmax = model.xrange(2);
35 model.c_init_ymin = model.yrange(1);
36 model.c_init_ymax = model.yrange(2);
37 model.c_init_xdivisions = (0.1:0.1:1.0) *...
38  (model.xrange(2)-model.xrange(1));
39 
40 model.k = 0;
41 
42 model.operators_conv_explicit = @fv_operators_conv_explicit_engquist_osher;
43 
44 %grid = construct_grid(model);
45 %params.lxf_lambda = 1.0194e+003;
46 %fv_search_max_lxf_lambda([],model);
47 model.nt = model.nt;
48 
49 % output settings
50 model.verbose = 10;
51 model.axis_equal = 1;
52 model.clim = [0,1];
53 
54 model = model;
55 model_data = gen_model_data(model);
56 
57 %detailed_data.grid = grid;
58 
59 switch step
60  case 1
61  disp('performing single detailed simulation')
62  sim_data = detailed_simulation(model, model_data);
63  plot_sim_data(model, model_data, sim_data,[]);
64 % plot_element_data_sequence(detailed_data.grid,U,model);
65  case 2 % construct dummy reduced basis by single trajectory and simulate
66  U = detailed_simulation(model,detailed_data);
67  A = feval(model.inner_product_matrix_algorithm,detailed_data.grid,model);
68  UON = orthonormalize(U,A);
69  detailed_data.RB = UON;
70  disp('reduced simulation:')
71  offline_data = rb_offline_prep(detailed_data,model);
72  model.N = size(detailed_data.RB,2);
73  reduced_data = rb_online_prep(offline_data, model);
74  simulation_data = rb_simulation(reduced_data,model);
75  Uappr = rb_reconstruction(detailed_data,simulation_data);
76 
77  model.title = 'reduced simulation result';
78  plot_element_data_sequence(detailed_data.grid,Uappr,model);
79  model.title = 'detailed simulation result';
80  plot_element_data_sequence(detailed_data.grid,U,model);
81  case 3 % generate good reduced basis
82  disp('constructing reduced basis')
83  detailed_data = gen_detailed_data(model,model_data);
84 % detailed_data = rb_basis_generation(detailed_data, ...
85 % model);
86  save(fullfile(rbmatlabresult,model.detailedfname),...
87  'detailed_data','model');
88  plot(detailed_data.RB_info.max_err_sequence);
89  set(gca,'Yscale','log');
90  title('RB-generation error convergence');
91 
92  case 4
93  load(fullfile(rbmatlabresult,model.detailedfname));
94  disp('reduced simulation:')
95  offline_data = rb_offline_prep(detailed_data,model);
96  model.N = size(detailed_data.RB,2);
97  model.k = 0.0001;
98  reduced_data = rb_online_prep(offline_data, model);
99  tic;
100  simulation_data = rb_simulation(reduced_data,model);
101  t = toc;
102  disp(['time for online phase: t = ',num2str(t)]);
103 
104  disp('full simulation:')
105  tic;
106  U = detailed_simulation(detailed_data.grid, model);
107  t = toc;
108  disp(['time for detailed simulation: t = ',num2str(t)]);
109 
110  case 5
111  load(fullfile(rbmatlabresult,model.detailedfname));
112  plot_params = [];
113  plot_params.axis_tight = 1;
114  demo_rb_gui(model,detailed_data,[],plot_params);
115  otherwise
116  error('step number unknown!');
117 end;
118 
119 
120 return;
121 
122 
123 % TO BE ADJUSTED TO NEW SYNTAX
124 %| \docupdate
function [ L_E_conv , bdir_E_conv ] = fv_operators_conv_explicit_engquist_osher(model, model_data, U, NU_ind)
computes convection contribution to finite volume time evolution matrices, or their Frechet derivati...
function model = convdiff_model(dummy)
function creating a simple model for a linear convection diffusion problem
function demo_rb_gui(varargin)
reduced basis demo with sliders
Definition: demo_rb_gui.m:17
function p = plot_sim_data(model, model_data, sim_data, plot_params)
function performing the plot of the simulation results as specified in model.
Definition: plot_sim_data.m:17
function detailed_data = rb_basis_generation(model, detailed_data)
reduced basis construction with different methods