Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Matlab: How to write the nonlinear term using pdenonlin solver

1 Ansicht (letzte 30 Tage)
Fehaid Alshammari
Fehaid Alshammari am 13 Feb. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I'm solving a nonlinear diffusion-advection equation in 2D spatial domain using pdenonlin . It seems straightforward to write the nonlinear term if it's of the form u^2, u^3, .. . The nonlinear term in my equation is of the form 2u/(4+u) . When I use char to pass this term to the f cofficient, the solutions don't seem right! I think I'm doing something wrong here. The equation I'm solving is u_xx+u_yy-2u/(4+u)=0 . What's wrong in my code? Thanks
c = 1;
a = 0;
f = char('-2*u./(4+u)')
d = 1; xmin=0;xmax=0.575;ymin=0;ymax=0.05315;ymax2=0.066;
gdm = [3;4;xmin;xmax;xmax;xmin;ymax;ymax2;ymin;ymin];
g = decsg(gdm, 'S1', ('S1')');
hmax = .1; % element size
[p, e, t] = initmesh(g, 'Hmax', hmax);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
numberOfPDE = 1;
pb = pde(numberOfPDE);
% Create a geometry entity
pg = pdeGeometryFromEdges(g);
bc1 = pdeBoundaryConditions(pg.Edges(1),'u',100);
bc2 = pdeBoundaryConditions(pg.Edges(2),'u',66);
bc3 = pdeBoundaryConditions(pg.Edges(3),'u',11);
bc4 = pdeBoundaryConditions(pg.Edges(4),'g',0);
pb.BoundaryConditions = [bc1,bc2,bc3,bc4];
u = pdenonlin(pb,p,e,t,c,a,f, 'jacobian', 'lumped');
figure;
hold on
pdeplot(p, e, t, 'xydata', u, 'contour', 'off', 'colormap', 'jet(99)');
title 'chemical Diffusion, Steady State Solution'
xlabel 'X-coordinate, cm'
ylabel 'Y-coordinate, cm'
  2 Kommentare
Richard Garner
Richard Garner am 14 Feb. 2015
I think you want to treat your nonlinear term as an "acoeff*u" term. That is, you use a_coeff=1/(4+u). fcoeff should be zero. Now, that having been said, I don't know what happens if 4+u happens to be zero during the course of the calculation. But that would be an algorithm issue. Or perhaps an inherent mathematical, or even numerical, issue.
Fehaid Alshammari
Fehaid Alshammari am 16 Feb. 2015
@Richard Thanks .. My 'u' always positive so that shouldn't be a problem

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by