CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   Calculation of the molar flow rate (

sylvix48 July 18, 2012 08:56

Calculation of the molar flow rate
Hello everyone !

In my problem I have a cylindrical geometry with an inlet and an outlet with a mixture inside and I want to determinate the molar flow rate in the inlet and the outlet. The formula to calculate the molar flow rate is :

\int\int C*S*VdS

Where C is the concentration of the specie, V the velocity of the flow and S the surface

The Inlet ID is 23, the outlet is 24 and my mixture ID is 15.

I've tried to code it but I've several issues :

Here's my UDF for my inlet case:

#include "udf.h"

Domain *d;
real molar_flow_rate_inl=0.;
face_t f;
Thread *t;
d = Get_Domain(15);
t= Lookup_Thread(d, 24);

molar_flow_rate_inl+=NV_MAG(A)*F_W(f,t)*"Concentra tion";

/* How to define the face concentration of a specific specie when my mixture contains several species and how I can define A in NV_MAG(A) ???*/

printf("Molecular Flow Rate inlet: %g\n",molar_flow_rate_inl);

Thank you for your future answers !!!

sylvix48 July 19, 2012 04:52

I have a litlle bit improved my code :


#define i_ch4 1
#define i_h2 2

#define mw_ch4 16.04303
#define mw_h2 2.01594

real A[ND_ND];
real molar_inlet=0;
real molar_outlet=0;
real efficiency=0;
int inlet_ID=23;
int outlet_ID=24;
Domain *d=Get_Domain(1);
Thread *t_inlet=Lookup_Thread(d,inlet_ID);
Thread *t_outlet=Lookup_Thread(d,outlet_ID);
face_t f;


molar_inlet += F_FLUX(f,t_inlet)*F_YI(f,t_inlet,i_ch4)/(mw_ch4)*1e-3;
Message("inlet %f mol/s of CH4\n",molar_inlet);


molar_outlet += F_FLUX(f,t_outlet)*F_YI(f,t_outlet,i_h2)/(mw_h2)*1e-3;
Message("outlet %f mol/s of H2\n",molar_outlet);

Message("Efficiency %f %\n",efficiency);


It is compiled under Fluent but it returns 0 for each case while there is a mass rate of CH4 and H2 at the boundaries. At the end of calculation it is stated :" Unable to enter text edit mode " maybe it is the error ? I don't understand why it doesn't work, if someone could help me.

flotus1 July 19, 2012 05:15


Message("Efficiency %f %\n",efficiency);
Are you sure that the second % isn't misunderstood by the compiler?

sylvix48 July 19, 2012 05:34

No it's not that.

I've tried without it still doesn't work.

Moreover it is already 0 for the inlet and the outlet.

I don't get also why it is printed several time on my screen when I ask to write it once ?

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