59 this =
this@models.pcd.BaseCoreFun(dynsys);
64 copy = models.pcd.CoreFun2D(this.
System);
67 copy =
clone@models.pcd.BaseCoreFun(
this, copy);
69 copy.nodes= this.nodes;
71 copy.idxmat= this.idxmat;
86 this.hlp.d1= s.Dims(1);
87 this.hlp.d2= s.Dims(2);
89 this.idxmat= zeros(s.Dims(1),s.Dims(2));
90 this.idxmat(:) = 1:this.nodes;
96 this.hlp.xr= a(1,2)-a(1,1);
98 this.hlp.yr= a(2,2)-a(2,1);
100 this.hlp.xd= abs(((1:this.hlp.d1)-1)*
this.System.h-.5*
this.hlp.xr)^
t;
102 this.hlp.yd= abs(((1:this.hlp.d2)-1)*
this.System.h-.5*
this.hlp.yr)^
t;
107 i = [(1:n)
" ; (1:n) "; (1:n)^
t];
111 i = [i; (n+1:2*n)
" ; (n+1:2*n) "; (n+1:2*n)^
t];
112 j = [j; (1:2*n)
" ; (3*n+1:4*n) "];
115 i = [i; (2*n+1:3*n)
" ; (2*n+1:3*n) "];
116 j = [j; (n+1:3*n)^
t];
119 i = [i; (3*n+1:4*n)
" ; (3*n+1:4*n) "];
120 j = [j; (1:n)
" ; (3*n+1:4*n) "];
146 rc = this.
System.ReacCoeff;
159 pos = this.hlp.xd <= this.hlp.xr*
mu(1)/2;
160 idx = this.idxmat(pos,1);
161 rb(idx) = (xi(idx)*
mu(2)*ud);
163 pos = this.hlp.xd <= this.hlp.xr*
mu(1)/2;
164 idx = this.idxmat(pos,end);
165 rb(idx) = rb(idx) + (xi(idx)*
mu(2)*ud);
169 pos = this.hlp.yd <= this.hlp.yr*
mu(1)/2;
170 idx = this.idxmat(end,pos);
171 rb(idx) = rb(idx) + (xi(idx)*
mu(2)*ud);
173 pos = this.hlp.yd <= this.hlp.yr*
mu(1)/2;
174 idx = this.idxmat(1,pos);
175 rb(idx) = rb(idx) + (xi(idx)*
mu(2)*ud);
178 fx(1:m) = rc(1)*xi.*ya - rc(3)*xa + rb/this.hlp.hs;
180 fx(m+1:2*m) = rc(2)*yi.*xan - rc(4)*ya;
182 fx(2*m+1:3*m) = -rc(1)*xi.*ya - rc(5)*xi + rc(7) - rb/this.hlp.hs;
184 fx(3*m+1:end) = -rc(2)*yi.*xan - rc(6)*yi + rc(8);
208 rc = this.
System.ReacCoeff;
222 xd = repmat(this.hlp.xd,1,nd);
225 pos = bsxfun(@lt,xd,this.hlp.xr*mu(1,:)/2);
226 idx = this.idxmat(:,1);
227 rb(idx,:) = pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
229 pos = bsxfun(@lt,xd,this.hlp.xr*mu(1,:)/2);
230 idx = this.idxmat(:,end);
231 rb(idx,:) = rb(idx,:) + pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
234 yd = repmat(this.hlp.yd,1,nd);
236 pos = bsxfun(@lt,yd,this.hlp.yr*mu(1,:)/2);
237 idx = this.idxmat(end,:);
238 rb(idx,:) = rb(idx,:) + pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
240 pos = bsxfun(@lt,yd,this.hlp.yr*mu(1,:)/2);
241 idx = this.idxmat(1,:);
242 rb(idx,:) = rb(idx,:) + pos .* (bsxfun(@times,xi(idx,:),
mu(2,:).*ud));
245 fx(1:m,:) = rc(1)*xi.*ya - xa*rc(3) + rb/this.hlp.hs;
247 fx(m+1:2*m,:) = rc(2)*yi.*xan - ya*rc(4);
249 fx(2*m+1:3*m,:) = -rc(1)*xi.*ya - rc(5)*xi + rc(7) - rb/this.hlp.hs;
251 fx(3*m+1:end,:) = -rc(2)*yi.*xan - rc(6)*yi + rc(8);
269 rc = this.
System.ReacCoeff;
272 bottom = this.idxmat(this.hlp.xd <=
this.hlp.xr*
mu(1)/2,1);
273 top = this.idxmat(this.hlp.xd <=
this.hlp.xr*
mu(1)/2,end);
274 right = this.idxmat(end,this.hlp.yd <=
this.hlp.yr*
mu(1)/2);
275 left = this.idxmat(1,this.hlp.yd <=
this.hlp.yr*
mu(1)/2);
278 rbxi(bottom) =
mu(2)*u;
280 rbxi(right) =
mu(2)*u;
281 rbxi(left) =
mu(2)*u;
282 rbxi = rbxi/this.hlp.hs;
286 i = [(1:n)
" ; (1:n) "; (1:n)^t];
288 s = [-ones(n,1)*rc(3); ...
290 rc(1)*x(2*n+1:3*n);...
292 rc(1)*x(n+1:2*n) + rbxi];
296 i = [i; (n+1:2*n)
" ; (n+1:2*n) "; (n+1:2*n)^t];
297 j = [j; (1:2*n)
" ; (3*n+1:4*n) "];
298 hlp1 =
mu(4)*rc(2)*x(3*n+1:end).*x(1:n).^(
mu(4)-1);
299 hlp2 = rc(2)*x(1:n).^
mu(4);
309 i = [i; (2*n+1:3*n)
" ; (2*n+1:3*n) "];
310 j = [j; (n+1:3*n)^t];
311 s = [s; -rc(1)*x(2*n+1:3*n);...
313 -rc(1)*x(n+1:2*n)-rc(5)-rbxi];
318 i = [i; (3*n+1:4*n)
" ; (3*n+1:4*n) "];
319 j = [j; (1:n)
" ; (3*n+1:4*n) "];
333 J = sparse(i,j,s,n,m);
347 fxj = zeros(length(pts),nd);
348 rc = this.
System.ReacCoeff;
350 bottom = bsxfun(@lt,this.hlp.xd,
this.hlp.xr*mu(1,:)/2);
351 top = bsxfun(@lt,this.hlp.xd,
this.hlp.xr*mu(1,:)/2);
352 right = bsxfun(@lt,this.hlp.yd,
this.hlp.yr*mu(1,:)/2);
353 left = bsxfun(@lt,this.hlp.yd,
this.hlp.yr*mu(1,:)/2);
355 bottom = this.hlp.xd <= this.hlp.xr*
mu(1,:)/2;
356 top = this.hlp.xd <= this.hlp.xr*
mu(1,:)/2;
357 right = this.hlp.yd <= this.hlp.yr*
mu(1,:)/2;
358 left = this.hlp.yd <= this.hlp.yr*
mu(1,:)/2;
366 row = rem(J2-1, this.hlp.d1)+1;
367 col = (J2-row)/this.hlp.d1+1;
368 u =
this.activationFun(t, mu);
369 for idx=1:length(pts)
377 xidx = (st+1):ends(idx);
384 fj = rc(1)*x(3,:).*x(2,:) - rc(3)*x(1,:);
389 fj = fj + bottom(row(idx),:) .* (x(3,:).*
mu(2,:).*u/this.hlp.hs);
392 if col(idx) == this.hlp.d2
393 fj = fj + top(row(idx),:) .* (x(3,:).*
mu(2,:).*u/this.hlp.hs);
396 if row(idx) == this.hlp.d1
397 fj = fj + right(col(idx),:) .* (x(3,:).*
mu(2,:).*u/this.hlp.hs);
401 fj = fj + left(col(idx),:) .* (x(3,:).*
mu(2,:).*u/this.hlp.hs);
405 elseif m < j && j <= 2*m
408 fj = rc(2)*x(3,:).*x(1,:).^
mu(4,:) - rc(4)*x(2,:);
411 elseif 2*m < j && j <= 3*m
414 fj = -rc(1)*x(2,:).*x(1,:) - rc(5)*x(2,:) + rc(7);
419 fj = fj - bottom(row(idx),:) .* (x(2,:).*
mu(2,:).*u/this.hlp.hs);
422 if col(idx) == this.hlp.d2
423 fj = fj - top(row(idx),:) .* (x(2,:).*
mu(2,:).*u/this.hlp.hs);
426 if row(idx) == this.hlp.d1
427 fj = fj - right(col(idx),:) .* (x(2,:).*
mu(2,:).*u/this.hlp.hs);
431 fj = fj - left(col(idx),:) .* (x(2,:).*
mu(2,:).*u/this.hlp.hs);
438 fj = -rc(2)*x(2,:).*x(1,:).^
mu(4,:) - rc(6)*x(2,:) + rc(8);
466 error(
" Activation fun not yet implemented correctly ");
468 rc = this.
System.ReacCoeff;
475 row = rem(pts2-1, this.hlp.d1)+1;
476 col = (pts2-row)/this.hlp.d1+1;
478 bottom = bsxfun(@lt,this.hlp.xd,
this.hlp.xr*mu(1)/2);
479 top = bsxfun(@lt,this.hlp.xd,
this.hlp.xr*mu(1)/2);
480 right = bsxfun(@lt,this.hlp.yd,
this.hlp.yr*mu(1)/2);
481 left = bsxfun(@lt,this.hlp.yd,
this.hlp.yr*mu(1)/2);
483 bottom = this.hlp.xd <= this.hlp.xr*
mu(1)/2;
484 top = this.hlp.xd <= this.hlp.xr*
mu(1)/2;
485 right = this.hlp.yd <= this.hlp.yr*
mu(1)/2;
486 left = this.hlp.yd <= this.hlp.yr*
mu(1)/2;
490 der =
false(size(X,1),1);
494 dfx = zeros(size(deriv,1),nd);
496 for idx=1:length(pts)
504 elem = (st+1):ends(idx);
513 dfx(curpos,:) = -rc(3);
518 dfx(curpos,:) = rc(1)*x(3,:);
523 dfx(curpos,:) = rc(1)*x(2,:);
526 dfx(curpos,:) = dfx(curpos,:) + bottom(row(idx),:) .*
mu(2,:)/this.hlp.hs;
528 if col(idx) == this.hlp.d2
530 dfx(curpos,:) = dfx(curpos,:) + top(row(idx),:) .*
mu(2,:)/this.hlp.hs;
532 if row(idx) == this.hlp.d1
534 dfx(curpos,:) = dfx(curpos,:) + right(col(idx),:) .*
mu(2,:)/this.hlp.hs;
538 dfx(curpos,:) = dfx(curpos,:) + left(col(idx),:) .*
mu(2,:)/this.hlp.hs;
544 elseif m < i && i <= 2*m
548 dfx(curpos,:) =
mu(4,:)*rc(2)*x(3,:).*x(1,:).^(
mu(4,:)-1);
553 dfx(curpos,:) = -rc(4);
558 dfx(curpos,:) = rc(2)*x(1,:).^
mu(4,:);
563 elseif 2*m < i && i <= 3*m
567 dfx(curpos,:) = -rc(1)*x(2,:);
572 dfx(curpos,:) = -rc(1)*x(1,:)-rc(5);
576 dfx(curpos,:) = dfx(curpos,:) - bottom(row(idx),:) .*
mu(2,:)/this.hlp.hs;
578 if col(idx) == this.hlp.d2
580 dfx(curpos,:) = dfx(curpos,:) - top(row(idx),:) .*
mu(2,:)/this.hlp.hs;
582 if row(idx) == this.hlp.d1
584 dfx(curpos,:) = dfx(curpos,:) - right(col(idx),:) .*
mu(2,:)/this.hlp.hs;
588 dfx(curpos,:) = dfx(curpos,:) - left(col(idx),:) .*
mu(2,:)/this.hlp.hs;
598 dfx(curpos,:) = -
mu(4,:)*rc(2)*x(2,:).*x(1,:).^(
mu(4,:)-1);
603 dfx(curpos,:) = -rc(2)*x(1,:).^
mu(4,:) - rc(6);
635 if ~isa(obj,
" models.pcd.CoreFun2D ")
638 if isfield(from,
" sys ")
641 obj = models.pcd.CoreFun2D(s);
642 obj.nodes= from.nodes;
644 obj.idxmat= from.idxmat;
645 obj =
loadobj@models.pcd.BaseCoreFun(obj, from);
647 obj =
loadobj@models.pcd.BaseCoreFun(obj);
integer fDim
The current output dimension of the function.
function J = getStateJacobian(colvec< double > x,double t)
function fxj = evaluateComponents(pts, ends, unused1, unused2, X,double t)
integer xDim
The current state space dimension of the function's argument .
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.
models.BaseFirstOrderSystem System
The system associated with the current ACoreFun.
V
The matrix of the biorthogonal pair .
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
static function obj = loadobj(obj)
function copy = clone()
System already copied in constructor (see below)
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
function newSysDimension()
Create diffusion matrix.
function f = activationFun(double t,colvec< double > mu)
function fx = evaluateMulti(colvec< double > x,double t,colvec< double > mu)
W
The matrix of the biorthogonal pair .
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...
function fx = evaluate(colvec< double > x,double t)
The core nonlinear function of the PCD model.