CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF for mass fraction (spilled organic liquid) (

Klemens Schatka February 21, 2009 05:56

UDF for mass fraction (spilled organic liquid)

I wanted do model the evaporation of spilled organic liquid in Fluent 6 and tried to write an udf with DEFINE_SOURCE (depending on temperature, ...). My source is a wall with mass frac for the organic species. Without udf at constant mass frac the result is not so bad compared to usual calculations, but does not take account of temperature, etc.

No error message when interpreting, but when I hook it to the source I get this error message: wrong return type: void udf function expected. The udf function returns a real (as defined in udf.h) but no return value is expected. Can someone give me a hint how to set the mass frac to model a species source?

Maybe it's better to model the evaporation as a flux from the wall element?

Thx Klemens

mange February 22, 2009 06:58

Re: UDF for mass fraction (spilled organic liquid)
you should return the source value in a DEFINE_SOURCE udf. I am a bit confused about your problem... Do you have something like:

{ real source; ... .calc source(T); ... return source; }


then it should work. Otherwise try it in compiled version.


Klemens Schatka February 22, 2009 11:22

Re: UDF for mass fraction (spilled organic liquid)
Hello mange,

my code is similar to the code you posted.

My idea was to model an area which is emitting an organic substance (free evaporation in moving air) for calculating zones of hazardous atmospheres (explosion, workers safety). So first I defined a bottomarea as a wall element with fixed mass fraction (according to the vapor pressur at given surface temperature which is proportional to the volume fraction). Air flowing over the surface of this area is then "saturated" with exactly this fraction. This is a very rough model, but when corrected by the local temperatur and maybe some boundary layer calculation including local velocity, heat transport, radiation, etc. hopefully it will be a better result.

My first UDF I tried was using a macro DEFINE_SOURCE which shows this error because mass fraction of a wall does not expect a return value. After wasting the last night I tried to read the UDF handbook ;-) The mass frac on a wall element can be set by a profile macro and not by a source macro. So I made a DEFINE_PROFILE and set up all face elements to a fixed (and later calculated) value. The UDF is hooked to the species massfrac of a wall. Now it works, but I don't know if this is a correct solution. The next steps will be the comparison with some common models we use in safety analysis, implementation of the (very simple) Clausius-Clapeyron equation for p_vap(T) and maybe later some VLE-calculation for mixtures of liquids especially for water soluble substances.

My udf now looks like this
DEFINE_PROFILE(massfrac_profile, t, i)
face_t f;

begin_f_loop(f, t)
// for testing set mass frac of face element to 0.02 [kg/kg]
// later this will be replaced by a more sophisticated formula
// e.g. for water saturated at 15-25C, linear approx from hx-diagram: F_PROFILE(f, t, i)= 0.0155 + 0.001 * (F_T(f, t)-293.15)
F_PROFILE(f, t, i)=0.2
end_f_loop(f, t, i)

mange February 23, 2009 04:16

Re: UDF for mass fraction (spilled organic liquid)
ok :)

Now i see what you want to do. You are right about using the DEFINE_PROFILE for the wall. DEFINE_SOURCE is for interior cells.

good luck /M

shshiva17 July 28, 2009 01:27

Arey please send the source code for radiation for ch4.........mean udf???plz da...

All times are GMT -4. The time now is 00:45.