CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF to change heat transfer coefficient with wall temperature (

emmkell May 10, 2012 05:21

UDF to change heat transfer coefficient with wall temperature

I need to change the heat transfer coefficient on a wall with changing temperature on the wall. I have written a simple UDF to change the heat transfer coefficient, which is interpreting into Fluent with no problems, but when I run a monitor on the wall for Total surface heat transfer coefficient it is giving me strange answers with negative values. I know that very low values of ln() will give a negative answer but anything over ln(0.4) in this equation will give a postivie answer. At a temperature of 297, this equation should give a h value of 3.06, but instead it keeps returning a value of 0.0002.

Is my UDF too basic? or is the problem with my monitor?

#include "udf.h"

DEFINE_PROFILE(HTC, thread, index)
face_t f;
real Temp = 293.15;
F_PROFILE(f, thread, index) = 1.2854*log(Temp - 293) + 1.2822;

Or should i be using the return HTC function as is used in DEFINE_PROPERTY which change with temperature also?

Daniel Tanner May 10, 2012 09:05

You cannot use Define_Profile this way. There needs to be a loop that loops over each element on the boundary/face of interest.

I ripped the udf below out of the UDF manual. You need to have something of this form (take out the velocity stuff and enter your temperature stuff).

Currently I think your UDF will only apply this correction to the first element of the face!

Let me know how you get on.

/************************************************** *********************
UDF for specifying steady-state velocity profile boundary condition
************************************************** **********************/
#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position)
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;

begin_f_loop(f, thread)
y = x[1];
F_PROFILE(f, thread, position) = 20. - y*y/(.0745*.0745)*20.;
end_f_loop(f, thread)

emmkell May 10, 2012 09:27

Thanks Dan!

I had tried some variations of this but didnt get anything to give the right ht coefficient. I will give it another try just changing the details to what I need.

I read in a couple of differnet threads on this forum that fluent doesnt give accurate readings of heat transfer coefficient from its surface monitor readout and I'd need another UDF to findout what fluent is settin gthe heat transfer coefficient to.

alighasemian June 9, 2012 00:23

Hi Emmkell, did you solve your problem? I mean did write a UDF which change the heat transfer coefficient on a wall in terms of the wall temperature?
if you solved your problem could you help me? I have a similar problem!
this is my email:

emmkell August 8, 2012 11:23

I got this working, I forgot to post it up here, using your recommendation Daniel, thank you!

I had to change y = x[1] to y = x[0] for some reason, i didnt understand what it meant at the time but i understand now that it is picking the values in the x array in either cell 0,1 or 2, so the fact that it worked for me must be something to do with how i set up my geometry?

Changing the wall thickness also helped.

#include "udf.h"

/* UDF Define Temperature dependant heat transfer coefficient) */

DEFINE_PROFILE(htc, thread, position)
face_t f;
real x[ND_ND]; /* this will hold the position vector */
real y = F_T(f,thread);

begin_f_loop(f, thread)
y = x[0];
F_PROFILE(f, thread, position) = 0.7942 + 1.3915*log(y);
end_f_loop(f, thread)

Wohoo! Now on to the next UDF problem!

hatef June 19, 2013 12:40


This is wrong!


ddmillar July 10, 2013 12:49


Care to elaborate on why this is wrong? I'm about to start writing a similar UDF and would greatly appreciate an explanation on why you think this is incorrect.


hatef July 11, 2013 06:19


Because in Emma's code, she has defined y (the temperature of the face) outside the loop, and inside the loop the value of y is overwritten by x[0]. Although this was really helpful, but unfortunately this does not work. I have written a code for time and temperature dependent heat transfer coefficient as follows;

#include "udf.h"

DEFINE_PROFILE(htc, thread, position)
face_t f;
real y;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
y = F_T(f,thread);
if (t<250)
F_PROFILE(f, thread, position) = 0.00000026*(y*y*y) - 0.00038*(y*y) + 0.25*y - 38;
F_PROFILE(f, thread, position) = 0.00000014*(y*y*y) - 0.00021*(y*y) + 0.14*y - 20;
end_f_loop(f, thread)


kaeran January 4, 2015 14:14

Hello Hatef,

I have similar problem in defining HTC through UDF.
If I am not wrong, bulk temperature or reference temperature has to be also included in the program.

But I could see only a temperature polynomial equation is defined to get HTC.
Could you please expalin me, how did you arrive with this equation?

I am relatively new to UDF...So please help me out in understanding the UDF written by you.

geeteshwaghela1234 April 7, 2015 10:27

Want to write UDF for heat flux on wall for a cylindrical tube change with temperatur
hey guys,
I am doing analysis on a cylinder with 2D axisymmetric model in fluent.
I have implemented a profile file for outer wall of cylinder but i want to implement a udf for inner wall as a function of temperature so that i could get accurate temperature on axis(fluid region).
my axial length is 0.1m and longitudnal length is 0.003m from axis.
I have tried using constant heat flux and coupled condition on inner wall but it does not help.
i want to get temperature profile in fluid region.

`e` April 7, 2015 18:52

Why not let Fluent use the energy equation to simulate the temperature profile on the inner wall?

geeteshwaghela1234 April 7, 2015 23:16

Hey e,
I have outer wall temperature profile from experiment using methane-air as fluid entering into the geometry.
I made the temperature profile as boundary condition on outer wall using profile.
If i let the inner wall as coupled then axis nor the inner wall does not get sufficient temperature as it should get. the material i use is fused silica for cylinder.
If i choose inner wall as heat flux and i gave it as zero then inner wall receives proper temperature but axis remains at 300 K.
According to the results my inner wall and axis both should have a temperature of 1300 K but i am getting till 800 K only at the place of highest temperature.
What should i do?

All times are GMT -4. The time now is 14:32.