How do I use the function PDENONLIN from the The Partial Differential Equation (PDE) Toolbox 1.0.4 (R13)?

1 view (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The most commonly encountered problem when using PDENONLIN occurs by not passing the input arguments correctly.
In an equation such as the following:
-div(c*grad(u))+a*u=f
you can use PDENONLIN as follows:
[U,RES]=PDENONLIN(B,P,E,T,C,A,F)
The B matrix is a boundary matrix, not a geometry matrix. For more information, see the Related Solution at the botom of the page.
P,E,T are the usual quantities when dealing with a PDE. C,A,F in PDENONLIN may be functions of u, and so you can either enter them as scalar quantities or as character arrays.
As an example, to solve the following equation:
-div(grad(u)) + u^3 = 0
you can use the following code:
% this is an example of how to use PDENONLIN
[p,e,t] = initmesh('circleg');
% this defines a unit circle as the surface we simulate the PDE on
% this also has the simple boundary condition u = 0, on the boundary
% you can view the details of the mfile, by typing "edit cricleg.m"
[p,e,t] = refinemesh('circleg',p,e,t);
[p,e,t] = refinemesh('circleg',p,e,t);
% refined the mesh twice (made the elements of FEM smaller)
% we're going to simulate the static problem
% so the equation is: -div(grad(u)) + u^3 = 0
% so the parameters that we will pass to PDENONLIN
% [U,RES]=PDENONLIN(B,P,E,T,C,A,F) solves the nonlinear
% PDE problem -div(c*grad(u))+a*u=f
% so our c = 1, a = u^2 and f = 0;
% you can change these as you wish
[ U, R ] = pdenonlin('circleb1',p,e,t,1,['u.^2'],0,'U0',1);
% Note that we used the function 'circleb1' rather than 'circleg'
% here, this is because we need a boundary matrix b, not a geometry
% this is further explained at the following URL:
% <http://www.mathworks.com/support/solutions/data/1-19DTS.shtml>
% Also, note how we entered a, as a character array, if you simply type
% u.^2 rather than ['u.^2'] you will receive an error
pdeplot(p,e,t,'xydata',u);
% we now plot the solution of the PDE

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!