rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
quadr_nonlin_script.m
1 function quadr_nonlin_script(step)
2 %function quadr_nonlin_script(step)
3 %
4 % Script demonstrating quadratically nonlinear diffusion problem
5 % and RB treatment
6 %
7 % B. Haasdonk 8.12.2011
8 
9 if nargin == 0
10  step = 1;
11 end;
12 
13 plot_params = [];
14 plot_params.axis_equal = 0;
15 plot_params.no_lines = 0;
16 
17 switch step
18  case 1
20  model_data = gen_model_data(model);
21  model = set_mu(model,[0.1,1]);
22  sim_data = detailed_simulation(model, model_data);
23  p = plot_sim_data(model, model_data, sim_data,[]);
24 
25  case 2 % demo_rb_gui of detailed_simulation
26  % setting rb-pointers to dummy-functions, such that
27  % rb simulation does simply do a full simulation:
29  model.gen_detailed_data = @(model,model_data) model_data;
30  model.gen_reduced_data = @(model,detailed_data) detailed_data;
31  model.rb_simulation = model.detailed_simulation;
32  model.rb_reconstruction = ...
33  @(model,detailed_data,rb_sim_data) ...
34  rb_sim_data;
35  % end of setting pointers.
36  model_data = gen_model_data(model);
37  detailed_data = gen_detailed_data(model, model_data);
38  demo_rb_gui(model, detailed_data,[],plot_params);
39 
40  case 3 % simple reduced basis generation and plot
42  model_data = gen_model_data(model);
43  detailed_data = gen_detailed_data(model, model_data);
44  plot(model_data.grid.X(2:end-1),detailed_data.RB)
45  title(['Reduced basis with ',...
46  num2str(size(detailed_data.RB,2)),...
47  ' basis vectors']);
48 
49  case 4 % reduced simulation and error for single parameter
50 
52  model_data = gen_model_data(model);
53  detailed_data = gen_detailed_data(model, model_data);
54  reduced_data = gen_reduced_data(model, detailed_data);
55  mu =[1,1];
56  model = set_mu(model,mu);
57  rb_sim_data = rb_simulation(model, reduced_data);
58  rb_sim_data = rb_reconstruction(model, detailed_data, rb_sim_data)
59  sim_data = detailed_simulation(model, model_data);
60  err = [];
61  err.u = sim_data.u - rb_sim_data.u;
62  plot_params.title = ['error u-uN for mu=',num2str(mu)];
63  plot_sim_data(model,detailed_data,err,plot_params);
64  figure;
65  plot_params.title = ['uN and u for mu=',num2str(mu)];
66  plot_params.legend ={'u','u_N'};
67  joint = [];
68  joint.u = [rb_sim_data.u, sim_data.u];
69  plot_sim_data(model,detailed_data,joint,plot_params);
70 
71  case 5 % rb_demo_gui
73  model_data = gen_model_data(model);
74  detailed_data = gen_detailed_data(model, model_data);
75  demo_rb_gui(model, detailed_data,[],plot_params);
76 
77  otherwise
78  error('step unknown');
79 end;
80 
function demo_rb_gui(varargin)
reduced basis demo with sliders
Definition: demo_rb_gui.m:17
function model = quadratic_poisson_model()
quadratic poisson equation on unit interval
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