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 celsius. at the right side of the block, heat flows from the block to the surrounding air at a constant rate of –10 w/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.
create model with geometry
the first step in solving this heat transfer problem is to create an
femodel
object for thermal analysis with a geometry representing a
block with a cavity.
model = femodel(analysistype="thermaltransient", ... geometry=@crackg);
plot geometry
plot the geometry with edge labels.
pdegplot(model,edgelabels="on");
xlim([-0.6,0.6])
ylim([-1,1])
specify thermal properties of material
specify the thermal conductivity, mass density, and specific heat of the material.
model.materialproperties = ... materialproperties(thermalconductivity=1, ... massdensity=1, ... specificheat=1);
apply boundary conditions
specify the temperature on the left edge as 100
and constant heat
flow to the exterior through the right edge as -10
. the toolbox uses the
default insulating boundary condition for all other boundaries.
model.edgebc(6) = edgebc(temperature=100); model.edgeload(1) = edgeload(heat=-10);
set initial conditions
set an initial value of 0
for the temperature.
model.faceic = faceic(temperature=0);
generate mesh
generate a mesh and assign the result to the model. this assignment updates the mesh
stored in the geometry
property of the model. plot the mesh.
model = generatemesh(model);
figure
pdemesh(model);
title("mesh with quadratic triangular elements")
specify solution times
set solution times to be 0 to 5 seconds in steps of 1/2.
tlist = 0:0.5:5;
calculate solution
calculate the solution by using the solve
function.
results = solve(model,tlist)
results = transientthermalresults with properties: temperature: [1320×11 double] solutiontimes: [0 0.5000 1 1.5000 2 2.5000 3 3.5000 4 4.5000 5] xgradients: [1320×11 double] ygradients: [1320×11 double] zgradients: [] mesh: [1×1 femesh]
evaluate heat flux
compute the heat flux density.
[qx,qy] = evaluateheatflux(results);
plot temperature distribution and heat flux
plot the solution at the final time step, t = 5.0 seconds, with isothermal lines using a contour plot, and plot the heat flux vector field using arrows.
figure pdeplot(results.mesh,xydata=results.temperature(:,end), ... contour="on",... flowdata=[qx(:,end),qy(:,end)], ... colormap="hot")