rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
scm_coercive_demo.m
Go to the documentation of this file.
1 function scm_coercive_demo()
3 %
4 % Demo of SCM (coercive constant)
5 %
6 
7 % David Kreplin 05.01.2015
8 
9 clear;
10 
11 model = thermalblock_model_hp();
12 model.gen_model_data=@lin_stat_gen_model_data;
13 model_data = model.gen_model_data(model);
14 
15 operator=@ (model) model.operators(model,model_data);
16 innerproduct_matrix = model.get_inner_product_matrix(model_data);
17 % SCM properties
18 params.Ma = inf;
19 params.Mp = 0;
20 params.NumberOfParameters = 1000;
21 params.eps=0.15;
22 params.max_iterations=100;
23 params.parallel=0;
24 params.dirichlet_gids = model_data.df_info.dirichlet_gids;
25 params.type='coercive';
26 
27 
28 
29 %OFFLINE
30 SCM_data=SCM(model,params,operator,innerproduct_matrix);
31 %Alternative (see documentation): SCM_data=SCM(model,params,model_data);
32 
33 rmserror=0;
34 maderror = 0;
35 innerproduct_matrix = model.get_inner_product_matrix(model_data);
36 innerproduct_matrix = remove_dirichlet(innerproduct_matrix,0,params.dirichlet_gids);
37 fprintf('Results:\ncoercive constant upper bound lower bound (scm coercive constant)\n');
38 for i = 1:20
39  mu = rand_uniform(1,model.mu_ranges);
40  model = set_mu(model,mu);
41  model.decomp_mode=0;
42  [A,~] = model.operators(model,model_data);
43  A=remove_dirichlet(A,0,params.dirichlet_gids);
44  coer=eigs(A,innerproduct_matrix,1,'sm');
45  alpha_UB = SCMonline(mu,model,operator,SCM_data,'ub');
46  %ONLINE:
47  alpha_LB = SCMonline(mu,model,operator,SCM_data,'lb');
48  %alpha_LB = SCMonline(mu,model,model_data,SCM_data);
49 
50  fprintf('%f %f %f\n',coer,alpha_UB,alpha_LB);
51 
52  rmserror = rmserror+(coer-alpha_LB)^2;
53  maderror = maderror + abs(coer-alpha_LB);
54 end
55 rmserror = sqrt(rmserror/20)
56 maderror = maderror/20
57 
58 
59 
60 keyboard;
61 end
62 
63 
64 function A=remove_dirichlet(A,mode,I)
65 if mode == 0
66  A(I,:) = [];
67  A(:,I)= [];
68 else
69  for i = 1:length(A)
70  A{1,i}(I,:) = [];
71  A{1,i}(:,I) = [];
72  end
73 end
74 end
75 
76 
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 scm_coercive_demo()
scm_coercive_demo()