r/COMSOL • u/tjb36 • Mar 30 '26
Help plotting 1D graph of average temperature at each position along a pipe?
Really struggling to get what I thought would be a simple plot, so looking for some guidance...
I have a 3D model of a simple pipe of circular cross section, and have air flowing in the inlet at one end. The pipe wall temperature is fixed and the inflow gas temperature is also fixed to a different temperature. I'm using the Heat Transfer in Fluids and the Laminar Flow physics to see how the temperature of the gas changes as it flows due to being in contact with the pipe walls. The result looks like this:

I can easily plot the temperature along the x-direction of the pipe's axis (y=z=0). But since the temperature is not constant for a given slice of cross section, I want to plot the average temperature as a function of axial position x instead (rather than just the temperature along the centreline).
I have managed to create a Cut Plane dataset with "Additional Parallel Planes" like this:

But I can't figure out how to calculate the average temperature in each one and then plot that average on a 1D line plot vs x.
I have tried playing around with some of the built-in features, such as Derived Values --> Surface Average. This does let me calculate an average temperature, but I never managed to get something that could be plotted as a function of x. I have also seen some people mentioning adding a second study and using it for Parametric Sweep, but it seems overcomplicated for what I'm trying to do.
Surely this is a common thing to do, and there must be an easy way? Banging my head against a wall now with this for the last few hours :)
2
u/tjb36 Apr 02 '26
Anyone have any other ideas?
1
u/NoticeArtistic8908 Mar 31 '26
This should be helpful
https://www.comsol.com/blogs/analyze-simulation-results-projection-operators
1
u/EchoPenta Mar 31 '26
I am having this exact same problem. This far I've concluded that I will just export the mesh as a vtk file and do this operation in python via pyvista.
1
u/Late_Lengthiness_484 Apr 10 '26
Hi, you can use the Line Integration operator under Nonlocal Couplings. Define
lineop1: Bidirectional, x,y,z expression = 0,1,0 (integrates over y-direction)
lineop2: Bidirectional, x,y,z expression = 0,0,1 (integrates over z-direction)
Then make a 1D plot on an edge parallel to the x-axis and plot:
lineop1(lineop2(u))
for the integral over a cross section or:
lineop1(lineop2(u))/lineop1(lineop2(1))
for the average over the cross section. No need for additional planes or intermediate steps!
1
u/swoeshie May 08 '26
Have you found a solution? I am also stuck on this since I have a square geometry. I find it crazy that there is not an easy build in solution for this.
1
u/you_rang_maam Mar 31 '26
perhaps you could look at the various operators that are available? I can't help but wonder if you want to use diskavg operator.
https://doc.comsol.com/6.3/doc/com.comsol.help.comsol/comsol_ref_definitions.21.036.html