CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   how to get such mass fraction (https://www.cfd-online.com/Forums/fluent/36342-how-get-such-mass-fraction.html)

handou April 12, 2005 02:37

how to get such mass fraction
 
hello. now, i am modeling a heat transfer flow. i want to get the mass fraction of the fluid in a certain temperature range. how can i deal with this problem? thanks.

rom April 12, 2005 04:44

Re: how to get such mass fraction
 
the follwing udf can be run in interpreted mode and computes the fluid mass within tmin and tmax (K).

good luck rom

#include "udf.h"

#define Tmin 1200

#define Tmax 1500

DEFINE_ON_DEMAND(get_fraction)

{

Domain *d;

cell_t c;

Thread *t;

real mf,mft;

mf=0;

mft=0;

d = Get_Domain(ROOT_DOMAIN_ID);

thread_loop_c(t,d)

{

begin_c_loop(c,t)

{

if((C_T(c,t)>=Tmin) && (C_T(c,t)<=Tmax)) mft += C_R(c,t)*C_VOLUME(c,t);

mf += C_R(c,t)*C_VOLUME(c,t);

}

end_c_loop(c,t)

}

printf("\nfluid mass = %f kg",mf);

printf("\nfluid mass within temperature range = %f kg",mft);

}

handou April 12, 2005 06:57

Re: how to get such mass fraction
 
oh, thank you, rom. this really help me a lot

handou April 12, 2005 09:22

Re: how to get such mass fraction
 
hi, rom. i try to use this udf on my computer.it can be compiled successfully. but, when i try to execute it from "execute on demand" panel, there is no reaction at all. i want to know where is the result printed to? thanks!

rom April 12, 2005 09:59

Re: how to get such mass fraction
 
Sometime Fluent doenst get the printf command right. I tested the udf on my machine (WinXP Fluent6.2) and it worked. You can substitute the "printf" with "Message". This usually solves the problem but then the udf will not longer run in interpreted mode so you will have to compile it first.

good luck rom


All times are GMT -4. The time now is 17:29.