rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
scm_infsup_demo.m
Go to the documentation of this file.
1 function scm_infsup_demo()
3 %
4 % Demo of SCM (infsup constant)
5 %
6 
7 % David Kreplin 05.01.2015
8 
9 %less parameters
10 
11 %Thermal Block Model
12 % model = thermalblock_model_hp();
13 % model.gen_model_data=@lin_stat_gen_model_data;
14 % model_data = model.gen_model_data(model);
15 % params.dirichlet_gids = model_data.df_info.dirichlet_gids;
16 
17 
18 %Laminar Flow Model
19 params.mesh_number = 1;
20 model = laminar_flow_model(params);
21 model.has_nonlinearity = 0;
22 model_data = model.gen_model_data(model);
23 params.dirichlet_gids = model_data.bc_info.dirichlet_gids;
24 
25 
26 
27 
28 operator=@ (model) model.operators(model,model_data);
29 innerproduct_matrix = model.get_inner_product_matrix(model_data);
30 
31 params.dirichlet_gids = model_data.bc_info.dirichlet_gids;
32 params.Ma = inf;
33 params.Mp = 0;
34 params.NumberOfParameters = 500;
35 params.eps=0.01;
36 params.max_iterations=10;
37 params.parallel=0;
38 
39 params.type='infsup';
40 
41 SCM_data = SCM(model, params, operator,innerproduct_matrix);
42 %alternative (see documentation): SCM_data = SCM(model, params, model_data);
43 
44 rmserror=0;
45 maderror = 0;
46 innerproduct_matrix = remove_dirichlet(innerproduct_matrix,0,params.dirichlet_gids);
47 fprintf('Results:\ninfsup constant upper bound lower bound (scm infsup constant)\n');
48 for i = 1:20
49  mu = rand_uniform(1,model.mu_ranges);
50  model = set_mu(model,mu);
51  model.decomp_mode=0;
52  [A,~] = model.operators(model,model_data);
53  A=remove_dirichlet(A,0,params.dirichlet_gids );
54  [v,d] = fast_eigs(A'*(innerproduct_matrix'\A),innerproduct_matrix,'sm');
55  infsup=sqrt(min(d));
56  alpha_UB = SCMonline(mu,model,operator,SCM_data,'ub');
57  alpha_LB = SCMonline(mu,model,operator,SCM_data,'lb');
58 
59  fprintf('%f %f %f\n',infsup,alpha_UB,alpha_LB);
60 
61  rmserror = rmserror+(infsup-alpha_LB)^2;
62  maderror = maderror + abs(infsup-alpha_LB);
63 end
64 rmserror = sqrt(rmserror/20)
65 maderror = maderror/20
66 
67 
68 
69 keyboard;
70 end
71 
72 
73 
74 function A=remove_dirichlet(A,mode,I)
75 if mode == 0
76  A(I,:) = [];
77  A(:,I)= [];
78 else
79  for i = 1:length(A)
80  A{1,i}(I,:) = [];
81  A{1,i}(:,I) = [];
82  end
83 end
84 end
function descr = thermalblock_model_hp(params)
Thermal Block example similar as described in the book of A.T. patera and G. Rozza (just one paramete...
function model = laminar_flow_model(params)
Model of laminar flow (steady Navier-Stokes) around cylinder in a pipe.
function scm_infsup_demo()
scm_infsup_demo()