rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
scm_demo.m
Go to the documentation of this file.
1 % scm_demo.m
2 % a simple demo script which produces scm_offline_data for the inf-sup
3 % constant of the scm_minimal_model. Then for a fine set of parameters in
4 % [0,1] the exact constant beta(mu), the lower bound beta_{LB}(mu) and
5 % the exact cercivity constant alpha(mu) are computet and the results are
6 % plottet.
7 % This shows that the scm_minimal_model is coercive up to mu = 0.5 and from
8 % there on it is only inf-sup stable. For mu = 0.5 it is neither cercive
9 % nor inf-sup stable. The main point is to show, that the SCM is working
10 % fine for little 'lin_stat' inf-sup stable problems.
11 
12 % Dominik Garmatter 20.09 2012
13 
14 clear;
15 % generate model and model_data
16 size = 100;
17 model = scm_minimal_model(size);
18 model_data = gen_model_data(model);
19 K = model.get_inner_product_matrix(model_data);
20 % add components to data
21 old_decomp_mode = model.decomp_mode;
22 model.decomp_mode = 1;
23 A_comp = model.operators(model, model_data);
24 model.decomp_mode = old_decomp_mode;
25 model_data.A_comp = A_comp;
26 % scm settings
27 model.scm_eps_tol = eps;
28 model.scm_size_C = 20;
29 model.scm_M_alpha = 20;
30 model.scm_M_plus = 200;
31 % generate offline_data for beta
32 model.scm_desired_constant = 2;
33 scm_offline_data_beta = scm_offline(model, model_data);
34 % write into reduced data
35 reduced_data_beta = [];
36 reduced_data_beta.scm_offline_data = scm_offline_data_beta;
37 % for every mu get the direct constant, and the lower bound
38 mu_fineness = 99;
39 gather_alpha = zeros(mu_fineness+1,1);
40 gather_beta = zeros(mu_fineness+1,1);
41 gather_beta_LB = zeros(mu_fineness+1,1);
42 for i = 1 : mu_fineness+1
43  fprintf('.');
44  model = set_mu(model, 0 + (i-1)/mu_fineness); % realises discrete [0,1]
45  model.decomp_mode = 2;
46  A_coeff = model.operators(model, model_data);
47  A = lincomb_sequence(A_comp, A_coeff);
48  % also solve the EWP for the coercivity constant
49  LM_alpha = eigs(0.5*(A+A'),K,1,'LM');
50  if LM_alpha >= 0
51  gather_alpha(i) = eigs(0.5*(A+A') - (LM_alpha+1e-10)*K,K,1,'LM') + (LM_alpha+1e-10);
52  else
53  gather_alpha(i) = LM_alpha;
54  end
55  LM_beta = sqrt(eigs(A*K*A',K,1,'LM'));
56  if LM_beta >= 0
57  gather_beta(i) = sqrt(eigs(A*K*A' - (LM_beta+1e-10)*K,K,1,'LM') + (LM_beta+1e-10)); % inv(K) == K (normally it would be A*inv(K)*A')
58  else
59  gather_beta(i) = LM_beta;
60  end
61  gather_beta_LB(i) = scm_lower_bound(model, reduced_data_beta);
62 end
63 fprintf('\n');
64 disp('plotting...')
65 % plot
66 f = figure;
67 subplot(1,2,1)
68 plot(0:1/mu_fineness:1,gather_alpha,'r')
69 xlabel('\mu')
70 leg = legend('\alpha','\alpha_{LB}');
71 set(leg,'Location','Best')
72 subplot(1,2,2)
73 plot(0:1/mu_fineness:1,gather_beta,'r:',0:1/mu_fineness:1,gather_beta_LB,'g--')
74 xlabel('\mu')
75 leg = legend('\beta','\beta_{LB}');
76 set(leg,'Location','Best')
77 axes('position',[0,0,1,1],'visible','off');
78 text(0.15,0.97,['This plot shows that the scm\_minimal\_model is coercive up to \mu = ' mat2str(0.5) ' and always inf-sup stable (except for \mu = ' mat2str(0.5) '). The main point is that the scm is working fine for small lin\_stat inf-sup stable problems.'])
79 set(gcf,'Color','white')
function scm_demo()
scm_demo.m a simple demo script which produces scm_offline_data for the inf-sup constant of the scm_m...
Definition: scm_demo.m:17
function scm_offline_data = scm_offline(model, detailed_data, M_train, D_train)
scm_offline_data = scm_offline(model, detailed_data, M_train, D_train)
Definition: scm_offline.m:17
function model = scm_minimal_model(size)
model = scm_minimal_model(size)