My problem specification is as follows:
I want to have a closed duct, where in the middle there is a zone, where the fluid flowing through is cooled down, like it would in a heat exchanger but I am not interested in efficiency, pressure drop, coolant temperatures, etc, the only thing important is the inflow-outflow temperature difference, more precisely that the outflow temperature to be around a specific value, but the inflow temperature can vary (but it is always higher than the specified outflow), so that's why I wrote that it is like a very simplified case of a heat exchanger.

My first guess was to write an UDF to get the inflow average temperature and based on the temperature difference, zone size (and possibly others, haven't figured out yet) set a source term for the energy equation. The problem is that I am not very familiar with heat transfer problems so I am not even sure that this problem could be solved this way.

So my first question is that is it possible to solve this problem via UDF (or other methods)?
The second is that if it is possible - even though I know that it is a very generalized problem yet - than could you give me some guidelines or tutorials about similar problems?
Every hint and help is much appreciated!

My first guess was to write an UDF to get the inflow average temperature and based on the temperature difference, zone size (and possibly others, haven't figured out yet) set a source term for the energy equation.
Peter

This is indeed possible. But let me simplify it even more, let's say you want to add a source/sink term in your energy eq. Then, these could be a good starting points:here and here

I am also trying to understand the problem. So you've got this duct and somewhere in the duct there is a zone acting like a sink for the energy equation right? if you are only interested in the temperature difference between the input and output of this zone, why don't you limit the domain to only this region and change the ave temperature at the boundary? Not sure though just an idea...! can you add a sketch of the problem?

Thank you for your reply!
Reading again my question your idea to limit the geometry seems trivial, but it's because my description was a bit misleading and not complete enough, sorry about that!
So yeah, the temp difference is important, but that is just the beginning of a bigger project. Later this duct should be a part of a bigger geometry and it would connect two systems. From inlet side comes a higher temperature air from a pump system, and whatever temp it is I would like to cool it down to around a specified value before entering to the other pump system.
But for now I would like to know if it is possible to create such a simplified heat exchanger-like sink term by just modeling the duct first in 2D (sketch attached, but maybe now it is clear without it too), then it should be implemented in 3D, then attached to the whole system.

But for now I would like to know if it is possible to create such a simplified heat exchanger-like sink term by just modeling the duct first in 2D (sketch attached, but maybe now it is clear without it too)

The answer is affirmative! as a matter of fact I think the approach you are taking (simple 2D to 3D) is pretty reasonable. Wonder if you've written the udf or maybe formulate the sink term?
cheers!

No, I haven't done any programming and formulation yet as I have to dig deeper into the field of heat transfer and working with the energy equation, but I wanted to know first if it is feasible and wanted to have some guidelines which you have given, so thank you again for your help! I'll check back if some progress is made or have other questions