# How to apply own heat transfer coefficients by UDF?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 12, 2017, 05:45 How to apply own heat transfer coefficients by UDF? #1 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 Hello everyone, I have made some measurements concerning the heat transfer coefficient and i would like to apply these values into the model instead of using the ones calculated by Fluent. Unfortunately, there is no example code on applying HTC by UDF in the manual. But I found some codes here in the forum I am trying to apply. For practise, I would first like to start with a function that configures an HTC of 10000 at the whole interface between solid and fluid. I use this UDF for that: DEFINE_PROFILE(pressure_profile,t,i) { face_t f; double htc; begin_f_loop(f,t) { htc=100000(F_T(f,t), 2.0); F_PROFILE(f,t,i) = htc; } end_f_loop(f,t) } Unfortunately this UDF does not work. Can someone explain me where the problem is? Besides that, can someone tell me how I actuall hook the UDF? Best regards h0rst

 March 12, 2017, 14:20 #2 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 Code: `htc=100000(F_T(f,t), 2.0);` What are you trying to do with this line? It is wrong, but I don't see the intention so it is hard to improve...

March 15, 2017, 00:53
#3
Member

Join Date: Nov 2016
Posts: 73
Rep Power: 9

I looked deeper into the functions and found out, that define_profile is not right for me.
Now I have programmed a UDF where I can actually change the heat transfer coefficient with the following source code:

real h ; // heat transfer coefficient (W/m^2 C)

{
// Define the heat transfer coefficient.

h = 32500;
}

DEFINE_HEAT_FLUX(heat_flux, f, t, c0, t0, cid, cir)
{

cid[0] = 0;
cid[1] = h;
cid[2] = h;
cid[3] = 0;
}

I build a very simple model and tried to work with these values. it is a rectangular tube flowed through by water. An inhomogenous power density is applied on the tube. Attached is the picture of the temperature distribution.
I use this simple model for testing new things with fluent

So, first I had a look on the results by looking on

- Wall fluxes --> Wall func. heat transfer coefficient

The intermediate value is about 22.000.

So, then I implemented the UDF above and expected to get similar results if I would have applied an h of 22.000 as well. Actually, the temperature was higher so I tried to find the right h until the values fit to the ones calculated when not using UDF.

I need to increase h to 32.500 to have similar temperatures in the model.

Does someone know why it behaves like that?

