CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Calculation of the molar flow rate

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2012, 09:56
Question Calculation of the molar flow rate
  #1
New Member
 
Join Date: Jul 2012
Posts: 6
Rep Power: 14
sylvix48 is on a distinguished road
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"

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

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);

Thank you for your future answers !!!
sylvix48 is offline   Reply With Quote

Old   July 19, 2012, 05:52
Default
  #2
New Member
 
Join Date: Jul 2012
Posts: 6
Rep Power: 14
sylvix48 is on a distinguished road
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);
Thread *t_inlet=Lookup_Thread(d,inlet_ID);
Thread *t_outlet=Lookup_Thread(d,outlet_ID);
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.

Last edited by sylvix48; July 19, 2012 at 07:04.
sylvix48 is offline   Reply With Quote

Old   July 19, 2012, 06:15
Default
  #3
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Quote:
Message("Efficiency %f %\n",efficiency);
Are you sure that the second % isn't misunderstood by the compiler?
flotus1 is offline   Reply With Quote

Old   July 19, 2012, 06:34
Default
  #4
New Member
 
Join Date: Jul 2012
Posts: 6
Rep Power: 14
sylvix48 is on a distinguished road
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 ?
sylvix48 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to calculate phase flow rate? sangramroy FLUENT 0 January 11, 2012 14:02
Mass Flow Rate is not converging destgir448 CFX 5 December 11, 2010 06:55
Calculation of mass flow rate msrinath80 OpenFOAM Running, Solving & CFD 0 April 18, 2007 15:05
mass flow rate error Masood FLUENT 0 May 22, 2005 01:32


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