thermalIC
Set initial conditions or initial guess for a thermal model
Domain-specific heat transfer workflow is not recommended. New features might not be compatible with this workflow. For help migrating your existing code to the unified finite element workflow, see Migration from Domain-Specific to Unified Workflow.
Syntax
Description
thermalIC(
sets initial temperature or initial guess for temperature to the entire
geometry.thermalmodel
,T0
)
thermalIC(
sets initial temperature or initial guess for temperature to a particular geometry
region.thermalmodel
,T0
,RegionType
,RegionID
)
thermalIC(
sets initial temperature or initial guess for temperature using the solution
thermalmodel
,Tresults
)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.
thermalIC(
sets initial temperature or initial guess for temperature using the solution
thermalmodel
,Tresults
,iT
)Tresults
for the time-step iT
from a
previous thermal analysis on the same geometry and mesh.
,
for any previous syntax, returns a handle to the thermal initial conditions
object.thermalIC
= thermalIC(___)
Examples
Constant Initial Temperature
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
Different Initial Temperatures on Subdomains
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
Nonconstant Initial Temperature
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, .
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)
Initial Condition as Previously Obtained Solution
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",40,... "MassDensity",7800,... "SpecificHeat",500); 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:10:100;
result1 = solve(thermalmodel,tlist);
pdeplot(thermalmodel,"XYData",result1.Temperature(:,end))
Now, resume the analysis and solve the problem for times from 100 to 1000 seconds. Use the previously obtained solution for 100 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);
Solve the problem and plot the solution.
result2 = solve(thermalmodel,100:100:1000);
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 50 seconds, which is the 6th element in tlist
.
tlist(6)
ans = 50
thermalIC(thermalmodel,result1,6);
result2 = solve(thermalmodel,50:100:1000);
pdeplot(thermalmodel,"XYData",result2.Temperature(:,end))
Input Arguments
thermalmodel
— Thermal model
ThermalModel
object
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.
Example: thermalmodel = createpde("thermal","steadystate")
T0
— Initial temperature or initial guess for temperature
number | function handle
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
RegionType
— Geometric region type
"Vertex"
| "Edge"
| "Face"
| "Cell"
for a 3-D model only
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
RegionID
— Geometric region ID
vector of positive integers
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
Tresults
— Thermal model solution
SteadyStateThermalResults
object | TransientThermalResults
object
Thermal model solution, specified as a
SteadyStateThermalResults
or
TransientThermalResults
object. Create
Tresults
by using solve
.
iT
— Time index
positive integer
Time index, specified as a positive integer.
Example: thermalIC(thermalmodel,Tresults,21)
Data Types: double
Output Arguments
thermalIC
— Handle to initial condition
GeometricThermalICs
object | NodalThermalICs
object
Handle to initial condition, returned as a
GeometricThermalICs
or
NodalThermalICs
object. See GeometricThermalICs Properties
and NodalThermalICs Properties.
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.
More About
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 (can depend on space only)
For example, use function handles to specify the thermal conductivity, internal heat source, convection coefficient, and initial temperature for this model.
thermalProperties(model,"ThermalConductivity", ... @myfunConductivity) internalHeatSource(model,"Face",2,@myfunHeatSource) thermalBC(model,"Edge",[3,4], ... "ConvectionCoefficient",@myfunBC, ... "AmbientTemperature",27) thermalIC(model,@myfunIC)
For all parameters, except the initial temperature, the function must be of the form:
function thermalVal = myfun(location,state)
For the initial temperature the function must be of the form:
function thermalVal = myfun(location)
The solver computes and populates the data in the location
and
state
structure arrays and passes this data to your function. You can
define your function so that its output depends on this data. You can use any names instead of
location
and state
, but the function must have exactly
two arguments (or one argument if the function specifies the initial temperature).
location
— A structure containing these fields:location.x
— The x-coordinate of the point or pointslocation.y
— The y-coordinate of the point or pointslocation.z
— For a 3-D or an axisymmetric geometry, the z-coordinate of the point or pointslocation.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.nx
— x-component of the normal vector at the evaluation point or pointslocation.ny
— y-component of the normal vector at the evaluation point or pointslocation.nz
— For a 3-D or an axisymmetric geometry, z-component of the normal vector at the evaluation point or pointslocation.nr
— For an axisymmetric geometry, r-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 structurestate.ux
— Estimates of the x-component of temperature gradients at the corresponding points of the location structurestate.uy
— Estimates of the y-component of temperature gradients at the corresponding points of the location structurestate.uz
— For a 3-D or an axisymmetric geometry, estimates of the z-component of temperature gradients at the corresponding points of the location structurestate.ur
— For an axisymmetric geometry, estimates of the r-component of temperature gradients at the corresponding points of the location structurestate.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.
Additional Arguments in Functions for Nonconstant Thermal Parameters
To use additional arguments in your function, wrap your function (that takes additional arguments) with an anonymous function that takes only the location
and state
arguments. For example:
thermalVal = ... @(location,state) myfunWithAdditionalArgs(location,state,arg1,arg2...) thermalBC(model,"Edge",3,"Temperature",thermalVal) thermalVal = @(location) myfunWithAdditionalArgs(location,arg1,arg2...) thermalIC(model,thermalVal)
Version History
Introduced in R2017a
MATLAB Command
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.
Select a Web Site
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: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)