Best regards
h0rst
Attached Images
 simple-fluent-model.png (23.2 KB, 24 views)

 March 17, 2017, 07:18 #4 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 I applyed the process to my model and found out that when I increase the HTC by factor 2, I get quite good values . But I have no idea where this factor comes from. Fluent calculates the heat flux using the cell information next to the wall. I would like Fluent to calculate by using the reference temperature (27,9 °C) but it gives divergence failures if I apply the following source code: cid[0] = h*(F_T(f,t)-301.05); cid[1] = 0; cid[2] = 0; cid[3] = 0; Does someone has an idea or proposal about this issue?

 March 17, 2017, 07:35 #5 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 I don't know about the factor 2, but your UDF can be much simpler: Code: ```DEFINE_HEAT_FLUX(heat_flux, f, t, c0, t0, cid, cir) { real h = 32500; cid[0] = 0; cid[1] = h; cid[2] = h; cid[3] = 0; }``` Unless you also use h in different UDFs that you did not show, it makes no sense to make it global and use DEFINE_ADJUST to set it...

 March 18, 2017, 13:40 #6 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 Hello pakk, thank your for the hint. I changed it and this simplifies my UDF :-) The factor 2 seems to be by random. As far as I understand, fluent calculates the HTC between cell temperature and wall temperature. But since my flow consists of many cells per wall element, it only considers the cell next to the wall which is of course the hottest. The mean water temperature is 303.05 k (29.9 °C) between inlet and outlet and I would like to implement that instead of the individual cell temperatures. I changed the UDF at one point by setting cid[1]=C_T(c0,t0)*h/303.05; This actually gives me good resutls. But actually I would expect that the cid should be cid[1]=303.05*h/C_T(c0,t0); (because the formula is: qid = cid[0] + cid[1]*C_T(c0,t0) - cid[2]*F_T(f,t) - cid[3]*pow(F_T(f,t),4)) but this leads to extreme bad results (temperatures 30 times higher of the solid surface). Is my approach to calculate the HTC at the mean water temperature reasonable and the implementation? Why does the formula cid[1]=303.05*h/C_T(c0,t0); does not work out at all? Best regards h0rst

 March 27, 2017, 12:32 #7 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 I've faced up again with this project and checked the surface temperature with the wall heat transfer coefficient used by Fluent. I applyed this value as input value for cid[1] and cid[2] and multiplicated each value with factor 2: cid[1]=2*h //h=mean average value of wall heat transfer coefficient cid[2]=2*h The mean-average temperature difference of the edited surface with this new h compared to the model where Fluent computes h is about 0,3 %. This seems to be unlikely then that h is by random to be multiplicated by 2. But still I have no idea where this factor comes from. Best regards h0rst

 March 28, 2017, 02:42 #8 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 I think I see the problem... Fluent calculates the heat transfer from the temperature of the wall and the temperature of the fluid close to the wall. You want to calculate the heat transfer from the temperature of the wall and the temperature far away from the wall. These are two different things, so it is not surprising that they give a different answer. Moreover: you are using the wrong one. Physically, the heat transfer is determined by local properties, not by properties far away. If you want to impose a constant heat flux, apply a constant heat flux. If you want to let Fluent calculate the heat flux according to local temperatures, do that. But choose, don't try to do both at the same time, that does not make sense.

 March 28, 2017, 02:51 #9 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 Hello pakk, thank you for your answer. I also thought about that issue. I want to apply a constant h but the heat flux shall be calculated by Fluent. You wrote that Fluent uses the cell temperature at the wall whereas I use the reference temperature. How can I change the UDF that Fluent uses the reference temperature instead of the cell temperatures at the wall when I apply the constant h? Best regards h0rst

 March 28, 2017, 03:02 #10 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 "the heat flux shall be calculated by Fluent." How? Which equation do you want Fluent to use?

 March 28, 2017, 03:08 #11 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 With this formular: qid = cid[0] + cid[1]*C_T(c0,t0) - cid[2]*F_T(f,t) - cid[3]*pow(F_T(f,t),4) I specify cid[1]= h*T_Ref/C_T(c0,t0) and cid[2]= h But this also does not work. What also wonders me is that I extract the average wall function heat transfer coefficient (named it fluent_h) when I have calculated with Fluent. Then I put this value back into Fluent by cid[1]= fluent_h cid[2]= fluent_h and the result is that the temperature is much higher. if I choose cid[1]= 2*fluent_h cid[2]= 2*fluent_h the temperature distribution is like as I haven't changed the cid values at all.

 March 28, 2017, 03:14 #12 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 I see the programming code that you intent to use, but I was trying to ask something else: which equation (from physics) do you want Fluent to use? [edit:] I ask this because I have the impression that you want to apply a constant heat flux, but you don't realize this yet.

 March 28, 2017, 03:15 #13 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 I want Fluent to use the equation: Q°= h*(T_Surface-T-Fluid)

 March 28, 2017, 03:17 #14 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 And which values do you want Fluent to use for T_Surface, and what for T_Fluid?

 March 28, 2017, 03:19 #15 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 For T_Surface, it shall use the value that actually the wall has, so I would think F_T. For T_Fluid, it shall use the mean Fluid temperature which is 27.9 °C.

 March 28, 2017, 03:21 #16 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 Are you calculating the temperature of the solid wall? Or are you giving that to Fluent?

 March 28, 2017, 03:23 #17 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 No I am giving that to Fluent. I also calculated an average value which is 47.3 °C but I am not applying that because it can vary quite much whereas the Fluid temperature does not change that much.

 March 28, 2017, 03:32 #18 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 Q°= h*(T_Surface-T-Fluid) You know h, you know T_Surface and you know T_fluid. So why don't you just calculate Q° yourself, and give that to Fluent?

 March 28, 2017, 03:33 #19 Member   Join Date: Nov 2016 Posts: 73 Rep Power: 9 I want to try that. But how can i do this with UDF?

 March 28, 2017, 03:42 #20 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 You don't need a UDF for that.