rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
scm_minimal_model.m
Go to the documentation of this file.
1 function model = scm_minimal_model(size)
2 %model = scm_minimal_model(size)
3 %
4 % a minimal-example of size = size(input) with the following matrices:
5 % A =(1 0 0 ... 1 b = (0 K = (1 0 ... 0
6 % 1 1 0 ... 0 0 0 1 0 ... 0
7 % 0 1 1 0 ... 0 ... 0 0 1 0 ... 0
8 % ..... 0) .....
9 % 0 ... 0 1) 0 .... 0 1)
10 %
11 % with A^1 = K and A^2 holding the rest of A so that A = (1-mu)*A^1 + mu*A^2
12 % This is coercive for mu = 0 (with alpha = beta = 1) and inf-sup stable
13 % (but not coercive) for mu = 1.
14 % This minimal model is used in the scm_demo to proof, that the 'lin_stat'
15 % inf-sup code is actually working.
16 
17 % Dominik Garmatter 20.09 2012
18 
19 if nargin == 0
20  model.size = 100;
21 else
22  if ceil(size/2) == size/2
23  model.size = size;
24  else
25  error('size has to be an even positiv number')
26  end
27 end
28 
29 model.rb_problem_type = 'lin_stat';
30 model.verbose = 30;
31 model.set_mu = @set_mu_default;
32 model.get_mu = @get_mu_default;
33 model.gen_model_data = @scm_minimal_model_gen_model_data;
34 model.get_inner_product_matrix = @(model_data) model_data.inner_product_matrix;
35 model.mu_names = {'mu'};
36 model.mu = 0;
37 model.mu_ranges = {[1e-10 1]};
38 model.decomp_mode = 0;
39 model.operators = @scm_minimal_model_operators;
40 model.use_scm = 1;
41 % some (not neccessary) settings for scm_offline.m:
42 model.scm_M_alpha = 70;
43 model.scm_M_plus = 200;
44 model.scm_eps_tol = eps;
45 model.scm_size_C = 50;
46 
47 function model_data = scm_minimal_model_gen_model_data(model)
48 
49 model_data = [];
50 model_data.inner_product_matrix = speye(model.size);
51 
52 
53 function [A,b] = scm_minimal_model_operators(model, model_data)
54 
55 
56 if ~isfield(model, 'decomp_mode')
57  model.decomp_mode = 0;
58 end
59 
60 H = model.size;
61 
62 
63 decomp_mode = model.decomp_mode;
64 if decomp_mode == 0
65  b = zeros(H,1);
66  A = (1-model.mu)*speye(H) + model.mu*(sparse(diag(ones(H-1,1),-1)) + sparse(1,H,1,H,H,1));
67 elseif decomp_mode == 1
68  b = {zeros(H,1)};
69  A = {speye(H); sparse(diag(ones(H-1,1),-1)) + sparse(1,H,1,H,H,1)};
70 else % decomp_mode = 2
71  b = 1;
72  A = [1-model.mu; model.mu];
73 end
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
Definition: verbose.m:17
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)