41 this =
this@models.pcdi.BaseCoreFun(dynsys);
46 copy = models.pcdi.CoreFun2D(this.
System);
49 copy =
clone@models.pcdi.BaseCoreFun(
this, copy);
51 copy.nodes= this.
nodes;
70 this.
hlp.d1= s.Dims(1);
71 this.
hlp.d2= s.Dims(2);
73 this.
idxmat= zeros(s.Dims(1),s.Dims(2));
80 this.
hlp.xr= a(1,2)-a(1,1);
82 this.
hlp.yr= a(2,2)-a(2,1);
84 this.
hlp.xd= abs(((1:this.
hlp.d1)-1)*
this.System.h-.5*
this.hlp.xr)^
t;
86 this.
hlp.yd= abs(((1:this.
hlp.d2)-1)*
this.System.h-.5*
this.hlp.yr)^
t;
92 i = repmat(this.
nodepos(1),1,3);
96 i = [i repmat(this.
nodepos(2),1,3)];
100 i = [i repmat(this.
nodepos(3),1,2)];
104 i = [i repmat(this.
nodepos(4),1,2)];
131 rc = this.
System.ReacCoeff;
144 pos = this.
hlp.xd <= this.
hlp.xr*
mu(1)/2;
146 rb(idx) = (xi(idx)*
mu(2)*ud);
148 pos = this.
hlp.xd <= this.
hlp.xr*
mu(1)/2;
149 idx = this.
idxmat(pos,end);
150 rb(idx) = rb(idx) + (xi(idx)*
mu(2)*ud);
154 pos = this.
hlp.yd <= this.
hlp.yr*
mu(1)/2;
155 idx = this.
idxmat(end,pos);
156 rb(idx) = rb(idx) + (xi(idx)*
mu(2)*ud);
158 pos = this.
hlp.yd <= this.
hlp.yr*
mu(1)/2;
160 rb(idx) = rb(idx) + (xi(idx)*
mu(2)*ud);
166 fx(1:m) = rc(2)*xi.*ya - rc(5)*xa + rb/this.
hlp.hs;
168 fx(m+1:2*m) = rc(1)*yi.*xan - rc(6)*ya;
170 fx(2*m+1:3*m) = -rc(2)*xi.*ya - rc(9)*xi + rc(16) - rb/this.
hlp.hs;
172 fx(3*m+1:end) = -rc(1)*yi.*xan - rc(10)*yi + rc(17);
196 rc = this.
System.ReacCoeff;
200 xan = bsxfun(@power,xa,
mu(4,:));
210 xd = repmat(this.
hlp.xd,1,nd);
213 pos = bsxfun(@lt,xd,this.
hlp.xr*mu(1,:)/2);
215 rb(idx,:) = pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
217 pos = bsxfun(@lt,xd,this.
hlp.xr*mu(1,:)/2);
219 rb(idx,:) = rb(idx,:) + pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
222 yd = repmat(this.
hlp.yd,1,nd);
224 pos = bsxfun(@lt,yd,this.
hlp.yr*mu(1,:)/2);
226 rb(idx,:) = rb(idx,:) + pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
228 pos = bsxfun(@lt,yd,this.
hlp.yr*mu(1,:)/2);
230 rb(idx,:) = rb(idx,:) + pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
233 fx(1:m,:) = rc(2)*xi.*ya - xa*rc(5) + rb/this.
hlp.hs;
235 fx(m+1:2*m,:) = rc(1)*yi.*xan - ya*rc(6);
237 fx(2*m+1:3*m,:) = -rc(2)*xi.*ya - rc(9)*xi + rc(16) - rb/this.
hlp.hs;
239 fx(3*m+1:end,:) = -rc(1)*yi.*xan - rc(10)*yi + rc(17);
261 rc = this.
System.ReacCoeff;
264 bottom = this.
idxmat(this.
hlp.xd <=
this.hlp.xr*
mu(1)/2,1);
265 top = this.
idxmat(this.
hlp.xd <=
this.hlp.xr*
mu(1)/2,end);
266 right = this.
idxmat(end,this.
hlp.yd <=
this.hlp.yr*
mu(1)/2);
267 left = this.
idxmat(1,this.
hlp.yd <=
this.hlp.yr*
mu(1)/2);
270 rbxi(bottom) =
mu(2)*u;
272 rbxi(right) =
mu(2)*u;
273 rbxi(left) =
mu(2)*u;
274 rbxi = rbxi/this.
hlp.hs;
277 posi =
reshape(1:4*n
" ,[],4) ";
279 xa = x(posi(1,:)); ya = x(posi(2,:));
280 xi = x(posi(3,:)); yi = x(posi(4,:));
291 nyixan_1 =
mu(4)*rc(1)*yi.*xa.^(
mu(4)-1);
292 k1xan = rc(1)*xa.^
mu(4);
293 s = [s; nyixan_1; ...
300 s = [s; -rc(2)*xi;...
302 -rc(2)*xa-rc(9)-rbxi];
305 s = [s; -nyixan_1; ...
318 J = sparse(this.
Ji,this.
Jj,s,n,m);
332 fxj = zeros(length(pts),nd);
333 rc = this.
System.ReacCoeff;
335 bottom = bsxfun(@lt,this.
hlp.xd,
this.hlp.xr*mu(1,:)/2);
336 top = bsxfun(@lt,this.
hlp.xd,
this.hlp.xr*mu(1,:)/2);
337 right = bsxfun(@lt,this.
hlp.yd,
this.hlp.yr*mu(1,:)/2);
338 left = bsxfun(@lt,this.
hlp.yd,
this.hlp.yr*mu(1,:)/2);
340 bottom = this.
hlp.xd <= this.
hlp.xr*
mu(1,:)/2;
341 top = this.
hlp.xd <= this.
hlp.xr*
mu(1,:)/2;
342 right = this.
hlp.yd <= this.
hlp.yr*
mu(1,:)/2;
343 left = this.
hlp.yd <= this.
hlp.yr*
mu(1,:)/2;
351 row = rem(J2-1, this.
hlp.d1)+1;
352 col = (J2-row)/this.
hlp.d1+1;
353 u =
this.activationFun(t, mu);
354 for idx=1:length(pts)
362 xidx = (st+1):ends(idx);
369 fj = rc(2)*x(3,:).*x(2,:) - rc(5)*x(1,:);
374 fj = fj + bottom(row(idx),:) .* (x(3,:).*
mu(2,:).*u/this.
hlp.hs);
377 if col(idx) == this.
hlp.d2
378 fj = fj + top(row(idx),:) .* (x(3,:).*
mu(2,:).*u/this.
hlp.hs);
381 if row(idx) == this.
hlp.d1
382 fj = fj + right(col(idx),:) .* (x(3,:).*
mu(2,:).*u/this.
hlp.hs);
386 fj = fj + left(col(idx),:) .* (x(3,:).*
mu(2,:).*u/this.
hlp.hs);
390 elseif m < j && j <= 2*m
393 fj = rc(1)*x(3,:).*x(1,:).^
mu(4,:) - rc(6)*x(2,:);
396 elseif 2*m < j && j <= 3*m
399 fj = -rc(2)*x(2,:).*x(1,:) - rc(9)*x(2,:) + rc(16);
404 fj = fj - bottom(row(idx),:) .* (x(2,:).*
mu(2,:).*u/this.
hlp.hs);
407 if col(idx) == this.
hlp.d2
408 fj = fj - top(row(idx),:) .* (x(2,:).*
mu(2,:).*u/this.
hlp.hs);
411 if row(idx) == this.
hlp.d1
412 fj = fj - right(col(idx),:) .* (x(2,:).*
mu(2,:).*u/this.
hlp.hs);
416 fj = fj - left(col(idx),:) .* (x(2,:).*
mu(2,:).*u/this.
hlp.hs);
423 fj = -rc(1)*x(2,:).*x(1,:).^
mu(4,:) - rc(10)*x(2,:) + rc(17);
451 error(
" Activation fun not yet implemented correctly ");
453 rc = this.
System.ReacCoeff;
460 row = rem(pts2-1, this.
hlp.d1)+1;
461 col = (pts2-row)/this.
hlp.d1+1;
463 bottom = bsxfun(@lt,this.
hlp.xd,
this.hlp.xr*mu(1)/2);
464 top = bsxfun(@lt,this.
hlp.xd,
this.hlp.xr*mu(1)/2);
465 right = bsxfun(@lt,this.
hlp.yd,
this.hlp.yr*mu(1)/2);
466 left = bsxfun(@lt,this.
hlp.yd,
this.hlp.yr*mu(1)/2);
468 bottom = this.
hlp.xd <= this.
hlp.xr*
mu(1)/2;
469 top = this.
hlp.xd <= this.
hlp.xr*
mu(1)/2;
470 right = this.
hlp.yd <= this.
hlp.yr*
mu(1)/2;
471 left = this.
hlp.yd <= this.
hlp.yr*
mu(1)/2;
475 der =
false(size(X,1),1);
479 dfx = zeros(size(deriv,1),nd);
481 for idx=1:length(pts)
489 elem = (st+1):ends(idx);
498 dfx(curpos,:) = -rc(5);
503 dfx(curpos,:) = rc(2)*x(3,:);
508 dfx(curpos,:) = rc(2)*x(2,:);
511 dfx(curpos,:) = dfx(curpos,:) + bottom(row(idx),:) .*
mu(2,:)/this.
hlp.hs;
513 if col(idx) == this.
hlp.d2
515 dfx(curpos,:) = dfx(curpos,:) + top(row(idx),:) .*
mu(2,:)/this.
hlp.hs;
517 if row(idx) == this.
hlp.d1
519 dfx(curpos,:) = dfx(curpos,:) + right(col(idx),:) .*
mu(2,:)/this.
hlp.hs;
523 dfx(curpos,:) = dfx(curpos,:) + left(col(idx),:) .*
mu(2,:)/this.
hlp.hs;
529 elseif m < i && i <= 2*m
533 dfx(curpos,:) =
mu(4,:)*rc(1)*x(3,:).*x(1,:).^(
mu(4,:)-1);
538 dfx(curpos,:) = -rc(6);
543 dfx(curpos,:) = rc(1)*x(1,:).^
mu(4,:);
548 elseif 2*m < i && i <= 3*m
552 dfx(curpos,:) = -rc(2)*x(2,:);
557 dfx(curpos,:) = -rc(2)*x(1,:)-rc(9);
561 dfx(curpos,:) = dfx(curpos,:) - bottom(row(idx),:) .*
mu(2,:)/this.
hlp.hs;
563 if col(idx) == this.
hlp.d2
565 dfx(curpos,:) = dfx(curpos,:) - top(row(idx),:) .*
mu(2,:)/this.
hlp.hs;
567 if row(idx) == this.
hlp.d1
569 dfx(curpos,:) = dfx(curpos,:) - right(col(idx),:) .*
mu(2,:)/this.
hlp.hs;
573 dfx(curpos,:) = dfx(curpos,:) - left(col(idx),:) .*
mu(2,:)/this.
hlp.hs;
583 dfx(curpos,:) = -
mu(4,:)*rc(1)*x(2,:).*x(1,:).^(
mu(4,:)-1);
588 dfx(curpos,:) = -rc(1)*x(1,:).^
mu(4,:) - rc(10);
integer fDim
The current output dimension of the function.
function idx = nodepos(nr)
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
function fxj = evaluateComponentsMulti(rowvec< integer > pts,rowvec< integer > ends, unused1, unused2,matrix< double > X,double t,matrix< double > mu)
The vector embedding results from the fixed ordering of the full 4*m-vector into the components x_a...
integer xDim
The current state space dimension of the function's argument .
models.BaseFirstOrderSystem System
The system associated with the current ACoreFun.
function f = activationFun(double t,colvec< double > mu)
V
The matrix of the biorthogonal pair .
function fx = evaluateMulti(colvec< double > x, unused1,colvec< double > mu)
Allocate result vector.
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
function J = getStateJacobian(colvec< double > x,double t)
function dfx = evaluateComponentPartialDerivatives(rowvec< integer > pts,rowvec< integer > ends, unused1,rowvec< integer > deriv, unused2,colvec< double > X, unused3,colvec< double > mu, unused4)
See dscomponents.ACompEvalCoreFun for more details.
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
function copy = clone()
System already copied in constructor (see below)
function fx = evaluate(colvec< double > x,double t)
If this has been projected, restore full size and compute values.
The core nonlinear function of the PCD model.
function newSysDimension()
Create diffusion matrix.
W
The matrix of the biorthogonal pair .
function fxj = evaluateComponents(pts, ends, unused1, unused2, X,double t)