Matlab: How to write the nonlinear term using pdenonlin solver
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
Richard Garner
2015년 2월 14일
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
2015년 2월 16일
답변 (0개)
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!