PDE Neumann boundary condition depends on u; qmatrix(u)
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (3)
Bill Greene
on 27 Feb 2013
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
0 Comments
Bill Greene
on 28 Feb 2013
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
0 Comments
See Also
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!