PDE Neumann boundary condition depends on u; qmatrix(u)

1 回表示 (過去 30 日間)
Felix
Felix 2013 年 2 月 27 日
Hi, I want to solve following parabolic equation (heat transfer)
u = parabolic(u0, tlist, b,p,e,t,c,a,f,d,rtol,atol);
The Geometry is a simple rectangle, and to creat the mesh I use
[p, e, t] = initmesh(rectangle, 'Hmax', 1e-3);
Both sides of the rectangle are adiabatic. On the bottom a constant heat flux is given. On top I want to set a heat flux coefficient which depends on the temperature (h = 1.5*u-300; u = temp.)
The boundary conditions are defined as follows:
function [q_matrix,g_matrix,h_matrix,r_matrix] = boundary_conditions(p,e,u,time);
q_matrix = zeros(1,ne);
g_matrix = q_matrix;
h_matrix = zeros(1,2*ne);
r_matrix = h_matrix;
for k = 1:ne
switch e(5,k)
case {1,3} %boundarys edge 1 and 3 adiabatic
q_matrix(k) = 0;
g_matrix(k) = 0;
case {2} %boundary edge 2 heat transfer coefficient
q_matrix(k) = 1.5 * (u(e(1,k))+u(e(2,k)))/2 -300;
g_matrix(k) = (1.5 * (u(e(1,k))+u(e(2,k)))/2 -300) * 273;
%T_ambient = 273K
otherwise %boundary edge 4 heat flux
q_matrix(k) = 0;
g_matrix(k) = 2000;
end
end
My Problem now is, that this is not working when I use a function of u in q_matrix! I get following error:
??? Attempted to access u(2); index out of bounds because numel(u)=0.
Error in ==> boundary_conditions at 53
q_matrix(k) = 1.5 * (u(e(1,k))+u(e(2,k)))/2 -300;
I hope somebody can help me,
Thanks Felix

回答 (3 件)

Bill Greene
Bill Greene 2013 年 2 月 27 日
Hi,
Are you by any chance using a version of MATLAB older than R2012b?
The capability to have coefficients and boundary conditions that are functions of the dependent variables in parabolic (and hyperbolic) was an enhancement for R2012b.
Other than that, the code snippets you show above basically look OK to me.
Regards.
Bill

Felix
Felix 2013 年 2 月 28 日
Hi Bill,
thanks for your answer! Unfortunately I don't have the change to use MATLAB R2012b. I use MATLAB R2012a.
Is an upgrade the only possibility to solve my problem? I thought that the described problem is more or less a standart problem by using MATLAB PDE.
Regards Felix

Bill Greene
Bill Greene 2013 年 2 月 28 日
Yes, you have boundary conditions that are a function of u.
That was not supported in PDE Toolbox for transient PDE (parabolic and hyperbolic) before R2012b. Older versions of PDE Toolbox do let you solve a stationary problem with coefficients and boundary conditions that are a function of u using the the pdenonlin function.
Bill

カテゴリ

Help Center および File ExchangeBoundary Conditions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by