rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
follicle_model.m
Go to the documentation of this file.
1 function model = follicle_model(params)
2 %function model = follicle_model(params)
3 % model of the human follicle growth
4 %
5 % two chemical components are assumed to be characteristic for the
6 % growth of human follicles.
7 %
8 % A deterministic model for the two species is given by a positive
9 % feedback loop, a bistable switch, i.e. 2-d nonlinear ODE.
10 %
11 % An approximation to the Chemical Master Equation gives a linear
12 % dynamical system.
13 %
14 % here, the state vector is the probability of states (pair of number of two
15 % chemical components) and the matrix A describes the change in
16 % these probabilities over time. The number of states is
17 % p = (range+1)*(range+2)/2
18 %
19 % The output is given by params.output_type:
20 % 'separatrix': an average over a subset of states, the ones below
21 % the "separatrix", which are assumed to be still "in rest",
22 % i.e. waiting for their growth specified by model.output_range
23 % 'expectation_M': the expectation of M state is computed
24 % 'expectation_N': the expectation of N state is computed
25 
26 % Q: D.h. die Zellen oberhalb der separatrix sind einfach abgestorben, oder zur
27 % Ovulation gekommen?
28 %
29 % Explanations from S. Waldherr "A stochastic switch for the
30 % primordial to primary transition in follicle growth", IST
31 % internal report (2009-04-09) v1
32 
33 % Bernard Haasdonk 22.9.2009
34 if (nargin < 1)
35  params = [];
36 end;
37 
38 model = lin_ds_model_default;
39 model.data_const_in_time = 1;
40 model.verbose = 0;
41 model.debug = 0;
42 
43 %%%%%%%%%%%%%%%%%%%%%%% parameters from steffen
44 model.M1 = 25;
45 model.h = 3;
46 model.M2 = 25;
47 %inomi=6;
48 if isfield(params,'range')
49  model.range = params.range;
50 else
51  model.range = 50; % connected with end time, increase e.g. to 50 later
52 end;
53 if isfield(params,'output_range')
54  model.output_range = params.output_range;
55 else
56  model.output_range = model.range; % connected with end time, increase e.g. to 50 later
57 end;
58 if (model.output_range > model.range)
59  error('please choose output range <= range');
60 end;
61 % determines the initial distribution in a lower left triangle
62 if isfield(params,'init_range')
63  model.init_range = params.init_range;
64 else
65  model.init_range = 0;
66 end;
67 %
68 if isfield(params,'reg_epsilon')
69  model.reg_epsilon = params.reg_epsilon;
70 else
71  model.reg_epsilon = 0;
72 end;
73 if ~isfield(params,'output_type')
74  params.output_type = 'separatrix';
75 end;
76 %for i = 1:10
77 % u1 = 0.01+(i-6)*0.001;
78 % u2 = 0.01+(i-6)*0.0005;
79 % k1 = 4*u1+(i-6)*0.0001;
80 % V1 = 75*u1;
81 % V2 = 75*0.01;
82 % parameterlist(i,1:5)= [k1 u1 u2 V1 V2];
83 %end;
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 
86 %model_data = my_ds_gen_model_data(model);
87 
88 model.u1 = 0.01;
89 model.u2 = 0.01;
90 model.k1fact = 4;
91 model.V1fact = 75;
92 model.V2fact = 75;
93 
94 % used as components later:
95 %model.k1 = model.k1fact * model.u1;
96 %model.V1 = model.V1fact * model.u1;
97 %model.V2 = model.V2fact * model.u2;
98 
99 model.mu_names = {'u1','u2'};
100 %model.mu_names = {'u1','u2','k1fact','V1fact','V2fact'};
101 model.mu_ranges = {[0.005,0.02],[0.005,0.02]};
102 
103 %model.T = 1000000; % Minutes, i.e. 1.9 Jahre
104 %model.nt = 500;
105 %model.T = 1000000; % Minutes, i.e. 1.9 Jahre
106 %model.nt = 10000;
107 model.T = 10000000; % Minutes, i.e. 19 Jahre
108 model.nt = 500;
109 %model.T = 5000000; % Minutes, i.e. 9.5 Jahre
110 %model.nt = 500;
111 %model.T = 50000000; % Minutes, i.e. 95 Jahre
112 %model.nt = 10000;
113 %disp('nt to be adjusted later!!!') => 500 OK!!
114 model.affinely_decomposed = 1;
115 model.A_function_ptr = @A_func;
116 % ratio of first to second ellipses axes
117 %model.A_axes_ratio = 2;
118 %model.A_axes_ratio = 2;
119 model.B_function_ptr = @B_func;
120 switch params.output_type
121  case 'separatrix'
122  model.C_function_ptr = @C_func_separatrix;
123  case 'expectation_M'
124  model.C_function_ptr = @C_func_expectation_M;
125  case 'expectation_N'
126  model.C_function_ptr = @C_func_expectation_N;
127  otherwise
128  error('params.output_type not known');
129 end;
130 model.D_function_ptr = @D_func;
131 model.x0_function_ptr = @x0_func;
132 % shift of x0 in third coordinate
133 %model.x0_shift=1;
134 model.u_function_ptr = @(model) 0; % define u constant
135 %model.u_function_ptr = @(model) sin(4*model.t);
136 %model.u_function_ptr = @(model) 0; % define u constant 0
137 %model.u_function_ptr = @(model) model.t; % define u = 1 * t
138 model.G_matrix_function_ptr = ...
139  @(model,model_data) speye(model.dim_x,model.dim_x);
140 % the following lead to both larger C1 and C2!!!
141 %model.G_matrix_function_ptr = @(model) diag([2,0.5,1]);
142 %model.G_matrix_function_ptr = @(model) diag([0.5,2,1]);
143 
144 % set function pointers to main model methods
145 model.gen_model_data = @my_ds_gen_model_data;
146 %model.detailed_simulation = @lin_ds_detailed_simulation;
147 model.gen_detailed_data = @my_ds_gen_detailed_data;
148 %model.gen_reduced_data = @lin_ds_gen_reduced_data;
149 %model.rb_simulation = @lin_ds_rb_simulation;
150 %model.plot_sim_data = @my_ds_plot_sim_data;
151 model.plot_sim_data_state = @plot_state_probabilities;
152 model.plot_slice = @my_plot_slice;
153 model.axis_tight = 1;
154 
155 %model.rb_reconstruction = @lin_ds_rb_reconstruction;
156 % determin model data, i.e. matrix components, matrix G
157 
158 model.orthonormalize = @model_orthonormalize_qr_no_perm;
159 
160 %model_data = gen_model_data(model); % matrix components
161 %model.dim_x = size(model_data.X,2);
162 model.dim_x = (model.range+1)*(model.range+2)/2;
163 
164 %model.decomp_mode = 1;
165 %tmp = model.C_function_ptr(model,[]);
166 model.dim_y = 1;
167 %model.dim_y = size(tmp{1},1);
168 %model.decomp_mode = 0;
169 
170 %model.dim_y = size(model_data.C_components{1},1);
171 
172 if isfield(params,'output_plot_indices')
173  model.output_plot_indices = params.output_plot_indices;
174 else
175  model.output_plot_indices = 1:model.dim_y;
176 end;
177 
178 model.theta = 1; % implicit discretization
179 
180 % be sure to determine correct constants once, if anything in the
181 % problem setting has changed!!
182 
183 %model.error_estimation = 1; % model is capable of error_estimation
184 model.enable_error_estimator = 1;
185 if ~isfield(params,'estimate_bounds')
186  params.estimate_bounds = 0;
187 end;
188 % the following only needs to be performed, if the model is changed.
189 if (params.estimate_bounds == 0)
190  % for G = Id
191  switch params.output_type
192  case 'separatrix'
193  model.state_bound_constant_C1 = 1 ;
194  model.output_bound_constant_C2 = sqrt(model.dim_x);
195  case 'expectation_N'
196  model.state_bound_constant_C1 = 1 ;
197  N = model.range;
198  model.output_bound_constant_C2 = ...
199  sqrt((N^4 - 2 * N^3 + 8 * N^2 + 2 * N + 3));
200  otherwise
201  warning('please adjust the computation of the error estimator constants!')
202  model.state_bound_constant_C1 = 100000 ;
203  model.output_bound_constant_C2 = 100000;
204  end;
205 %elseif params.estimate_bounds == 1
206 % model.estimate_lin_ds_nmu = 3;
207 % model.estimate_lin_ds_nX = 10;
208 % model.estimate_lin_ds_nt = 10;
209 % format long;
210 % [C1,C2] = lin_ds_estimate_bound_constants(model,model_data)
211 % model.state_bound_constant_C1 = C1;
212 % model.output_bound_constant_C2 = C2;
213 else
214  model.estimate_lin_ds_nmu = 3;
215  model.estimate_lin_ds_nX = 10;
216  model.estimate_lin_ds_nt = 10;
217  format long;
218  [C1,C2] = lin_ds_estimate_bound_constants(model,model_data)
219  model.state_bound_constant_C1 = C1;
220  model.output_bound_constant_C2 = C2;
221 end;
222 
223 model.inner_product_matrix_algorithm =@(model,model_data) ...
224  speye(model.dim_x,model.dim_x);
225 
226 model.error_algorithm = @(u1,u2,dummy1,dummy2) ...
227  sqrt(max(sum((u1-u2).^2),0));
228 % [4,3]* [3,2];
229 
230 %model.error_norm = 'l2';
231 %% 'RB_extension_max_error_snapshot'};
232 model.RB_stop_timeout = 4*60*60; % 4 hours
233 model.RB_stop_epsilon = 1e-10;
234 model.RB_error_indicator = 'error'; % true error
235 
236 %model.RB_error_indicator = 'estimator'; % Delta from rb_simulation
237 
238 model.RB_stop_Nmax = 200;
239 model.RB_generation_mode = 'greedy_uniform_fixed';
240 model.RB_numintervals = [4,4];
241 model.RB_detailed_train_savepath = 'follicle_model_detailed_train';
242 model.orthonormalize = @model_orthonormalize_qr;
243 model.RB_extension_algorithm = @RB_extension_PCA_fixspace;
245 
246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247 % functions defining the dynamical system and input/initial data
248 function A = A_func(model,model_data);
249 A = eval_affine_decomp(@A_components,@A_coefficients,...
250  model,model_data);
251 
252 function Acomp = A_components(model,model_data)
253 p = model.dim_x;
254 X = model_data.X;
255 h = model.h;
256 M1 = model.M1;
257 M2 = model.M2;
258 A1 = sparse([],[],[],p,p,7*p); % for k1
259 A2 = sparse([],[],[],p,p,7*p); % for u1
260 A3 = sparse([],[],[],p,p,7*p); % for u2
261 A4 = sparse([],[],[],p,p,7*p); % for V1
262 A5 = sparse([],[],[],p,p,7*p); % for V2
263 A6 = -speye(p,p); % for regularization
264 for m=1:p
265  A1(m,m)= -1;
266  j = find ((X(1,:)==X(1,m)+1) & (X(2,:)==X(2,m)));
267  A1(j,m) = 1;
268  A2(m,m) = -X(1,m);
269  j = find((X(1,:)==X(1,m)-1) & (X(2,:)==X(2,m)));
270  A2(j,m) = X(1,m);
271  A3(m,m) = -X(2,m);
272  j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)-1));
273  A3(j,m) = X(2,m);
274  A4(m,m) = -X(2,m)^h/(M1^h+X(2,m)^h);
275  j = find((X(1,:)==X(1,m)+1) & (X(2,:)==X(2,m)));
276  A4(j,m) = X(2,m)^h/(M1^h+X(2,m)^h);
277  A5(m,m)= -X(1,m)^h/(M2^h+X(1,m)^h);
278  j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)+1));
279  A5(j,m) = X(1,m)^h/(M2^h+X(1,m)^h);
280 end;
281 %keyboard;
282 Acomp = {A1, A2, A3, A4, A5, A6};
283 
284 function Acoeff = A_coefficients(model)
285 %Acoeff = [model.k1, model.u1, model.u2, model.V1, model.V2];
286 k1 = model.k1fact * model.u1;
287 V1 = model.V1fact * model.u1;
288 V2 = model.V2fact * model.u2;
289 Acoeff = [k1, model.u1, model.u2, V1, V2, model.reg_epsilon];
290 
291 function B = B_func(model,model_data)
292 B = eval_affine_decomp(@B_components,@B_coefficients,model,model_data);
293 
294 function Bcomp = B_components(model,model_data)
295 Bcomp = {zeros(model.dim_x,1)};
296 
297 function Bcoeff = B_coefficients(model)
298 Bcoeff = 1;
299 
300 function C = C_func_separatrix(model,model_data)
301 C = eval_affine_decomp(@C_components_separatrix,...
302  @C_coefficients,model,model_data);
303 
304 function C = C_func_expectation_M(model,model_data)
305 C = eval_affine_decomp(@C_components_expectation_M,...
306  @C_coefficients,model,model_data);
307 
308 function C = C_func_expectation_N(model,model_data)
309 C = eval_affine_decomp(@C_components_expectation_N,...
310  @C_coefficients,model,model_data);
311 
312 function Ccomp = C_components_separatrix(model,model_data)
313 i = find((model_data.Ms+model_data.Ns)<=model.output_range);
314 C = zeros(1,model.dim_x);
315 C(i) = 1;
316 Ccomp = {C};
317 % Ccomp = {ones(1,model.dim_x)};
318 %Ccomp = {[2,0,1],[0,2,1]};
319 
320 function Ccomp = C_components_expectation_M(model,model_data)
321 C = model_data.Ms(:)';
322 Ccomp = {C};
323 
324 function Ccomp = C_components_expectation_N(model,model_data)
325 C = model_data.Ns(:)';
326 Ccomp = {C};
327 
328 function Ccoeff = C_coefficients(model)
329 Ccoeff = [1];
330 %Ccoeff = [model.C_weight,1-model.C_weight];
331 
332 function D = D_func(model,model_data)
333 %D = [0;0]; % no decomposition required for scheme
334 D = [0]; % no decomposition required for scheme
335 
336 function x0 = x0_func(model,model_data)
337 x0 = eval_affine_decomp(@x0_components,@x0_coefficients,model,model_data);
338 
339 function x0comp = x0_components(model,model_data)
340 %if model.init_range == 0
341 % x0comp = {eye(model.dim_x,1)};
342 %else
343 i = ((model_data.Ms+model_data.Ns)<=model.init_range);
344 %i = (model_data.Ms<=1);
345 x0comp = {i(:)/sum(i)}; % sum should be 1!
346 %end;
347 
348 function x0coeff = x0_coefficients(model)
349 x0coeff = 1;
350 
351 function model_data = my_ds_gen_model_data(model)
352 s = 1; % state counter
353 % generate list of states X and output weight vector
354 Ms = zeros(1,(model.range+1)*(model.range+2)/2);
355 Ns = zeros(1,(model.range+1)*(model.range+2)/2);
356 for m=0:model.range
357  for n=0:(model.range-m)
358  X(:,s) = [m;n];
359  Ns(s) = n;
360  Ms(s) = m;
361  s = s+1;
362  end;
363 end;
364 p = s-1; % number of states
365 model.dim_x = p;
366 %model_data = lin_ds_gen_model_data(model);
367 model_data.X = X;
368 model_data.Ns = Ns;
369 model_data.Ms = Ms;
370 
371 if model.affinely_decomposed
372  model.decomp_mode = 1;
373  % the following call is extremely expensive: 30 seconds!!!!
374  % therefore caching is activated
375  % model_data.A_components = model.A_function_ptr(model,model_data);
376  model_data.A_components = filecache_function(...
377  model.A_function_ptr,model,model_data);
378  model_data.B_components = model.B_function_ptr(model,model_data);
379  model_data.C_components = model.C_function_ptr(model,model_data);
380  % no D components
381  % model_data.D_components = model.D_function_ptr(model);
382  model_data.x0_components = model.x0_function_ptr(model,model_data);
383 end;
384 model_data.G = model.G_matrix_function_ptr(model,[]);
385 
386 params.xnumintervals = model.range+1;
387 params.ynumintervals = model.range+1;
388 params.xrange = [-0.5,model.range+0.5];
389 params.yrange = [-0.5,model.range+0.5];
390 params.verbose = 0;
391 
392 % only for plotting:
393 model_data.plot_grid = rectgrid(params);
394 model_data.plot_nm_index_vector = ...
395  model_data.Ms + model_data.Ns*(model.range+1)+1;
396 
397 function detailed_data = my_ds_gen_detailed_data(model,model_data)
398 detailed_data = lin_ds_gen_detailed_data(model,model_data);
399 % only for plotting:
400 detailed_data.plot_grid = model_data.plot_grid;
401 detailed_data.plot_nm_index_vector = model_data.plot_nm_index_vector;
402 
403 function p = plot_state_probabilities(model,model_data,sim_data,params)
404 % plot of trajectory and output
405 %p = lin_ds_plot_sim_data(model,model_data,sim_data,params);
406 %close(gcf-1);
407 p = []; % no handles
408 %grid = Grids.rectgrid(params);
409 U = nan((model.range+1)*(model.range+1),size(sim_data.X,2));
410 U(model_data.plot_nm_index_vector,1:end)= sim_data.X;
411 % for debug:
412 %U(nm_index_vector,1) = model_data.Ns;
413 %U(nm_index_vector,2) = model_data.Ms;
414 %params.plot_function = @plot_element_data;
415 merged_plot_params = merge_model_plot_params(model, params);
416 merged_plot_params.plot_function = 'plot_element_data';
417 plot_data_sequence(model,model_data.plot_grid,U,merged_plot_params)
418 axis tight;
419 xlabel('species m');
420 ylabel('species n');
421 if ~isfield(model,'plot_title')
422  title('state probabilities');
423 else
424  title(model.plot_title);
425 end;
426 
427 function p = my_plot_slice(model,model_data,sim_data,params)
428 U = nan((model.range+1)*(model.range+1),1);
429 U(model_data.plot_nm_index_vector)= sim_data.X(:,params.timestep+1);
430 % for debug:
431 %U(nm_index_vector,1) = model_data.Ns;
432 %U(nm_index_vector,2) = model_data.Ms;
433 %params.plot_function = @plot_element_data;
434 params.plot_function = 'plot_element_data';
435 if ~isfield(params,'clim') && isfield(model,'clim')
436  params.clim = model.clim;
437 end;
438 p = plot_element_data(model_data.plot_grid,U,params);
439 %axis tight;
440 xlabel('species m');
441 ylabel('species n');
442 title('state probabilities');
443 
444 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
445 % CODE FROM STEFFEN, RESP HANWEI LI:
446 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447 
448 
449 % $$$
450 % $$$
451 % $$$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
452 % $$$ % define parameter
453 % $$$ clear;
454 % $$$ M1 = 25;
455 % $$$ h = 3;
456 % $$$ M2 = 25;
457 % $$$
458 % $$$ for i = 1:10
459 % $$$ u1 = 0.01+(i-6)*0.001;
460 % $$$ u2 = 0.01+(i-6)*0.0005;
461 % $$$ k1 = 4*u1+(i-6)*0.0001;
462 % $$$ V1 = 75*u1;
463 % $$$ V2 = 75*0.01;
464 % $$$ parameterlist(i,1:5)= [k1 u1 u2 V1 V2];
465 % $$$ end;
466 % $$$ inomi=6;
467 % $$$
468 % $$$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
469 % $$$ % build the nominal model
470 % $$$
471 % $$$ range = 20;
472 % $$$ s = 1; % state counter
473 % $$$
474 % $$$ % generate list of states X
475 % $$$ clear X;
476 % $$$ for m=0:range
477 % $$$ for n=0:(range-m)
478 % $$$ X(:,s) = [m;n];
479 % $$$ s = s+1;
480 % $$$ end;
481 % $$$ end;
482 % $$$ p = s-1; % number of states
483 % $$$
484 % $$$ % defining propensity functions
485 % $$$ a1 = @(x) (parameterlist(inomi,1)+parameterlist(inomi,4)*x(2)^h/(M1^h+x(2)^h));
486 % $$$ a2 = @(x) parameterlist(inomi,2)*x(1);
487 % $$$ a3 = @(x) parameterlist(inomi,5)*x(1)^h/(M2^h+x(1)^h);
488 % $$$ a4 = @(x) parameterlist(inomi,3)*x(2);
489 % $$$
490 % $$$ A = sparse([],[],[],p,p,7*p);
491 % $$$ for m=1:p
492 % $$$ A(m,m) = -(a1(X(:,m))+a2(X(:,m))+a3(X(:,m))+a4(X(:,m)));
493 % $$$ j = find((X(1,:)==X(1,m)+1) & (X(2,:)==X(2,m)));
494 % $$$ A(j,m) = a1(X(:,m));
495 % $$$ j = find((X(1,:)==X(1,m)-1) & (X(2,:)==X(2,m)));
496 % $$$ A(j,m) = a2(X(:,m));
497 % $$$ j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)+1));
498 % $$$ A(j,m) = a3(X(:,m));
499 % $$$ j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)-1));
500 % $$$ A(j,m) = a4(X(:,m));
501 % $$$ end;
502 % $$$
503 % $$$
504 % $$$ % KoeffizientenZerlegung
505 % $$$ clear A1; % for k1
506 % $$$ A1 = sparse([],[],[],p,p,7*p);
507 % $$$ for m=1:p
508 % $$$ A1(m,m)= -1;
509 % $$$ j = find ((X(1,:)==X(1,m)+1) & (X(2,:)==X(2,m)));
510 % $$$ A1(j,m) = 1;
511 % $$$ end;
512 % $$$
513 % $$$ clear A2; % for u1
514 % $$$ A2 = sparse([],[],[],p,p,7*p);
515 % $$$ for m=1:p;
516 % $$$ A2(m,m) = -X(1,m);
517 % $$$ j = find((X(1,:)==X(1,m)-1) & (X(2,:)==X(2,m)));
518 % $$$ A2(j,m) = X(1,m);
519 % $$$ end;
520 % $$$
521 % $$$ clear A3; % for u2
522 % $$$ A3 = sparse([],[],[],p,p,7*p);
523 % $$$ for m=1:p;
524 % $$$ A3(m,m) = -X(2,m);
525 % $$$ j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)-1));
526 % $$$ A3(j,m) = X(2,m);
527 % $$$ end;
528 % $$$
529 % $$$ clear A4; % for V1
530 % $$$ A4 = sparse([],[],[],p,p,7*p);
531 % $$$ for m=1:p;
532 % $$$ A4(m,m) = -X(2,m)^h/(M1^h+X(2,m)^h);
533 % $$$ j = find((X(1,:)==X(1,m)+1) & (X(2,:)==X(2,m)));
534 % $$$ A4(j,m) = X(2,m)^h/(M1^h+X(2,m)^h);
535 % $$$ end;
536 % $$$
537 % $$$ clear A5; % for V2
538 % $$$ A5 = sparse([],[],[],p,p,7*p);
539 % $$$ for m=1:p;
540 % $$$ A5(m,m)= -X(1,m)^h/(M2^h+X(1,m)^h);
541 % $$$ j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)+1));
542 % $$$ A5(j,m) = X(1,m)^h/(M2^h+X(1,m)^h);
543 % $$$ end;
544 % $$$
545 % $$$ % state space of the nominal system
546 % $$$ A = full(A);
547 % $$$ B = eye(p);
548 % $$$ C = ones(1,p);
549 % $$$ D = zeros(1,p);
550 % $$$ sys=ss(A,B,C,D);
551 % $$$
552 % $$$ %Model reduction, sysb is a balanced realization for sys.sysb=T*sys*T^-1
553 % $$$ [sysb,g,T,Ti]= balreal(sys);
554 % $$$ n = 3;
555 % $$$ sysr = modred(sysb,[n:p],'del');
556 % $$$ a1 = eye(n-1);
557 % $$$ a2 = zeros(p-n+1,n-1);
558 % $$$ V = T^-1*[a1;a2];
559 % $$$ W = T'*[a1;a2];
560 % $$$
561 % $$$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 % $$$ % compare the reduced system with different parameters with the original system
563 % $$$
564 % $$$ for i = 1:10
565 % $$$ % Ar = k1*A1r+u1*A2r+u2*A3r+V1*A4r+V2*A5r
566 % $$$ % Air = W'*Ai*V
567 % $$$ Ar = parameterlist(i,1)*W'*A1*V + parameterlist(i,2)*W'*A2*V + parameterlist(i,3)*W'*A3*V + parameterlist(i,4)*W'*A4*V + parameterlist(i,5)*W'*A5*V;
568 % $$$ Cr = C*V;
569 % $$$
570 % $$$ % original system
571 % $$$ a1 = @(x) (parameterlist(i,1)+parameterlist(i,4)*x(2)^h/(M1^h+x(2)^h));
572 % $$$ a2 = @(x) parameterlist(i,2)*x(1);
573 % $$$ a3 = @(x) parameterlist(i,5)*x(1)^h/(M2^h+x(1)^h);
574 % $$$ a4 = @(x) parameterlist(i,3)*x(2);
575 % $$$
576 % $$$ A = sparse([],[],[],p,p,7*p);
577 % $$$ for m=1:p
578 % $$$ A(m,m) = -(a1(X(:,m))+a2(X(:,m))+a3(X(:,m))+a4(X(:,m)));
579 % $$$ j = find((X(1,:)==X(1,m)+1) & (X(2,:)==X(2,m)));
580 % $$$ A(j,m) = a1(X(:,m));
581 % $$$ j = find((X(1,:)==X(1,m)-1) & (X(2,:)==X(2,m)));
582 % $$$ A(j,m) = a2(X(:,m));
583 % $$$ j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)+1));
584 % $$$ A(j,m) = a3(X(:,m));
585 % $$$ j = find((X(1,:)==X(1,m)) & (X(2,:)==X(2,m)-1));
586 % $$$ A(j,m) = a4(X(:,m));
587 % $$$ end;
588 % $$$
589 % $$$
590 % $$$ subplot(4,3,i);
591 % $$$ x0=zeros(p,1);
592 % $$$ x0(1)=1;
593 % $$$ [t,x]=ode15s(@(t,x) A*x, [0 1000000], x0);
594 % $$$ plot(t,sum(x'),'r');
595 % $$$ grid on;
596 % $$$ hold on;
597 % $$$
598 % $$$ % reduced system
599 % $$$ x1=T*x0;
600 % $$$ x2=x1(1:(n-1),:);
601 % $$$ [tr,xr]=ode15s(@(tr,xr) Ar*xr, [0 1000000], x2);
602 % $$$
603 % $$$ clear y;
604 % $$$ for m = 1:size(xr,1)
605 % $$$ y(m)=sysr.c*xr(m,:)';
606 % $$$ end;
607 % $$$ plot(tr,y);
608 % $$$ hold on;
609 % $$$ xlabel('zeit t');
610 % $$$ ylabel('y');
611 % $$$
612 % $$$ end;
613 % $$$
614 % $$$
615 % $$$
616 % $$$
617 % $$$
618 %| \docupdate
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 [ RBext , dummy ] = RB_extension_PCA_fixspace(model, detailed_data)
function computing a RB basis extension for given parameters by the POD-Greedy algorithm.
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.
function model = follicle_model(params)
model of the human follicle growth
A cartesian rectangular grid in two dimensions with axis parallel elements.
Definition: rectgrid.m:17
function save_detailed_simulations(model, model_data, M, savepath)
perform loop over detailed simulations and save results or check consistency with existing saved resu...