Heat Transfer Coefficient - Porous Media - LTNE

  • Last Post 29 May 2020
  • Topic Is Solved
RyMor posted this 26 May 2020


I have some general questions about a UDF I have been using to define the heat transfer coefficient between air and the material which makes up my porous domain ("sand"). The flow is Darcy governed. The UDF is described below and my QUESTIONS are found beneath the UDF.

Somethings to note about my UDF:

d_p (particle diameter, meters) and Pr (Prandtl Number) are both explicitly defined.

In particular, Pr is a value from literature for which my Nusselt Number (Nu) expression is valid.

I also have used the UDF with a "calculated" Pr and simulation results did not seem to be noticeable different (at least from my assessment). 


#include "udf.h"



    cell_t c;

    real Nu,Re,Pr;

    real dens, visc; /*Fluid*/

    real cond, cp; /* Fluid*/

    real d_p;

    d_p = 0.0001875;

    Pr = 0.72;



        dens = C_R(c,t); /*Density of fluid*/

        visc = C_MU_L(c,t); /*Viscosity fluid*/

        cond = C_K_L(c,t); /*Conductivity fluid*/

        cp = C_CP(c,t); /*Specific heat fluid*/


        Re = (ND_MAG(C_U(c,t),C_V(c,t),C_W(c,t))*d_p*dens)/visc;


        Nu = 0.001*(pow(Re,1.97)*pow(Pr,1./3.));


        F_PROFILE(c,t,i) = (Nu*cond)/d_p;






1) I have read that DEFINE_PROFILE is used to create a custom boundary profile. Why then can it be used to define a heat transfer coefficient throughout the domain?

2) Why is it possible that F_PROFILE can be used while looping over cell values? I have also used C_PROFILE within this UDF in place of F_PROFILE with no significant difference in simulation results (to my knowledge).

3) Overall, are there any glaring improvements I can make to my UDF?

4) Finally, I have been wanting to implement some method to "tell me" if my UDF is outputting the correct values. I have thought of printing the heat transfer coefficient values to a .txt file. Any suggestions on the best way to check UDF outputs and debug?


Thanks in advance for any help that can be offered and please let me know if any further clarification is needed. 


Order By: Standard | Newest | Votes
Kremella posted this 27 May 2020


Here are the answers.

1.  You can use DEFINE_PROFILE to define a custom boundary profile or cell zone condition that varies as a function of spatial coordinates or time. Once you compile/interpret the UDF, you will be hooking this to the appropriate boundary condition or cell-zone condition dialog box. Please read through section in the Fluent Customization manual for additional details.

2.F_PROFILE stores a boundary condition in memory for a given face and thread and is nested within the face loop as shown in the examples below. However, in your case, you are looping over the cells using the begin_c_loop (instead of begin_f_loop). Please double-check if this is what your intention is.

3. Regarding UDF, we can certainly help with syntax related questions. We will, however, not be able to debug UDF codes from scratch. Please let me know if you are looking for something specific.

4.  Please use fprintf or message statements to print the values. Fluent will print the values directly in the Fluent Console.

I hope this helps.



  • Liked by
  • RyMor
RyMor posted this 28 May 2020

 Hi Karthik, 

Thanks for the responses. Here are my replies:

1) Understood. 

2) As I am fairly new to Fluent, this is a hard question to answer. My intention is to set the heat transfer coefficient between the solid and fluid zones of my porous media model (which varies with the temperature dependent fluid properties, thus requiring this UDF). Following along this thought process, I would think that the objective of my UDF should be to specify a "cell-centered" value which Fluent can then use to solve the energy equations of both the fluid and solid zones. It is not clear to me why one would specify a non-transport variable on a cell face. Does this direction of thought sound consistent? Any comment would be helpful. 

3) Syntax wise, if I do use a cell loop (i.e. being,end_c_loop) would it be correct to use C_PROFILE within this loop? In relation, the Fluent UDF manual displays examples UDFs in which F_PROFILE accepts a cell index argument (i.e. cell_t) as opposed to a face index argument (i.e. face_t). Would you be able to comment on why is this possible/what is the logic? Furthermore, what is the difference between C_PROFILE and F_PROFILE?

4) Understood.


Thank you again for the help. 


Kremella posted this 28 May 2020

Hello Ryan,

Here are my responses.

2. Are you using the non-equilibrium thermal model for the porous media? If this is the case and if I understand correctly, you are trying to supply the value of heat transfer coefficient through this UDF. Is my understanding correct? If this is the case, I think you are in the right direction. You might have to verify if the code is working the way it should and you are seeing the correct values of h between solid and fluid zones of the porous media.

3. Regarding the difference between C_PROFILE (this is particularly useful for the porous media problems) and F_PROFILE - DEFINE_PROFILE is a macro that always uses a pointer to thread on which boundary condition or cell zone where it is being applied to. Yes, you are correct. In some cases, where one is looping over the cells, F_PROFILE uses a cell index argument.

Please have a look at the following example in the Customization manual and you should be able to use either approach - " Example 6 - Viscous Resistance Profile in a Porous Zone" - Here is the link: https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v201/en/flu_udf/flu_udf_sec_define_profile.html?q=C_profile

Please make sure you are getting the correct values using fprintf / message statements.

I hope this helps.

Oh, one more thing - in case you are not able to open the link properly, please have a look at the instructions provided here. https://studentcommunity.ansys.com/thread/how-to-access-the-ansys-online-help/

If this answers your question, please mark it as 'Is Solution' so others can benefit.

Good luck.




  • Liked by
  • RyMor
RyMor posted this 29 May 2020

Hi Karthik,

Thanks again for these responses. 

2) Yes, your understanding is correct. I will work on extracting h-values from my UDF to check.

3) The example you mentioned is actually the instance of F_PROFILE using a cell index argument that I was referencing. Unfortunately, I still have not been able to identify the difference between F_PROFILE and C_PROFILE from your response. I do understand the overall function DEFINE_PROFILE. 

Would it be fair to say that F_PROFILE applies the boundary condition to the face of a cell (which then will be interpolated to the cell-center)? While C_PROFILE applies the boundary condition directly to the "cell-center"?

Thank you again for your help, 


Kremella posted this 29 May 2020


Yes. On a very superficial level, I'd think of them as trying to apply it to the face (F_PROFILE) vs. cell centers (C_PROFILE). Depending on how you code, you should be able to use one vs. the other. Strictly speaking, if you are trying to use DEFINE_PROFILE for a variable which is required at the cell-center (similar to the Viscous Resistance in Porous media formulation), I'd continue using C_PROFILE.



RyMor posted this 29 May 2020

Thank you!