CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDS porous media (

Nagendra September 13, 2002 02:47

UDS porous media

I am trying to add an energy equation for the solid material in the porous media in FLUENT.

My User Defined Scalar is the Solid Temperature. My Diffusivity is the heat conduction and my source term is the convective heat transfer.

I believe that using such a model I will be able to model a more realistic heat transfer between hot gasses flowing through a porous media.

Could anyone please advice me whether the following steps are suitable:

I write a code which contains DEFINE_DIFFUSIVITY, DEFINE_SOURCE and enum {T_SOLID}.

I then try and compile this to my test case

In Define>User Defined>Scalar I choose ONE for scalar and none for Flux

Then I go to Boundary conditions for my porous media I add the source term and in the Materials panel I add uds_diffusivity for my porous solid

I go to Control and solve for all the equations "including" my UDS

Could anyone please tell me if this process is right as I couldn't find good details of UDS in FLUENT


Greg Perkins September 14, 2002 20:30

Re: UDS porous media
I've written some code for this -see


Nagendra September 15, 2002 22:35

Re: UDS porous media
Dear Mr. Perkins,

Thanks for your response and code. I did look at your code and it really is well written and very comprehensive.

I took the DEFINE_DIFFUSIVITY, DEFINE_SOURCE for solid energy/fluid energy and real Gas_Solid_HTC from your code and defined 2 UDS in "enum" - ZETA and SOLID_TEMP and compiled into my code.

It did compile into FLUENT 6. But, could you also tell me what to do now after compiling, because it doesn't seem to work thereafter for me. This is what I do:

1. Go to Define>User Defined>Functions and compile your code (with mods as explained above)

2. Go to Define>User Defined>Scalars and pick 2 for scalars and none for Flux Functions

3. Go to materials panel and define uds_diffusivity for air (I am surprised that this diffusivity appears in fluid zone while theoretically it should appear for the porous material (solid) - don't you think theres an error here coz diffusivity is for the scalar SOLID_TEMP!!)

4. Go to "Fluid Zone" where my "porous" material is placed and add the source terms for solid and source terms for fluid.

5. Solve for SOLID_TEMP only and leave ZETA alone

These are the steps that I followed but the code doesn't seem to be added properly!! FLUENT is unable to start!! could you please help me out with the post UDF processes. I'll be highly grateful


Greg Perkins September 15, 2002 22:53

Re: UDS porous media
Hi, I think for Fluent 6 you should change the name of the UDS_Diffusivity macro to something else. Apparently Fluent 6 also uses this name internally, which wasn't the case in Fluent 5.

Make sure you define enough UDSs and maybe check if you need UDMIs. I added some storage stuff there too.

The UDS Diffusivity is the diffusivity for the user defined scalars - not for air.

You connect the SRCE terms to the appropriate equation. For fluid energy this is the standard energy eqn, for the solid energy this is the solid_temp uds.

Make sure you don't solve all uds's defined - just the solid temp (and may zeta if you want porosity to change - but you'll need to add a mass source eg. due to chemical reaction). You the solve-controls panel.

Other than this, I really can't too many more details, due to time constraints sorry.

Good Luck


Sachin September 16, 2002 06:53

Re: UDS porous media

Yes, I too used Greg's code and it is well written.

You're right that the diffusivity shows up in the air panel because FLUENT says (section 9.2) that UDS can only be defined for the fluid cells !!

So essentially, I feel that if you have to use an energy equation for solid material in your porous media, you should analyse it as an energy sink term in your energy equation for fluid.

Another advice would be to include appropriate wall boundary conditions as they also affect the soln.

I still am trying to figure out the right way to implement this UDS into FLUENT after it has been written and compiled.. !!

Greg Perkins September 16, 2002 18:54

Re: UDS porous media
The code does these things - to some limited extent.

Essentially the UDS sovles for the temperature of the solid phase. The solid and fluid energy udfs compute the interphase heat transfer based on the temperature difference and the surface area for heat transfer.

You can set wall boundary conditions for the "solid temperature" using the UDS panels in Fluent. Ie for a constant solid wall temperature define the UDS for the solid temperature at a wall to be a certain value.

Yes, you can extend this - I now have this model extended to include multiple solid phases, arbitrary chemical reactions and simple solids flow due to chemical consumption etc. But this code is far too complex to post so that's why I've just posted this simpler version to get people started. Its up to you guys to extend it for your applications. Or to write something even better - and post that back!

Oh also note that due to limitations in Fluent re defintion of Cp, the above code only works within a steady solution method (or pseudo-steady) - ie you need to assume the gas phase is steady, since the transient term in the energy equation in Fluent is not handled correctly if you add another phase. Generally this is no problem since gas phase residence time is must shorter than the solid pahse.


Nagendra September 17, 2002 01:05

Re: UDS porous media
Dear Greg,

This is an excellent code man.. it has started to run on my case, lets see how the results look like.

I just took diffusivity (with its name changed coz of FLUENT internal naming), source terms for fluid and solid energy, specified wall BCs for fluid and UDS and its running fine now.. lets hope it continues :)

Thanks a lot!

sachin September 18, 2002 02:12

Re: UDS porous media
yippee.. the code is running finally for me. I am trying to get some experimental data or test cases to validate this now, coz, I have started to get contours which are making some sense, but, I want to know the accuracy :) will post the details when ready thanks greg sachin

neilduffy1024 January 18, 2011 10:07


I realise this post is pretty old but does anyone have a copy of the code above or similar. much appreciated.


neilduffy1024 January 24, 2011 11:16

For those who are interested, I found it at

Excellent code, many thanks to Greg for posting it.


oky February 1, 2011 21:57

Hi everyone,

I'm trying simulation porous media in rectangular channel, but the result isn't suitable with any research.

So, would you help me. I wish someone can check my simulation and give some reports if there is something wrong.

Thank you for your help.
Please send your e-mail, than i will send you my works to to your email.
my e-mail:

OKY Andytya P

I use ANSYS Fluent 6.3 [CFD]

virrast July 21, 2016 08:03


Originally Posted by Greg Perkins
I've written some code for this -see


Dear Greg,

I downloaded your code long time ago. It was very useful for me. However, I have significantly changed it, and unfortunately I am not able to find original version. I have also tried to download it, but the provided link does not work anymore. Could you post another link to your udf, or send it to me via email. My email is

All times are GMT -4. The time now is 10:24.