How can I define the temperature in 2D domain at location x,y [rather than nodal locations] for steady state or transient solution?

4 visualizzazioni (ultimi 30 giorni)
I have been able to duplicate the results for the steady state and transient responses for the problem defined at
This example includes code to plot the temperature at a specific point in the block, in this case near the center of the right edge, as a function of time.
I would be interested to define the temperature and temperature history at any x,y location for the defined block with the slot in it- for example at the top right corner of the slot.

Risposta accettata

Shishir Reddy
Shishir Reddy il 23 Ago 2024
Hi John
Finding the temperature at an arbitrary point ((x, y)) within a finite element mesh can be challenging because directly calculating the temperature at a random (x, y) point would require identifying the element containing the point and using interpolation functions, which can be complex and computationally intensive.
Instead of calculating the temperature at the exact (x, y) point, it can be approximated to the temperature at the nearest node. This is an efficient approximation because it reduces the complexity and also gives closer estimate to the temperature if the mesh is sufficiently refined.
If observed closely, it can be understood that same method is followed in the documentation in finding the temperature at the centre of the right edge as well.
% Function to find the index of the nearest node
getClosestNode = @(p, x, y) find(min((p(1,:) - x).^2 + (p(2,:) - y).^2) == (p(1,:) - x).^2 + (p(2,:) - y).^2);
% Find the index of the nearest node
nid = getClosestNode(p, x_target, y_target);% (x_target, y_target) are the coordinates of the specific position we would like to calculate the temperature at.
To find the temperature at top right corner of the slot, substitute x_target = 0.5 and y_target = 0.8.
I hope this helps.
  1 Commento
John McGrath
John McGrath il 23 Ago 2024
Hi Shishir,
Thank you for your response. I tried your suggestion and got error messages as follows:
Undefined function 'minus' for input arguments of type 'matlab.graphics.GraphicsPlaceholder'.
Error in untitled78>@(p,x,y)find(min((p(1,:)-x).^2+(p(2,:)-y).^2)==(p(1,:)-x).^2+(p(2,:)-y).^2) (line 55)
getClosestNode = @(p, x, y) find(min((p(1,:) - x).^2 + (p(2,:) - y).^2) == (p(1,:) - x).^2 + (p(2,:) - y).^2);
Error in untitled78 (line 57)
nid = getClosestNode(p, x_target, y_target);% (x_target, y_target) are the coordinates of the specific position we would
like to calculate the temperature at.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by