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 CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by