rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
cmp_rb_lin_nonlin_evol.m
Go to the documentation of this file.
1 % small script performing a reduced basis simulation with the
2 % linear and nonlinear scheme and plotting the results
3 % the detailed_data for the nonlinear case can be modified and the
4 % simulation parameters switched, hereby checking suitability of a
5 % colateral basis for different parameter settings.
6 
7 % Bernard Haasdonk 24.5.2007
8 
9 % prepare and run nonlin_evol simulation
10 
12 % params.Mmax = 100;
13 % detailed_data = rb_detailed_prep(params);
14  clear;
15 % load demo_nonlin_evol_detailed_data_LE_on_RB_wo_offset;
16 % load demo_nonlin_evol_detailed_data3;
17  load demo_nonlin_evol_detailed_data_8_trajectories;
18 % load demo_nonlin_evol_detailed_data_LE_on_RB;
19  offline_data = rb_offline_prep(detailed_data,params);
20 
21 %params.N = 25; params.M = length(detailed_data.TM);
22 %params.N = 123; params.M = length(detailed_data.TM);
23 params.N = size(detailed_data.RB,2); params.M = length(detailed_data.TM{1});
24 
25  % M usually less than N !!
26 
27  reduced_data = rb_online_prep(offline_data,params);
28  %params.k = 1.25e-8;
29  params.k = 0;
30  %params.c_init = 1;
31  params.c_init = 0.5;
32  params.beta = 0.5;
33  %params.k = 5e-8;
34 
35  disp('performing nonlinear simulation:');
36  simulation_data = rb_simulation(reduced_data,params);
37  Unonlin = rb_reconstruction(detailed_data,simulation_data);
38  params.title = 'Solution from nonlinear rb-simulation';
39  plot_element_data_sequence([],Unonlin,params);
40 % plot_element_data_sequence([],Unonlin(:,1:100),params);
41  %plot_rb_reconstruction(detailed_data,simulation_data,params);
42 
43  disp('performing linear simulation:');
44  % run linear simulation
45  lparams = params;
46  lparams.rb_problem_type = 'lin_evol';
47  lparams.L_I_inv_norm_bound = 1;
48  lparams.L_E_norm_bound = 1;
49  %use same detailed-data, i.e. reduced basis
50  offline_data = rb_offline_prep(detailed_data,lparams);
51  reduced_data = rb_online_prep(offline_data,lparams);
52  simulation_data = rb_simulation(reduced_data,lparams);
53  Ulin = rb_reconstruction(detailed_data,simulation_data);
54  lparams.title = 'Solution from linear rb-simulation';
55 % plot_element_data_sequence([],Ulin(:,1:100),lparams);
56  plot_element_data_sequence([],Ulin,lparams);
57 
58  % plot difference
59  params.title = 'Difference of linear and nonlinear';
60 % plot_element_data_sequence([],Ulin(:,1:100)-Unonlin(:,1:100),params);
61  plot_element_data_sequence([],Ulin-Unonlin,params);
62 
63  l2_errors = fv_l2_error(Ulin,Unonlin,detailed_data.W);
64 
65  figure,plot(l2_errors);
66 
67  title('l2-difference');
68 % TO BE ADJUSTED TO NEW SYNTAX
69 %| \docupdate