thermalIC

Set initial conditions or initial guess for a thermal model

Description

example

thermalIC(thermalmodel,T0) sets initial temperature or initial guess for temperature to the entire geometry.

example

thermalIC(thermalmodel,T0,RegionType,RegionID) sets initial temperature or initial guess for temperature to a particular geometry region.

example

thermalIC(thermalmodel,Tresults) sets initial temperature or initial guess for temperature using the solution Tresults from a previous thermal analysis on the same geometry and mesh. If Tresults is obtained by solving a transient thermal problem, thermalIC uses the solution Tresults for the last time-step.

example

thermalIC(thermalmodel,Tresults,iT) sets initial temperature or initial guess for temperature using the solution Tresults for the time-step iT from a previous thermal analysis on the same geometry and mesh.

thermalIC = thermalIC(___), for any previous syntax, returns a handle to the thermal initial conditions object.

Examples

collapse all

Create a thermal model, import geometry, and set the initial temperature to 0 on the entire geometry.

thermalModel = createpde('thermal','transient');
geometryFromEdges(thermalModel,@lshapeg);
thermalIC(thermalModel,0)
ans =
GeometricThermalICs with properties:

RegionType: 'face'
RegionID: [1 2 3]
InitialTemperature: 0

Set different initial conditions on each portion of the L-shaped membrane geometry.

Create a model and include a 2-D geometry.

thermalModel = createpde('thermal','transient');
geometryFromEdges(thermalModel,@lshapeg);
pdegplot(thermalModel,'FaceLabels','on')
axis equal
ylim([-1.1 1.1])

Set initial conditions.

thermalIC(thermalModel,0,'Face',1)
ans =
GeometricThermalICs with properties:

RegionType: 'face'
RegionID: 1
InitialTemperature: 0

thermalIC(thermalModel,10,'Face',2)
ans =
GeometricThermalICs with properties:

RegionType: 'face'
RegionID: 2
InitialTemperature: 10

thermalIC(thermalModel,75,'Face',3)
ans =
GeometricThermalICs with properties:

RegionType: 'face'
RegionID: 3
InitialTemperature: 75

Use a function handle to specify an initial temperature that depends 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);

Set the initial temperature in the rod to be dependent on the y-coordinate, for example, ${10}^{3}\left(0.2-{\mathit{y}}^{2}\right)$.

T0 = @(location)10^3*(0.2 - location.y.^2);
thermalIC(thermalmodel,T0)
ans =
GeometricThermalICs with properties:

RegionType: 'face'
RegionID: 1
InitialTemperature: @(location)10^3*(0.2-location.y.^2)

Create a thermal model and include a square geometry.

thermalmodel = createpde('thermal','transient');
geometryFromEdges(thermalmodel,@squareg);
pdegplot(thermalmodel,'FaceLabels','on')
ylim([-1.1,1.1])
axis equal

Specify material properties and internal heat source, and set boundary conditions and initial conditions.

thermalProperties(thermalmodel,'ThermalConductivity',500,...
'MassDensity',200,...
'SpecificHeat',100);

internalHeatSource(thermalmodel,2);
thermalBC(thermalmodel,'Edge',[1,3],'Temperature',100);
thermalIC(thermalmodel,0);

Generate mesh, solve the problem, and plot the solution.

generateMesh(thermalmodel);
tlist = 0:0.5:10;
result1 = solve(thermalmodel,tlist)
result1 =
TransientThermalResults with properties:

Temperature: [1541x21 double]
SolutionTimes: [1x21 double]
Mesh: [1x1 FEMesh]

pdeplot(thermalmodel,'XYData',result1.Temperature(:,end))

Now, resume the analysis and solve the problem for times from 10 to 15 seconds. Use the previously obtained solution for 10 seconds as an initial condition. Since 10 seconds is the last element in tlist, you do not need to specify the solution time index. By default, thermalIC uses the last solution index.

thermalIC(thermalmodel,result1)
ans =
NodalThermalICs with properties:

InitialTemperature: [1541x1 double]

Solve the problem and plot the solution.

result2 = solve(thermalmodel,10:0.5:15)
result2 =
TransientThermalResults with properties:

Temperature: [1541x11 double]
SolutionTimes: [10 10.5000 11 11.5000 12 12.5000 13 13.5000 14 14.5000 15]
Mesh: [1x1 FEMesh]

pdeplot(thermalmodel,'XYData',result2.Temperature(:,end))

To use the previously obtained solution for a particular solution time instead of the last one, specify the solution time index as a third parameter of thermalIC. For example, use the solution at time 5 seconds, which is the 11th element in tlist.

tlist(11)
ans = 5
thermalIC(thermalmodel,result1,11);
result2 = solve(thermalmodel,5:0.5:15)
result2 =
TransientThermalResults with properties:

