Parabolic solver of PDE and coefficient in function form.
2 次查看(过去 30 天)
显示 更早的评论
I want to solve non-stationary parabolic equation d∂u∂t−∇·(c∇u)+au=f , where a=f(u) , but Matlab give out such errors:
Undefined function or variable 'u'.
Error in MoePDE (line 17)
u=parabolic(u0,tlist,b,p,e,t,c,acoeff(p,t,u,tlist),f,d);
where
function coeff = acoeff(p,t,u,time)
% Triangle point indices
it1 = t(1,:);
it2 = t(2,:);
it3 = t(3,:);
% Find centroids of triangles
xpts = (p(1,it1) + p(1,it2) + p(1,it3))/3;
ypts = (p(2,it1) + p(2,it2) + p(2,it3))/3;
uintrp = pdeintrp(p,t,u); % Interpolated values at centroids
A1=-1.0174E-10; A2=2.10708E-10; x0=423976; dx=873999.05251;
Eps1=6.8*8.85e-12;Eps2=22.6*8.85e-12;h=0.002;
coeff=appr2(uintrp,A2,A1,x0,dx,h)/Eps1;
end
and
function v=appr2(u,A2,A1,x0,dx,h)
v = A2 + (A1-A2)./(1 + exp((u-x0)/dx));
end
full code:
vs=1e-12;
c=(-vs*h)/Eps1;
f=0;
d=1;
[p, e, t] = initmesh(g, 'Hmax', 0.08);
pdemesh(p,e,t); axis equal
n=200;
u0=1600;
tlist=linspace(0,5,260);
u=parabolic(u0,tlist,b,p,e,t,c,acoeff(p,t,u,tlist),f,d);
pdesurf(p,t,u); grid on;
boundary conditions are u=0 on each edge and geometry model(square 1x1) i have export from PDE TOOL.
If I use
u=parabolic(u0,tlist,b,p,e,t,c,@acoeff,f,d);
then result of 'a' will be constant, am i right? (i just build two plots: 1st with a=0.29 and 2nd like@acoeff, and they were same), but i want that a is variable coefficient which varies during the execution of the solver.
Function coefficient 'a' is calculated as written in Documentation:
Calculate Coefficients in Function FormX- and Y-Values
The x- and y-values of the centroid of a triangle t are the mean values of the entries of the points p in t. To get row vectors xpts and ypts containing the mean values:
% Triangle point indices
it1 = t(1,:);
it2 = t(2,:);
it3 = t(3,:);
% Find centroids of triangles
xpts = (p(1,it1) + p(1,it2) + p(1,it3))/3;
ypts = (p(2,it1) + p(2,it2) + p(2,it3))/3;
Interpolated u
The pdeintrp function linearly interpolates the values of u at the centroids of t, based on the values at the points p.
uintrp = pdeintrp(p,t,u); % Interpolated values at centroids
The output uintrp is a row vector with the same number of columns as t. Use uintrp as the solution value in your coefficient calculations.
____________________________________
Thanks in advance for your help
12 个评论
Torsten
2019-6-4
Check which function files MATLAB uses on execution.
It can't happen that MATLAB uses
v = A2+(A1-A2)./(1+exp((U-x0)/dx))
to calculate v if it states that there is an error in the line
v = A2 + (A1-A2)/(1 + exp((U-x0)/dx))
(except for the case that this line appears more than once in your code).
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Eigenvalue Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!