Hi. I need to compute the average flux across the edge in the diagram that is of length xa. Shouldn't the results from the function evaluateHeatFlux be weighted by the mesh segment lengths on that edge? For non-uniform meshes, as this is, the segment lengths are not all equal and thus the result given by evaluateHeatFlux should have less weight in a small segment versus a large segment (when averaging). Does Matlab have a built-in way of doing this?
results = solve(model);
[qx,qy] = evaluateHeatFlux(results);
Nodes_Xa = findNodes(model.Mesh,"region","Edge",Edge_Xa);
flux_Xa = qy(Nodes_Xa);
averageFlux = mean(flux_Xa); % SHOULDN'T THIS BE WEIGHTED BY THE ELEMENT EDGE LENGTH?
Thanks for any input.

 채택된 답변

Torsten
Torsten 2025년 5월 1일
이동: Torsten 2025년 5월 1일

0 개 추천

Should be
averageFlux = 1/(Nodes_Xa(end)-Nodes_Xa(1))*trapz(Nodes_Xa,flux_Xa)

댓글 수: 7

Actually, this would be the way. Need to use the coordinate values (xa) versus the node numbers (Nodes_Xa).
results = solve(model);
[qx,qy] = evaluateHeatFlux(results);
Nodes_Xa = findNodes(model.Mesh,"region","Edge",Edge_Xa); % Gives node numbers
flux_Xa = qy(Nodes_Xa);
xa = results.Mesh.Nodes(1,Nodes_Xa); % Gives coord values at nodes
averageFlux = 1/(xa(end)-xa(1))*trapz(xa,flux_Xa);
Thanks for the suggestion, @Torsten
@Torsten what're your thoughts about needing to scale the results from evaluateHeatFlux in a plot like:
figure; plot(xa,flux_Xa,'ro')
Should the values in flux_Xa be scaled by the segment sizes of xa? Since heat flux is a "per unit area" quantity, it would seem that the area of each element (i.e. diff(xa)) would be important. Or, do you think that the built-in Matlab function evaluateHeatFlux handles the different areas of element edges on the domain boundary?
Torsten
Torsten 2025년 5월 1일
편집: Torsten 2025년 5월 1일
Or, do you think that the built-in Matlab function evaluateHeatFlux handles the different areas of element edges on the domain boundary?
If you want to compute the total heat flux across the boundary in Watt, the edge lengths would be important because you take the integral over the edge. But using "evaluateHeatFlux" gives the local values in Watt/m^2 in the node points - thus the value is independent of the actual local edge lengths of your mesh.
Paul Safier
Paul Safier 2025년 5월 1일
Thanks!
Torsten
Torsten 2025년 5월 2일
편집: Torsten 2025년 5월 2일
I think "evaluateHeatRate" is what you are looking for:
It's the integrated heat flux normal to the boundary. To get the mean, you'll have to divide by the length of the edge, I guess.
Paul Safier
Paul Safier 2025년 5월 2일
OK, I just tested that and it comes up as the exact same answer as the integral with trapz. Thanks!
Ansel
Ansel 2025년 5월 14일
Thanks for the link, you saved my day.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

릴리스

R2023b

질문:

2025년 5월 1일

댓글:

2025년 5월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by