How does this kinds of functions work?
1 次查看(过去 30 天)
显示 更早的评论
Hi, I'm working with the following kinds of functions but I don't really know how they work.
sol = pdepe(m, @pdef1, @pdeic1, @pdebc1, x, t40);
u = sol(:,:,1);
assignin('base','solution',u);
assignin('base','time',t40);
% A surface plot is often a good way to study a solution.
figure;
surf(x,t40,u);
title(sprintf('Numerical solution computed with 20 mesh points.\nArxiu %s.', VCC40));
xlabel('Distance x');
ylabel('Time t');
% A solution profile can also be illuminating.
figure;
plot(t40,u(:,1),'x');
hold on
plot(t40,u(:,21),'+');
hold on
plot(t40,Temp40,'o');
legend('T at centre','T at exterior','initial conditions','Location','best');
title(sprintf('Solutions at the origin.\nArxiu %s.', VCC40));
xlabel('time');
ylabel('T');
%========================================================================= % defines the properties of the PDE function
function[c,f,s] = pdef1(x, t, u, DuDx)
c = rho*cp;
f = k*DuDx;
s = (1/volum).*interp1(t40, Pot40, t, 'linear', 'extrap'); % ficar la x (on es dissipa la pot)
% assignin('base','s',s)
end % ========================================================================= % defines the Initial Conditions
function[u0] = pdeic1(x)
u0 = tinitial;
end % ========================================================================= % defines the Boundary Conditions
function[pl,ql,pr,qr] = pdebc1(xl, ul, xr, ur, t)
%for cylindrical pl and ql are 0, because of symmetry. No flux is present
%at the center of the sphere.
pl = 0;
ql = 0;
pr = ur-interp1(t40, Temp40, t, 'linear', 'extrap');
qr = 0;
the thing is that, those functions at the bottom of the code are called at each iteration when matlab solves the pde. But I don't know how do they work. Also, I need to know how to introduce the coefficient 's' depending on x (radius of a circle). For example, from 0 (center) to 1 cm it generates (dissipates) but from 1cm to 2 cm it doesnt. If anyone could help me with this I'd be very grateful.
To sum it up, I have two questions:
1) how do these kinds of functions works. 2) how to introduce the radial dependency on s.
Thanks in advance.
4 个评论
dpb
2016-12-15
编辑:dpb
2016-12-15
Don't know what that means at all, but the helper functions are simply "ordinary" Matlab functions, they "function" (so to speak :) ) like any other function; they return the expected output for the given input when called. The only real difference is that they're called behind the scenes by the solver instead of at the command line but they can be written and debugged separately. The key is, of course, that they have to follow the prescribed interface of input/output as expected by pdepe per the documentation for it.
As for how to incorporate a radial component, from the documentation, pdepe is a function able to solve "initial-boundary value problems for parabolic-elliptic PDEs in 1-D"; in other words, there is no way to include a second geometric dimension into the functionals; pdepe simply wouldn't know what to do with it if tried.
Whether there are additional capabilities in other toolboxes beyond this I don't know; that's all there is in the base product at least through R2012b that I have here...
I see there is a <PDE Toolbox>, check on its capabilities for something applicable to your specific problem.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Boundary Conditions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!