rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
test_rb_lin_evol.m
1 function OK = test_rb_lin_evol
2 %function OK = test_rb_lin_evol
3 %
4 % function performing the whole sequence of reduced basis approximation
5 % and testing, whether the error prediction of the reduced model is
6 % indeed smaller than the real error.
7 %
8 % OK == 1 if test is OK, otherwise 0
9 
10 % Bernard Haasdonk 20.8.2007
11 
12  OK = 1;
13 
14 model = init_model('convdiff_model');
15 disp('linear evolution problem loaded');
16 
17 try
18  % do not compute the detailed data, but simply load
19  load('test_rb_lin_evol_data','detailed_data');
20 catch
21  model_data = gen_model_data(model);
22 
23  detailed_data = gen_detailed_data(model, model_data)
24  save('test_rb_lin_evol_data', 'detailed_data', 'model');
25 end
26 
27 detailed_data.grid = construct_grid(model);
28 
29 model.verbose = 0;
30 %model.mu=[0,0,0];
31 %model.RB_stop_Nmax = 100;
32 %detailed_data = gen_detailed_data(model, model_data);
33 %save('/tmp/temp.mat','detailed_data','model','model_data');
34 
35 reduced_data = gen_reduced_data(model, detailed_data);
36 disp('offline preparation terminated');
37 
38 model.N = size(detailed_data.RB,2);
39 
40 reduced_data = extract_reduced_data_subset(model, reduced_data);
41 
42 disp('online preparation terminated');
43 
44 mus = {[0,0,0],[0.1,0.1,0.1e-8]};
45 elim = [5.7e-9, 2.4e-07]; % error limits
46 
47 for m = 1:length(mus)
48  model = model.set_mu(model, mus{m});
49 
50  disp('mu is set');
51 
52  rb_simulation_data = rb_simulation(model,reduced_data);
53 
54  disp('rb simulation terminated');
55 
56  rb_simulation_data = rb_reconstruction(model,detailed_data,rb_simulation_data);
57 
58  disp('reconstruction finished');
59 
60  simulation_data = detailed_simulation(model, detailed_data);
61 
62  disp('detailed simulation finished');
63 
64  err = model.error_algorithm(simulation_data.U,rb_simulation_data.U,detailed_data.W,model);
65 
66  disp('error computation finished');
67 
68  if err(end) > elim(m);
69  disp('reduced error is too large!!!');
70  OK = 0;
71  end;
72 
73  if err(end) < elim(m)*0.1;
74  disp('reduced error is too small!!!');
75  OK = 0;
76  end;
77 
78  if rb_simulation_data.Delta(end) < err(end)
79  disp('rb_prediction smaller than true error!!!');
80  OK = 0;
81  end;
82 
83 end;
84 
85 
86 
87 
88 
89 
90 %| \docupdate