Heat Transfer in Block with Cavity

This example shows how to solve for the heat distribution in a block with cavity.

Consider a block containing a rectangular crack or cavity. The left side of the block is heated to 100 degrees centigrade. At the right side of the block, heat flows from the block to the surrounding air at a constant rate, for example -10W/m2. All the other boundaries are insulated. The temperature in the block at the starting time t0=0 is 0 degrees. The goal is to model the heat distribution during the first five seconds.

The crackg.m file describes the geometry of the block.

thermalmodel = createpde('thermal','transient');

Plot the geometry with edge labels.

axis equal

Assume that the block has these thermal properties.


Set the boundary conditions to have the solution u equal to 20 on the left edge (edge 6), and g equal to -10 on the right edge (edge 1). The boundary condition on edge 1 corresponds to constant heat flow to the exterior. The toolbox uses the default insulating boundary condition for all other boundaries.


Set an initial value of 0 for the temperature.


Set solution times to be 0 to 5 in steps of 1/2.

tlist = 0:0.5:5;

Create a mesh and solve the problem.

thermalresults = solve(thermalmodel,tlist);
T = thermalresults.Temperature;

Compute the heat flux density. Plot the solution at t = 5.0 seconds with isothermal lines using a contour plot, and plot the heat flux vector field using arrows.

[qx,qy] = evaluateHeatFlux(thermalresults);