Non-constant boundary condition for thermal PDE solve

6 次查看(过去 30 天)
Hello, I am trying to solve a heat transfer problem which contains a 3D geometry. I am using thermal model. I want to use 'heat transfer cofficient' as a boundary condition in such a way that it is a non-constant B.C. w.r.t. location on my 3D geometry. I use the function handle and wrap another function called 'getcoldcofficient' in it so that I can pass more arguments than only 'location' and 'state'. The 'h_c' here is a row vector containing different values which I want to apply on face of my geometry.
cold_coff = ...
@(location,state) getcoldcofficient(location,state,h_c);
thermalBC(model2,"Face",[7,8,9,10],"ConvectionCoefficient",cold_coff,"AmbientTemperature",?);
The function 'getcoldcofficient' is defined as follows, It extracts the location i, then converts it into a usable index value for my row vector 'h_c'
function hc = getcoldcofficient(location,state,h_c)
i = round(1000*abs(location.z));
if i == 0
hc = h_c(1);
else
hc = h_c(i);
end
end
Now the issue is that my 'Ambient temperature' is also changing at each location and is not a constant, I also have it as a row vector Tc. I want to use a similar function to 'getcoldcofficient' to get my ambient temperature at each corresponding index i. But I am not able to do this since 'Ambient temperature' only accepts a double type as an input and not a function handle.
To summarize, I want both heat transfer cofficient and its ambient temperature to be no-constant BCs on faces. Can someone help me with this ? Thanks.

回答(1 个)

Karan Singh
Karan Singh 2023-9-1
Hello Apurva, I noticed that you are encountering some challenges when it comes to defining the boundary conditions for your heat transfer problem. While you have successfully defined the 'Convection coefficient' as a function handle, it seems that you are facing difficulty in doing the same for the 'AmbientTemperature'. According to the documentation, the 'AmbientTemperature' is expected to be of type 'double', which means it cannot be defined as a function handle.
To work around this limitation, one approach you can consider is reapplying the boundary conditions individually. By doing so, you can achieve non-constant ambient temperatures on the faces of your 3D geometry. Here's a suggested modification to your approach:
% Define the convection coefficient function handle
h_c = [10, 15, 20, 25]; % Example convection coefficient values
cold_coefficient = @(location, state) getcoldcoefficient(location, state, h_c);
% Define the ambient temperature vector
Tc = [25, 30, 35, 40]; % Example ambient temperature values
% Create the thermal model
model2 = createpde('thermal', 'transient');
% Define your 3D geometry (example: a cube)
L = 1; % Length of the cube
geometry = [3; 4; 0; L; 0; L; 0; L; 0; L; 0; L];
% Create a geometry object and assign it to the model
g = geometryFromEdges(model2, 'Edges', geometry);
model2.Geometry = g;
% Generate a mesh
generateMesh(model2);
% Apply the non-constant boundary conditions
faceIndices = [7, 8, 9, 10];
thermalBC(model2, 'Face', faceIndices, 'ConvectionCoefficient', cold_coefficient);
% Set the ambient temperature for each face individually
for k = 1:numel(faceIndices)
faceID = faceIndices(k);
thermalBC(model2, 'Face', faceID, 'AmbientTemperature', Tc(k));
end
In this modified code, after defining the geometry and generating the mesh, we apply the non-constant convection coefficient boundary condition using the “cold_coefficient” function handle.
Then, we iterate over each face index and apply the individual ambient temperatures using a loop. The “thermalBC” function is called for each face separately, specifying the face ID and the corresponding ambient temperature from the “Tc” vector.
Hope It helps!
  1 个评论
Evan Olsen
Evan Olsen 2024-5-18
I am approaching this same issue with MATLAB being unable to specify the ambient temperature through a function handle.
In my case, I am attempting to apply the non-constant ambient temperature to a singular edge of a 2D transient analysis, and I am unable to use the same solution due to the issue of being unable to add new edges to the generated mesh.
Is there a way to manipulate the mesh to segment one edge into many edges based on knowing the locations of all of the vertices?

请先登录,再进行评论。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by