Specify boundary conditions for a thermal model

`thermalBC(`

adds a temperature boundary condition to `thermalmodel`

,`RegionType`

,`RegionID`

,'Temperature',`Tval`

)`thermalmodel`

. The
boundary condition applies to regions of type `RegionType`

with
ID numbers in `RegionID`

.

`thermalBC(`

adds a heat flux boundary condition to `thermalmodel`

,`RegionType`

,`RegionID`

,'HeatFlux,`HFval`

)`thermalmodel`

. The
boundary condition applies to regions of type `RegionType`

with
ID numbers in `RegionID`

.

Use `thermalBC`

with the `HeatFlux`

parameter to specify a heat flux to or from an external source. To specify
internal heat generation, that is, heat sources that belong to the geometry
of the model, use `internalHeatSource`

.

`thermalBC(`

adds a convection boundary condition to `thermalmodel`

,`RegionType`

,`RegionID`

,'ConvectionCoefficient',`CCval`

,'AmbientTemperature',`ATval`

)`thermalmodel`

. The
boundary condition applies to regions of type `RegionType`

with
ID numbers in `RegionID`

.

`thermalBC(`

adds a radiation boundary condition to `thermalmodel`

,`RegionType`

,`RegionID`

,'Emissivity',`REval`

,'AmbientTemperature',`ATval`

)`thermalmodel`

. The
boundary condition applies to regions of type `RegionType`

with
ID numbers in `RegionID`

.

returns the thermal boundary condition object.`thermalBC`

= thermalBC(___)

Apply temperature boundary condition on two edges of a square.

thermalmodel = createpde('thermal'); geometryFromEdges(thermalmodel,@squareg); thermalBC(thermalmodel,'Edge',[1,3],'Temperature',100)

ans = ThermalBC with properties: RegionType: 'Edge' RegionID: [1 3] Temperature: 100 HeatFlux: [] ConvectionCoefficient: [] Emissivity: [] AmbientTemperature: [] Vectorized: 'off'

Apply heat flux boundary condition on two faces of a block.

thermalmodel = createpde('thermal','transient'); gm = importGeometry(thermalmodel,'Block.stl'); thermalBC(thermalmodel,'Face',[1,3],'HeatFlux',20)

ans = ThermalBC with properties: RegionType: 'Face' RegionID: [1 3] Temperature: [] HeatFlux: 20 ConvectionCoefficient: [] Emissivity: [] AmbientTemperature: [] Vectorized: 'off'

Apply convection boundary condition on four faces of a block.

thermalModel = createpde('thermal','transient'); gm = importGeometry(thermalModel,'Block.stl'); thermalBC(thermalModel,'Face',[2 4 5 6], ... 'ConvectionCoefficient',5, ... 'AmbientTemperature',27)

ans = ThermalBC with properties: RegionType: 'Face' RegionID: [2 4 5 6] Temperature: [] HeatFlux: [] ConvectionCoefficient: 5 Emissivity: [] AmbientTemperature: 27 Vectorized: 'off'

Apply radiation boundary condition on four faces of a block.

thermalmodel = createpde('thermal','transient'); gm = importGeometry(thermalmodel,'Block.stl'); thermalmodel.StefanBoltzmannConstant = 5.670373E-8; thermalBC(thermalmodel,'Face',[2,4,5,6],... 'Emissivity',0.1,... 'AmbientTemperature',300)

ans = ThermalBC with properties: RegionType: 'Face' RegionID: [2 4 5 6] Temperature: [] HeatFlux: [] ConvectionCoefficient: [] Emissivity: 0.1000 AmbientTemperature: 300 Vectorized: 'off'

Use function handles to specify thermal boundary conditions that depend on coordinates.

Create a thermal model for transient analysis and include the geometry. The geometry is a rod with a circular cross section. The 2-D model is a rectangular strip whose *y*-dimension extends from the axis of symmetry to the outer surface, and whose *x*-dimension extends over the actual length of the rod.

