evaluateTemperatureGradient
Evaluate temperature gradient of a thermal solution at arbitrary spatial locations
Syntax
Description
[
returns the interpolated values of temperature gradients of the thermal model solutiongradTx
,gradTy
] = evaluateTemperatureGradient(thermalresults
,xq
,yq
)thermalresults
at the 2-D points specified inxq
andyq
。This syntax is valid for both the steady-state and transient thermal models.
[___] = evaluateTemperatureGradient(
returns the interpolated values of the temperature gradients at the points specified inthermalresults
,querypoints
)querypoints
。This syntax is valid for both the steady-state and transient thermal models.
[___] = evaluateTemperatureGradient(___,
returns the interpolated values of the temperature gradients for the time-dependent equation at timesiT
)iT
。SpecifyiT
after the input arguments in any of the previous syntaxes.
The first dimension ofgradTx
,gradTy
, and, in 3-D case,gradTz
corresponds to query points. The second dimension corresponds to time-stepsiT
。
Examples
Temperature Gradients for 2-D Steady-State Thermal Model
For a 2-D steady-state thermal model, evaluate temperature gradients at the nodal locations and at the points specified byx
andy
coordinates.
Create a thermal model for steady-state analysis.
thermalmodel = createpde("thermal");
Create the geometry and include it in the model.
R1 = [3,4,-1,1,1,-1,1,1,-1,-1]'; g = decsg(R1,'R1',('R1')'); geometryFromEdges(thermalmodel,g); pdegplot(thermalmodel,"EdgeLabels","on") xlim([-1.5 1.5]) axisequal
Assuming that this geometry represents an iron plate, the thermal conductivity is 。
thermalProperties(thermalmodel,"ThermalConductivity",79.5,"Face",1);
Apply a constant temperature of 300 K to the bottom of the plate (edge 3). Also, assume that the top of the plate (edge 1) is insulated, and apply convection on the two sides of the plate (edges 2 and 4).
thermalBC(thermalmodel,"Edge",3,"Temperature",300); thermalBC(thermalmodel,"Edge",1,"HeatFlux",0); thermalBC(thermalmodel,"Edge",[2 4],。.."ConvectionCoefficient",25,。.."AmbientTemperature",50);
Mesh the geometry and solve the problem.
generateMesh(thermalmodel); results = solve(thermalmodel)
结果= SteadyStateThermalResults properties: Temperature: [1541x1 double] XGradients: [1541x1 double] YGradients: [1541x1 double] ZGradients: [] Mesh: [1x1 FEMesh]
The solver finds the temperatures and temperature gradients at the nodal locations. To access these values, useresults.Temperature
,results.XGradients
, and so on. For example, plot the temperature gradients at nodal locations.
figure; pdeplot(thermalmodel,。.."FlowData",[results.XGradients results.YGradients]);
Create a grid specified byx
andy
coordinates, and evaluate temperature gradients to the grid.
v = linspace(-0.5,0.5,11); [X,Y] = meshgrid(v); [gradTx,gradTy] =。..evaluateTemperatureGradient(results,X,Y);
Reshape thegradTx
andgradTy
vectors, and plot the resulting temperature gradients.
gradTx = reshape(gradTx,size(X)); gradTy = reshape(gradTy,size(Y)); figure quiver(X,Y,gradTx,gradTy)
Alternatively, you can specify the grid by using a matrix of query points.
querypoints = [X(:) Y(:)]'; [gradTx,gradTy] =。..evaluateTemperatureGradient(results,querypoints); gradTx = reshape(gradTx,size(X)); gradTy = reshape(gradTy,size(Y)); figure quiver(X,Y,gradTx,gradTy)
Temperature Gradients for 3-D Steady-State Thermal Model
For a 3-D steady-state thermal model, evaluate temperature gradients at the nodal locations and at the points specified byx
,y
, andz
coordinates.
Create a thermal model for steady-state analysis.
thermalmodel = createpde("thermal");
Create the following 3-D geometry and include it in the model.
importGeometry(thermalmodel,"Block.stl"); pdegplot(thermalmodel,"FaceLabels","on","FaceAlpha",0.5) title("Copper block, cm") axisequal
Assuming that this is a copper block, the thermal conductivity of the block is approximately 。
thermalProperties(thermalmodel,"ThermalConductivity",4);
Apply a constant temperature of 373 K to the left side of the block (edge 1) and a constant temperature of 573 K to the right side of the block.
thermalBC(thermalmodel,"Face",1,"Temperature",373); thermalBC(thermalmodel,"Face",3,"Temperature",573);
Apply a heat flux boundary condition to the bottom of the block.
thermalBC(thermalmodel,"Face",4,"HeatFlux",-20);
Mesh the geometry and solve the problem.
generateMesh(thermalmodel); thermalresults = solve(thermalmodel)
thermalresults = SteadyStateThermalResults with properties: Temperature: [12691x1 double] XGradients: [12691x1 double] YGradients: [12691x1 double] ZGradients: [12691x1 double] Mesh: [1x1 FEMesh]
The solver finds the values of temperatures and temperature gradients at the nodal locations. To access these values, useresults.Temperature
,results.XGradients
, and so on.
Create a grid specified byx
,y
, andz
coordinates, and evaluate temperature gradients to the grid.
[X,Y,Z] = meshgrid(1:26:100,1:6:20,1:11:50); [gradTx,gradTy,gradTz] =。..evaluateTemperatureGradient(thermalresults,X,Y,Z);
Reshape thegradTx
,gradTy
, andgradTz
vectors, and plot the resulting temperature gradients.
gradTx = reshape(gradTx,size(X)); gradTy = reshape(gradTy,size(Y)); gradTz = reshape(gradTz,size(Z)); figure quiver3(X,Y,Z,gradTx,gradTy,gradTz) axisequalxlabel("x") ylabel("y") zlabel("z")
Alternatively, you can specify the grid by using a matrix of query points.
querypoints = [X(:) Y(:) Z(:)]'; [gradTx,gradTy,gradTz] =。..evaluateTemperatureGradient(thermalresults,querypoints); gradTx = reshape(gradTx,size(X)); gradTy = reshape(gradTy,size(Y)); gradTz = reshape(gradTz,size(Z)); figure quiver3(X,Y,Z,gradTx,gradTy,gradTz) axisequalxlabel("x") ylabel("y") zlabel("z")
Temperature Gradients for Transient Thermal Model on Square
Solve a 2-D transient heat transfer problem on a square domain and compute temperature gradients at the convective boundary.
Create a transient thermal model for this problem.
thermalmodel = createpde("thermal","transient");
Create the geometry and include it in the model.
g = @squareg; geometryFromEdges(thermalmodel,g); pdegplot(thermalmodel,"EdgeLabels","on") xlim([-1.2 1.2]) ylim([-1.2 1.2]) axisequal
Assign the following thermal properties: thermal conductivity is , mass density is , and specific heat is 。
thermalProperties(thermalmodel,"ThermalConductivity", 100,。.."MassDensity",7800,。.."SpecificHeat",500);
Apply insulated boundary conditions on three edges and the free convection boundary condition on the right edge.
thermalBC(thermalmodel,"Edge",[1 3 4],"HeatFlux",0); thermalBC(thermalmodel,"Edge",2,。.."ConvectionCoefficient",5000,。.."AmbientTemperature",25);
Set the initial conditions: uniform room temperature across domain and higher temperature on the left edge.
thermalIC(thermalmodel,25); thermalIC(thermalmodel,100,"Edge",4);
Generate a mesh and solve the problem using0:1000:200000
as a vector of times.
generateMesh(thermalmodel); tlist = 0:1000:200000; thermalresults = solve(thermalmodel,tlist);
Define a line at convection boundary and compute temperature gradients across that line.
X = -1:0.1:1; Y = ones(size(X)); [gradTx,gradTy] = evaluateTemperatureGradient(thermalresults,。..X,Y,1:length(tlist));
Plot the interpolated gradient componentgradTx
along thex
axis for the following values from the time intervaltlist
。
figure t = [51:50:201];fori = t p(i) = plot(X,gradTx(:,i),"DisplayName",。..strcat("t=",num2str(tlist(i)))); holdonendlegend(p(t)) xlabel("x") ylabel("gradTx")
Input Arguments
thermalresults
—Solution of thermal problem
SteadyStateThermalResults
object|TransientThermalResults
object
Solution of a thermal problem, specified as aSteadyStateThermalResults
object or aTransientThermalResults
object. Createthermalresults
using thesolve
function.
Example:thermalresults = solve(thermalmodel)
xq
—x-coordinate query points
real array
x-coordinate query points, specified as a real array.evaluateTemperatureGradient
evaluates temperature gradient at the 2-D coordinate points[xq(i) yq(i)]
or at the 3-D coordinate points[xq(i) yq(i) zq(i)]
。Soxq
,yq
, and (if present)zq
must have the same number of entries.
evaluateTemperatureGradient
converts query points to column vectorsxq(:)
,yq(:)
, and (if present)zq(:)
。它返回f的温度梯度orm of a column vector of the same size. To ensure that the dimensions of the returned solution is consistent with the dimensions of the original query points, usereshape
。For example, usegradTx = reshape(gradTx,size(xq))
。
Data Types:double
yq
—y-coordinate query points
real array
y-coordinate query points, specified as a real array.evaluateTemperatureGradient
evaluates the temperature gradient at the 2-D coordinate points[xq(i) yq(i)]
or at the 3-D coordinate points[xq(i) yq(i) zq(i)]
。Soxq
,yq
, and (if present)zq
must have the same number of entries.
evaluateTemperatureGradient
converts query points to column vectorsxq(:)
,yq(:)
, and (if present)zq(:)
。它返回f的温度梯度orm of a column vector of the same size. To ensure that the dimensions of the returned solution is consistent with the dimensions of the original query points, usereshape
。For example, usegradTy = reshape(gradTy,size(yq))
。
Data Types:double
zq
—z-coordinate query points
real array
z-coordinate query points, specified as a real array.evaluateTemperatureGradient
evaluates the temperature gradient at the 3-D coordinate points[xq(i) yq(i) zq(i)]
。Soxq
,yq
, andzq
must have the same number of entries.
evaluateTemperatureGradient
converts query points to column vectorsxq(:)
,yq(:)
, and (if present)zq(:)
。它返回f的温度梯度orm of a column vector of the same size. To ensure that the dimensions of the returned solution is consistent with the dimensions of the original query points, usereshape
。For example, usegradTz = reshape(gradTz,size(zq))
。
Data Types:double
querypoints
—Query points
real matrix
Query points, specified as a real matrix with either two rows for 2-D geometry, or three rows for 3-D geometry.evaluateTemperatureGradient
evaluates the temperature gradient at the coordinate pointsquerypoints(:,i)
, so each column ofquerypoints
contains exactly one 2-D or 3-D query point.
Example:For 2-D geometry,querypoints = [0.5 0.5 0.75 0.75; 1 2 0 0.5]
Data Types:double
iT
—Time indices
vector of positive integers
Time indices, specified as a vector of positive integers. Each entry iniT
specifies a time index.
Example:iT = 1:5:21
specifies every fifth time-step up to 21.
Data Types:double
Output Arguments
gradTx
—x-component of the temperature gradient
matrix
x-component of the temperature gradient, returned as a matrix. For query points that are outside the geometry,gradTx
=NaN
。
gradTy
—y-component of the temperature gradient
matrix
y-component of the temperature gradient, returned as a matrix. For query points that are outside the geometry,gradTy
=NaN
。
gradTz
—z-component of the temperature gradient
matrix
z-component of the temperature gradient, returned as a matrix. For query points that are outside the geometry,gradTz
=NaN
。
Version History
Introduced in R2017a
Beispiel öffnen
Sie haben eine geänderte Version dieses Beispiels. Möchten Sie dieses Beispiel mit Ihren Änderungen öffnen?
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
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)
- 挪威(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)