KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PCDSystem3D.m
Go to the documentation of this file.
1 namespace models{
2 namespace pcd{
3 
4 
5 /* (Autoinserted by mtoc++)
6  * This source code has been filtered by the mtoc++ executable,
7  * which generates code that can be processed by the doxygen documentation tool.
8  *
9  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
10  * Except for the comments, the function bodies of your M-file functions are untouched.
11  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
12  * attached source files that are highly readable by humans.
13  *
14  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
15  * the correct locations in the source code browser.
16  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
17  */
18 
20  :public models.pcd.BasePCDSystem {
38  public:
39 
40  geo;
41 
42 
43  public:
44 
46  this = this@models.pcd.BasePCDSystem(model);
47 
48  /* Set core function */
49  this.f= models.pcd.CoreFun3D(this);
50 
51  /* Spatial area [X, Y, Z] */
52  this.Omega= [0 1; 0 1; 0 1] * this.Model.L;
53  this.h= this.Model.L/6;
54 
55  /* Add params */
56  rate_max = 1e-4;
57  /* Param indices 9-14 */
58  this.addParam(" area_front ", .5, " Range ", [.3, .8], " Desired ", 3);
59  this.addParam(" area_back ", 0, " Range ", [0, 0], " Desired ", 2);
60  this.addParam(" area_left ", .5, " Range ", [.3, .8]," Desired ", 3);
61  this.addParam(" area_right ", 0, " Range ", [0, 0], " Desired ", 2);
62  this.addParam(" area_top ", .5, " Range ", [.3, .8], " Desired ", 2);
63  this.addParam(" area_bottom ", 0, " Range ", [0, 0], " Desired ", 2);
64  /* Param indices 15-20 */
65  this.addParam(" rate_front ", rate_max/2, " Range ", [0, rate_max], " Desired ", 4);
66  this.addParam(" rate_back ", rate_max/2, " Range ", [0, rate_max], " Desired ", 1);
67  this.addParam(" rate_left ", rate_max/2, " Range ", [0, rate_max], " Desired ", 4);
68  this.addParam(" rate_right ", rate_max/2, " Range ", [0, rate_max], " Desired ", 1);
69  this.addParam(" rate_top ", rate_max/2, " Range ", [0, rate_max], " Desired ", 4);
70  this.addParam(" rate_bottom ", rate_max/2, " Range ", [0, rate_max], " Desired ", 1);
71  }
72 
73 
75 
76  autocols = true;
77  plotback = false;
78 
79  m = prod(this.Dims);
80  xa = v(1:m,:);
81  ya = v(m+1:2*m,:);
82  xi = v(2*m+1:3*m,:);
83  yi = v(3*m+1:end,:);
84  b = [min(xa(:)) max(xa(:)); min(ya(:)) max(ya(:));...
85  min(xi(:)) max(xi(:)); min(yi(:)) max(yi(:))];
86  /* % Prepare figures */
87  f1 = figure(1); rotate3d on;
88  f2 = figure(2); rotate3d on;
89  hlpf = figure(" Visible "," off "," MenuBar "," none "," ToolBar "," none ");
90  hlpax = newplot(hlpf);
91  ax = [];
92  caps = [" Caspase-8 "," Caspase-3 "," Pro-Caspase-8 "," Pro-Caspase-3 "];
93  for p = 1:4
94  figure(f1);
95  a = subplot(2,2,p);
96  cla(a);
97  set(a," Box "," on "," GridLineStyle "," none ");
98  if ~autocols
99  set(a," CLimMode "," manual "," CLim ",b(p,:));
100  end
101  view(a,-22,31);
102  axis ij;
103  axis(a,reshape(this.Omega^t,1,[]));
104  xlabel(a," Left to right ");
105  ylabel(a," Top to bottom ");
106  zlabel(a," Front to back ");
107  title(a,sprintf(" Model '%s', %s concentrations ", model.Name, caps[p]));
108  colorbar(" peer ",a);
109  ax(end+1) = a;/* #ok */
110 
111 
112  figure(f2);
113  a = subplot(2,2,p);
114  set(a," Box "," on "," GridLineStyle "," none ");
115  if ~autocols
116  set(a," CLimMode "," manual "," CLim ",b(p,:));
117  end
118  view(a,-22,31);
119  axis ij;
120  axis(a,reshape(this.Omega^t,1,[]));
121  xlabel(a," Left to right ");
122  ylabel(a," Top to bottom ");
123  zlabel(a," Front to back ");
124  title(a,sprintf(" Model '%s', %s concentrations ", model.Name, caps[p]));
125  colorbar(" peer ",a);
126  ax(end+1) = a;/* #ok */
127 
128  end
129 
130  /* % Plot timesteps */
131  a = this.Omega;
132  x = a(1,1):this.h:a(1,2);
133  y = a(2,1):this.h:a(2,2);
134  z = a(3,1):this.h:a(3,2);
135  [X,Y,Z] = meshgrid(x,y,z);
136  xpos = mean(x); ypos = mean(y); zpos = mean(z);
137 
138  step = round(length(t)/40);
139  for idx=1:step:length(t)
140  h1 = doplot(xa(:,idx),ax(1:2));
141  h2 = doplot(ya(:,idx),ax(3:4));
142  h3 = doplot(xi(:,idx),ax(5:6));
143  h4 = doplot(yi(:,idx),ax(7:8));
144  set(f1," Name ",sprintf(" Plot at t=%f ",t(idx)));
145  set(f2," Name ",sprintf(" Plot at t=%f ",t(idx)));
146  if idx ~= length(t)
147  pause(1);
148  delete([h1; h2; h3; h4]);
149  end
150  end
151 
152  close(hlpf);
153 
154  function h = doplot(zd, ax)
155  V = reshape(zd,this.Dims(1),this.Dims(2),[]);
156  /* permute(V,[1 3 2]); */
157 
158  hc = contourslice(ax(1),X,Y,Z,V,[],0:.2:1,[]); /* 'EdgeColor','none' */
159 
160 
161  /* bugfix: constant nonzero values cause slice to crash when
162  * setting the clim property. */
163  if V(1) ~= 0 && all(V(1) == V(:))
164  V(1) = 1.0001*V(1);
165  end
166  hs = slice(hlpax,X,Y,Z,V,xpos,ypos,zpos);
167  set(hs," Parent ",ax(2)," FaceColor "," interp "," EdgeColor "," none ");
168  if plotback
169  hs2 = slice(hlpax,X,Y,Z,V,a(1,2),a(2,1),a(3,1));
170  set(hs2," Parent ",ax(2)," FaceColor "," interp "," EdgeColor "," none ");
171  hs = [hs; hs2];
172  end
173  h = [hc; hs];
174  end
175  }
189  protected:
190 
191  function newSysDimension() {
192  m = prod(this.Dims);
193  x0 = zeros(4*m,1);
194  x0(1:2*m) = 1e-16;
195  x0(2*m+1:end) = 1e-9;
196  this.x0= dscomponents.ConstInitialValue(x0);
197 
198  d = this.Dims;
199  ge = general.geometry.RectGrid3D(d(1),d(2),d(3));
200  this.geo= ge;
201  A = MatUtils.laplacemat3D(this.h, ge);
202  D = this.Diff;
203  A = blkdiag(A,D(1)*A,D(2)*A,D(3)*A);
204  this.A= dscomponents.LinearCoreFun(A);
205 
206 /* [i,j] = find(this.A);
207  * i = [i; i+n; i+2*n; i+3*n];
208  * j = [j; j+n; j+2*n; j+3*n];
209  * this.JSparsityPattern = sparse(i,j,ones(length(i),1),4*n,4*n); */
210 
211  p = .1; /* 10% of each dimensions span, centered in geometry. */
212 
213  d = this.Dims(1);
214  d1idx = find(abs((1:d) - d/2) <= d/2 * p);
215  d = this.Dims(2);
216  d2idx = find(abs((1:d) - d/2) <= d/2 * p);
217  d = this.Dims(3);
218  d3idx = find(abs((1:d) - d/2) <= d/2 * p);
219  [d1,d2,d3] = meshgrid(d1idx,d2idx,d3idx);
220  sel = reshape(sub2ind([this.Dims(1),this.Dims(2),this.Dims(3)],d1,d2,d3),1,[]);
221  C = zeros(1,4*m);
222  ca3 = m+1:2*m;
223  C(ca3(sel)) = 1/length(sel);
224  this.C= dscomponents.LinearOutputConv(C);
225  }
226 
227 
228 };
229 }
230 }
231 
232 
233 
char Name
The name of the Model.
Definition: BaseModel.m:117
PCDSYSTEM3D 3D implementation of the cell apoptosis model.
Definition: PCDSystem3D.m:19
h
Spatial stepwidth (in unscaled size units!) is set in subclasses.
Definition: BasePCDSystem.m:62
PCDSystem3D(models.BaseFullModel model)
Definition: PCDSystem3D.m:45
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
A matlab matrix.
Model
The Model this System is attached to.
hs
scaled spatial stepwidth
Dims
The system's dimensions.
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
LinearCoreFun(A)
No system reference needed for constant linear core fun.
Definition: LinearCoreFun.m:43
dscomponents.AInitialValue x0
Function handle to initial state evaluation.
#define X(i, j)
Speed test * all(1:3)
dscomponents.LinearOutputConv C
The output conversion Defaults to an LinearOutputConv instance using a 1-matrix, which just forwards ...
dscomponents.ACoreFun f
The core f function from the dynamical system.
MatUtils: Matrix utility functions.
Definition: MatUtils.m:17
#define Y(i, j)
A matlab row vector.
function plotState(models.BaseFullModel model,rowvec t,matrix v)
Performs a plot for this model's results.
Definition: PCDSystem3D.m:74
Omega
The spatial width/area/region (in unscaled size units!)
Definition: BasePCDSystem.m:78
function ModelParam p = addParam(char name, default, varargin)
Adds a parameter with the given values to the parameter collection of the current dynamical system...
PCDSYSTEM The 2D dynamical system of the Programmed Cell Death Model by Markus Daub.
Definition: BasePCDSystem.m:19
dscomponents.LinearCoreFun A
Represents a linear or affine-linear component of the dynamical system.
function newSysDimension()
Custom updates for new system dimension.
Definition: PCDSystem3D.m:191
Diff
Relative diffusion coefficients ([d2/d1, d3/d1, d4/d1])
static function A = laplacemat3D(h, g)
Computes a 3D laplacian sparse matrix.
Definition: MatUtils.m:187