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 。All the other boundaries are insulated. The temperature in the block at the starting time is 0 degrees. The goal is to model the heat distribution during the first five seconds.
创建热分析模型
The first step in solving a heat transfer problem is to create a thermal analysis model. This is a container that holds the geometry, thermal material properties, internal heat sources, temperature on the boundaries, heat fluxes through the boundaries, mesh, and initial conditions.
thermalmodel = createpde('thermal','transient');
Import Geometry
通过使用该块几何形状添加到热模型geometryFromEdges
function. The geometry description file for this problem is calledcrackg.m
。
geometryFromEdges(thermalmodel,@crackg);
Plot the geometry, displaying edge labels.
pdegplot(thermalmodel,'edgelabels','on') ylim([-1,1]) axisequal
指定材料的热性能
Specify the thermal conductivity, mass density, and specific heat of the material.
thermalProperties(thermalmodel,'ThermalConductivity',1,。。。'MassDensity',1,。。。'femificheat',1);
Apply Boundary Conditions
Specify the temperature on the left edge as100
, and constant heat flow to the exterior through the right edge as-10
。该工具箱使用所有其他边界使用默认的绝缘边界条件。
thermalBC(thermalmodel,'Edge',6,'Temperature',100); thermalBC(thermalmodel,'Edge',1,'HeatFlux',-10);
Set Initial Conditions
Set an initial value of0
for the temperature.
thermalIC(thermalmodel,0);
Generate Mesh
Create and plot a mesh.
generateMesh(thermalmodel); figure pdemesh(thermalmodel) 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
Use thesolve
function to calculate the solution.
thermalresults = solve(thermalmodel,tlist)
thermalresults = TransientThermalResults with properties: Temperature: [1320x11 double] SolutionTimes: [0 0.5000 1 1.5000 2 2.5000 3 3.5000 4 4.5000 5] XGradients: [1320x11 double] YGradients: [1320x11 double] ZGradients: [] Mesh: [1x1 FEMesh]
评估热通量
Compute the heat flux density.
[qx,qy] = evaluateHeatFlux(thermalresults);
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.
pdeplot(thermalmodel,'XYData',thermalresults.Temperature(:,end),。。。'Contour','on',。。。'FlowData', (qx(:,结束),qy(:,结束),。。。'ColorMap','hot')