Temperature: [1541x21 double]
SolutionTimes: [1x21 double]
Mesh: [1x1 FEMesh]

pdeplot(thermalmodel,'XYData',result2.Temperature(:,end))

Input Arguments

collapse all

Thermal 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.

Initial temperature or initial guess for temperature, specified as a number or a function handle. Use a function handle to specify spatially varying initial temperature. For details, see More About.

Data Types: double | function_handle

Geometric region type, specified as 'Vertex', 'Edge', 'Face', or 'Cell' for a 3-D model. For a 2-D model, use 'Vertex', 'Edge', or 'Face'.

Example: thermalIC(thermalmodel,10,'Face',1)

Data Types: char | string

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

Example: thermalIC(thermalmodel,10,'Edge',2:5)

Data Types: double

Thermal model solution, specified as a ThermalResults object. Create Tresults by using solve.

Time index, specified as a positive integer.

Example: thermalIC(thermalmodel,Tresults,21)

Data Types: double

Output Arguments

collapse all

Handle to initial condition, returned as an object. thermalIC associates the thermal initial condition with the geometric region in the case of a geometric assignment, or the nodes in the case of a results-based assignment.

collapse all

Specifying Nonconstant Parameters of a Thermal Model

Use a function handle to specify these thermal parameters when they depend on space, temperature, and time:

• Thermal conductivity of the material

• Mass density of the material

• Specific heat of the material

• Internal heat source

• Temperature on the boundary

• Heat flux through the boundary

• Convection coefficient on the boundary

• Radiation emissivity coefficient on the boundary

• Initial temperature

For example, use function handles to specify the thermal conductivity, internal heat source, convection coefficient, and initial temperature for this model.

thermalProperties(model,'ThermalConductivity',@myfun)
internalHeatSource(model,'Face',2,@myfun)
thermalBC(model,'Edge',[3,4], ...
'ConvectionCoefficient',@myfun, ...
'AmbientTemperature',27)
thermalIC(model,@myfun)

The function must be of the form:

function thermalVal = myfun(location,state)

The solver passes the location and state data to your function:

• location — A structure containing these fields:

• location.x — The x-coordinate of the point or points

• location.y — The y-coordinate of the point or points

• location.z — For a 3-D or an axisymmetric geometry, the z-coordinate of the point or points

• location.r — For an axisymmetric geometry, the r-coordinate of the point or points

Furthermore, for boundary conditions, the solver passes these data in the location structure:

• location.nxx-component of the normal vector at the evaluation point or points

• location.nyy-component of the normal vector at the evaluation point or points

• location.nz — For a 3-D or an axisymmetric geometry, z-component of the normal vector at the evaluation point or points

• location.nz — For an axisymmetric geometry, z-component of the normal vector at the evaluation point or points

• state — A structure containing these fields for transient or nonlinear problems:

• state.u — Temperatures at the corresponding points of the location structure

• state.ux — Estimates of the x-component of temperature gradients at the corresponding points of the location structure

• state.uy — Estimates of the y-component of temperature gradients at the corresponding points of the location structure

• state.uz — For a 3-D or an axisymmetric geometry, estimates of the z-component of temperature gradients at the corresponding points of the location structure

• state.ur — For an axisymmetric geometry, estimates of the r-component of temperature gradients at the corresponding points of the location structure

• state.time — Time at evaluation points

Thermal material properties (thermal conductivity, mass density, and specific heat) and internal heat source get these data from the solver:

• location.x, location.y, location.z, location.r

• Subdomain ID

• state.u, state.ux, state.uy, state.uz, state.r, state.time

Boundary conditions (temperature on the boundary, heat flux, convection coefficient, and radiation emissivity coefficient) get these data from the solver:

• location.x, location.y, location.z, location.r

• location.nx, location.ny, location.nz, location.nr

• state.u, state.time

Initial temperature gets the following data from the solver:

• location.x, location.y, location.z, location.r

• Subdomain ID

For all thermal parameters, except for thermal conductivity, your function must return a row vector thermalVal with the number of columns equal to the number of evaluation points, for example, M = length(location.y).

For thermal conductivity, your function must return a matrix thermalVal with number of rows equal to 1, Ndim, Ndim*(Ndim+1)/2, or Ndim*Ndim, where Ndim is 2 for 2-D problems and 3 for 3-D problems. The number of columns must equal the number of evaluation points, for example, M = length(location.y). For details about dimensions of the matrix, see c Coefficient for specifyCoefficients.

If properties depend on the time or temperature, ensure that your function returns a matrix of NaN of the correct size when state.u or state.time are NaN. Solvers check whether a problem is time dependent by passing NaN state values and looking for returned NaN values.