CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Calculation of the molar flow rate (http://www.cfd-online.com/Forums/fluent-udf/104905-calculation-molar-flow-rate.html)

 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 :

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"

DEFINE_EXECUTE_AT_END(measure_molar_flow_rate_inl)
{
Domain *d;
real molar_flow_rate_inl=0.;
face_t f;
d = Get_Domain(15);

begin_f_loop(f,t)
{
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) ???*/

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

 sylvix48 July 19, 2012 04:52

I have a litlle bit improved my code :

#include"udf.h"

#define i_ch4 1
#define i_h2 2

#define mw_ch4 16.04303
#define mw_h2 2.01594

DEFINE_ON_DEMAND(efficiency)
{
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);
face_t f;

begin_f_loop(f,t_inlet)
{

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

begin_f_loop(f,t_outlet)
{

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

efficiency=molar_outlet/(2*molar_inlet);
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

Quote:
 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 10:44.