thermalmodel = createpde('thermal','transient'); g = decsg([3 4 -1.5 1.5 1.5 -1.5 0 0 .2 .2]'); geometryFromEdges(thermalmodel,g);

Plot the geometry.

figure pdegplot(thermalmodel,'EdgeLabels','on'); xlim([-2 2]); ylim([-2 2]); title 'Rod Section Geometry with Edge Labels';

Assume that there is a heat source at the left end of the rod and a fixed temperature at the right end. The outer surface of the rod exchanges heat with the environment due to convection.

Define the boundary conditions for the model. The edge at *y *= 0 (edge 1) is along the axis of symmetry. No heat is transferred in the direction normal to this edge. This boundary is modeled as an insulated boundary, by default.

The temperature at the right end of the rod (edge 2) is a fixed temperature, T = 100 C. Specify the boundary condition for edge 2 as follows.

thermalBC(thermalmodel,'Edge',2,'Temperature',100)

ans = ThermalBC with properties: RegionType: 'Edge' RegionID: 2 Temperature: 100 HeatFlux: [] ConvectionCoefficient: [] Emissivity: [] AmbientTemperature: [] Vectorized: 'off'

The convection coefficient for the outer surface of the rod (edge 3) depends on the *y*-coordinate, 50*y.* Specify the boundary condition for this edge as follows.

outerCC = @(location,~) 50*location.y; thermalBC(thermalmodel,'Edge',3,... 'ConvectionCoefficient',outerCC,... 'AmbientTemperature',100)

ans = ThermalBC with properties: RegionType: 'Edge' RegionID: 3 Temperature: [] HeatFlux: [] ConvectionCoefficient: @(location,~)50*location.y Emissivity: [] AmbientTemperature: 100 Vectorized: 'off'

The heat flux at the left end of the rod (edge 4) is also a function of the *y*-coordinate, 5000*y. *Specify the boundary condition for this edge as follows.

leftHF = @(location,~) 5000*location.y; thermalBC(thermalmodel,'Edge',4,'HeatFlux',leftHF)

ans = ThermalBC with properties: RegionType: 'Edge' RegionID: 4 Temperature: [] HeatFlux: @(location,~)5000*location.y ConvectionCoefficient: [] Emissivity: [] AmbientTemperature: [] Vectorized: 'off'

`thermalmodel`

— Thermal model`ThermalModel`

objectThermal model, specified as a `ThermalModel`

object.
The model contains the geometry, mesh, thermal properties of the material,
internal heat source, boundary conditions, and initial conditions.

**Example: **`thermalmodel = createpde('thermal','steadystate')`

`RegionType`

— Geometric region type`'Edge'`

for a 2-D model | `'Face'`

for a 3-D modelGeometric region type, specified as `'Edge'`

or
`'Face'`

.

**Example: **`thermalBC(thermalmodel,'Face',1,'Temperature',72)`

**Data Types: **`char`

`RegionID`

— Geometric region IDvector of positive integers

Geometric region ID, specified as a vector of positive integers. Find the
region IDs by using `pdegplot`

with the
`'FaceLabels'`

(3-D) or `'EdgeLabels'`

(2-D) value set to `'on'`

.

**Example: **`thermalBC(thermalmodel,'Edge',2:5,'Temperature',72)`

**Data Types: **`double`

`Tval`

— Temperature boundary conditionnumber | function handle

Temperature boundary condition, specified as a number or a function handle. Use a function handle to specify the temperature that depends on space, time, or temperature. The function must be of the form

Tval = Tfun(location,state)

The solver passes `location`

data as a structure array
with the fields `location.x`

,
`location.y`

, and, for 3-D problems,
`location.z`

. The `state`

data is a
structure array with the fields `state.u`

,
`state.ux`

, `state.uy`

,
`state.uz`

(for 3-D problems), and
`state.time`

(for transient problems). The
`state.u`

field contains the solution vector. The
`state.ux`

, `state.uy`

,
`state.uz`

fields are estimates of the solution’s
partial derivatives at the corresponding points of the location structure.
The `state.time`

field contains time at evaluation
points.

`Tfun`

must return a row vector `Tval`

with the number of columns equal to the number of evaluation points,
`M = length(location.x)`

.

**Example: **`thermalBC(thermalmodel,'Face',1,'Temperature',72)`

**Data Types: **`double`

| `function_handle`

`HFval`

— Heat flux boundary conditionnumber | function handle

Heat flux boundary condition, specified as a number or a function handle. Use a function handle to specify the heat flux that depends on space, time, or temperature. The function must be of the form

HFval = HFfun(location,state)

The solver passes `location`

data as a structure array
with the fields `location.x`

,
`location.y`

, and, for 3-D problems,
`location.z`

. The `state`

data is a
structure array with the fields `state.u`

,
`state.ux`

, `state.uy`

,
`state.uz`

(for 3-D problems), and
`state.time`

(for transient problems). The
`state.u`

field contains the solution vector. The
`state.ux`

, `state.uy`

,
`state.uz`

fields are estimates of the solution’s
partial derivatives at the corresponding points of the location structure.
The `state.time`

field contains time at evaluation
points.

`HFfun`

must return a row vector `HFval`

with the number of columns equal to the number of evaluation points,
`M = length(location.x)`

.

**Example: **`thermalBC(thermalmodel,'Face',[1,3],'HeatFlux',20)`

**Data Types: **`double`

| `function_handle`

`CCval`

— Coefficient for convection to ambient heat transfer conditionnumber | function handle

Convection to ambient boundary condition, specified as a number or a function handle. Use a function handle to specify the convection coefficient that depends on space, time, or temperature. The function must be of the form

CCval = CCfun(location,state)

The solver passes `location`

data as a structure array
with the fields `location.x`

,
`location.y`

, and, for 3-D problems,
`location.z`

. The `state`

data is a
structure array with the fields `state.u`

,
`state.ux`

, `state.uy`

,
`state.uz`

(for 3-D problems), and
`state.time`

(for transient problems). The
`state.u`

field contains the solution vector. The
`state.ux`

, `state.uy`

,
`state.uz`

fields are estimates of the solution’s
partial derivatives at the corresponding points of the location structure.
The `state.time`

field contains time at evaluation
points.

`CCfun`

must return a row vector `CCval`

with the number of columns equal to the number of evaluation points,
`M = length(location.x)`

.

Specify ambient temperature using the
`AmbientTemperature`

argument. The value of
`ConvectionCoefficient`

is positive for heat convection
into the ambient environment.

**Example: **`thermalBC(thermalmodel,'Edge',[2,4],'ConvectionCoefficient',5,'AmbientTemperature',60)`

**Data Types: **`double`

| `function_handle`

`REval`

— Radiation emissivity coefficientnumber in the range (0,1)

Radiation emissivity coefficient, specified as a number in the range (0,1). Use a function handle to specify the radiation emissivity that depends on space, time, or temperature. The function must be of the form

REval = REfun(location,state)

`location`

data as a structure array
with the fields `location.x`

,
`location.y`

, and, for 3-D problems,
`location.z`

. The `state`

data is a
structure array with the fields `state.u`

,
`state.ux`

, `state.uy`

,
`state.uz`

(for 3-D problems), and
`state.time`

(for transient problems). The
`state.u`

field contains the solution vector. The
`state.ux`

, `state.uy`

,
`state.uz`

fields are estimates of the solution’s
partial derivatives at the corresponding points of the location structure.
The `state.time`

field contains time at evaluation
points.

`REfun`

must return a row vector `REval`

with the number of columns equal to the number of evaluation points,
`M = length(location.x)`

.

Specify ambient temperature using the
`AmbientTemperature`

argument and the Stefan-Boltzmann
constant using the thermal model properties. The value of
`Emissivity`

is positive for heat radiation into the
ambient environment.

**Example: **```
thermalmodel.StefanBoltzmannConstant = 5.670373E-8;
thermalBC(thermalmodel,'Edge',[2,4,5,6],'Emissivity',0.1,'AmbientTemperature',300)
```

**Data Types: **`double`

| `function_handle`

`ATval`

— Ambient temperaturenumber

Ambient temperature, specified as a number. The ambient temperature value is required for specifying convection and radiation boundary conditions.

**Example: **`thermalBC(thermalmodel,'Edge',[2,4],'ConvectionCoefficient',5,'AmbientTemperature',60)`

**Data Types: **`double`

`thermalBC`

— Handle to thermal boundary conditionobject

Handle to thermal boundary condition, returned as an object.
`thermalBC`

associates the thermal boundary
condition with the geometric region.

`applyBoundaryCondition`

| `internalHeatSource`

| `thermalIC`

| `thermalProperties`

A modified version of this example exists on your system. Do you want to open this version instead?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)