rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
test_compare_real_error_estimated_error.m
Go to the documentation of this file.
1 %% model initialisation
2 
3 params = [];
4 params.coarse_factor = 16;
5 model = advection_fv_output_opt_model(params);
6 
7 model.rb_init_data_basis = @RB_init_data_basis_lin_evol_opt;
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 %%compare estimated to real error
18 
19 
20 %model = advection_fv_output_opt_model([]);
21 
22 
23 model.RB_stop_Nmax = 15;
24 
25 model_data = gen_model_data(model);
26 
27 detailed_data = gen_detailed_data(model, model_data);
28 
29 save('TestBasis_coarse16.mat','model','detailed_data');
30 
31 %% Load
32 load('TestBasis_coarse16.mat');
33 
34 reduced_data = gen_reduced_data(model, detailed_data);
35 
36 model = set_mu(model, [0.25,0.25,0.25]);
37 
38 sim_data_rb = rb_simulation(model, reduced_data);
39 
40 sim_data_rb = rb_reconstruction(model, detailed_data, sim_data_rb);
41 
42 sim_data_det = detailed_simulation(model, model_data);
43 
44 
45 %-----------------
46 A = model_data.W;
47 
48 difference = sim_data_rb.U - sim_data_det.U;
49 
50 sim_data = sim_data_det;
51 sim_data.U = difference;
52 plot_sim_data(model, model_data, sim_data, []);
53 
54 %plot_sim_data(model, model_data, sim_data_det, []);
55 %plot_sim_data(model, model_data, sim_data_rb, []);
56 
57 nt = size(sim_data_rb.U,2);
58 real_error = zeros(1,nt);
59 for n=1:nt
60  real_error(n) = sqrt(difference(:,n)'*A*difference(:,n));
61 end
62 
63 t=1:nt;
64 
65 plot(t, real_error);
66 hold on;
67 plot(t,sim_data_rb.Delta);
68 
69 
70 keyboard;
71 
72 %% Fehlertest durch hinzufügen von trajektorie
73 
74 params = [];
75 params.coarse_factor = 16;
76 model = advection_fv_output_opt_model(params);
77 
78 model.rb_init_data_basis = @RB_init_data_basis_lin_evol_opt;
79 
80 
81 model.RB_stop_Nmax = 15;
82 
83 model_data = gen_model_data(model);
84 
85 detailed_data = gen_detailed_data(model, model_data);
86 
87 model = set_mu(model, [0,1,1]);
88 
89 reduced_data = gen_reduced_data (model, detailed_data);
90 sim_data_red = rb_simulation(model, reduced_data);
91 Delta = sim_data_red.Delta(end);
92 
93 
94 
95 sim_data = detailed_simulation(model, model_data);
96 U = sim_data.U;
97 [phi,S,V] = svds(U,50);
98 
99 detailed_data.RB = [detailed_data.RB,phi];
100 
101 reduced_data = gen_reduced_data(model, detailed_data);
102 
103 sim_data_new = rb_simulation(model, reduced_data);
104 
105 Delta_new = sim_data_new.Delta(end);
106 
107 Delta
108 Delta_new
109 
110 
111 %% Mit PCA basis generieren
112 
113 
114 params = [];
115 params.coarse_factor = 16;
116 model = advection_fv_output_opt_model(params);
117 
118 model.RB_generation_mode= 'PCA_trajectories';
119 M=[0,0,0;0,0,1;0,1,0;1,0,0;0,1,1;1,0,1;1,1,1;1,1,0];
120 
121 for i = 1:size(M,1)
122 model.RB_mu_list{i} = M(i,:);
123 end
124 
125 model_data = gen_model_data(model);
126 detailed_data = gen_detailed_data(model, model_data);
127 save('PCA_basis_coarse16.mat', 'model', 'detailed_data', 'model_data');
128 
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