adding advection to Gray--Scott example

41 views
Skip to first unread message

punit....@gmail.com

unread,
Nov 23, 2016, 1:39:46 PM11/23/16
to chebfun-users
Hi,

I am interested in integrating a pde on a 2d domain that has a u_x term in it.   As a test, I tried to add such a term to the Gray--Scott example from the documentation.  

----------------------------------------------------
ep1 = 0.00002; ep2 = 0.00001;
b = 0.04; d = 0.1;
c=0.000001;

dom = [-1 1 -1 1]; x = chebfun('x',dom(1:2)); tspan = [0 3500];
S = spinop2(dom,tspan);
%S.linearPart = @(u,v) [ep1*lap(u); ep2*lap(v)];
S.linearPart = @(u,v) [ep1*lap(u)+c*diffx(u); ep2*lap(v)];
S.nonlinearPart = @(u,v) [b*(1-u)-u.*v.^2;-d*v+u.*v.^2];
S.init = chebfun2v(@(x,y) 1-exp(-80*((x+.05).^2+(y+.02).^2)), ...
                   @(x,y) exp(-80*((x-.05).^2+(y-.02).^2)),dom);
pause off
tic, u = spin2(S,'N',200,'dt',2,'plot','off');
plot(u{2}), view(0,90), axis equal, axis off
time_in_seconds = toc
---------------------------------------------------


I get the following errors when I run it:
----------------------------------------------------
Undefined function 'diffx' for input arguments of type 'double'.

Error in spinop2/discretize/@(u,v)[ep1*(u)+c*diffx(u);ep2*(v)]



Error in spinop2/discretize (line 143)
A = feval(func, inputs{:});

Error in spinoperator.solvepde (line 216)
[L, Nc] = discretize(S, N);

Error in spin2 (line 142)
[uout, tout] = spinoperator.solvepde(varargin{:});
----------------------------------------------------


I also tried diff(u,1,2) instead of diffx(u) and got the errors:
----------------------------------------------------
Attempted to access A(2); index out of bounds because numel(A)=1.

Error in spinop2/discretize (line 203)
    L = [L; A(k)*lapmat + B(k)*bihmat + C(k)*trihmat + D(k)*quadhmat + ...

Error in spinoperator.solvepde (line 216)
[L, Nc] = discretize(S, N);

Error in spin2 (line 142)
[uout, tout] = spinoperator.solvepde(varargin{:});
----------------------------------------------------

I'm also curious if there is a reason why the terms -b*u and -d*v are included in S.nonlinearPart instead of S.linearPart?   This is my first time playing with chebfun, so any help would be appreciated.  Thanks!

Punit


Hadrien Montanelli

unread,
Dec 16, 2016, 10:09:37 AM12/16/16
to chebfun-users, punit....@gmail.com
Dear Punit,

It's not possible to do this for the moment but we hope to add these capabilities soon. This and the fact that the -b*u and -b*v terms have to be included in the nonlinear part are related to parsing issues. 

Best,
Hadrien

Lisa Lin

unread,
Aug 25, 2023, 9:03:42 PM8/25/23
to chebfun-users
Hi,

Just wondering if there have been any updates to this? I just recently tried the same and got the same error message that was posted earlier. I also wanted to add a mixed derivative term to the second equation, i.e.
S.nonlin = @(u,v) [b*(1-u)-u.*v.^2;-d*v+u.*v.^2 + diff(u,[1,1])];
However, I then got a separate error message that seemed to confuse chebfun2's diff function with MATLAB's:
"Error using diff
Difference order N must be a positive integer scalar."
Is the reason I received such an error because this functionality is also not supported for 2D PDE's? Also a new Chebfun user, so any pointers would be much appreciated! :-)

Lisa

Reply all
Reply to author
Forward
0 new messages