Documentation

# thermalIC

Set initial conditions or initial guess for a thermal model

## Syntax

``thermalIC(thermalmodel,T0)``
``thermalIC(thermalmodel,T0,RegionType,RegionID)``
``thermalIC(thermalmodel,Tresults)``
``thermalIC(thermalmodel,Tresults,iT)``
``thermalIC = thermalIC(___)``

## 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] XGradients: [1541x21 double] YGradients: [1541x21 double] ZGradients: [] 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] XGradients: [1541x11 double] YGradients: [1541x11 double] ZGradients: [] 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] XGradients: [1541x21 double] YGradients: [1541x21 double] ZGradients: [] 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.

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

Initial temperature or initial guess for temperature, specified as a number or a function handle. Use a function handle to specify spatially varying temperature. The function must be of the form

`T0 = T0fun(location)`

The solver passes `location` as a structure with fields `location.x`, `location.y`, and, for 3-D problems, `location.z`. `T0fun` must return a row vector `T0` with the number of columns equal to `M = length(location.x)`.

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.