
[Sponsors] 
August 7, 2009, 04:41 
UDF Mass flux computing

#1 
New Member
Carlo Locci
Join Date: Apr 2009
Posts: 8
Rep Power: 10 
Hi everybody: I'm trying to write an UDF which calculates the mass flux of an outlet. I need it to calculate a pollutant concentration: for this reason the DEFINE in which my computing is inserted is the DEFINE_ADJUST. my problem is that this udf doesn't return the total mass flux value I get from the REPORT tool.
The problem is 2D axisymmetric, so my outlet is seen like a circular area. #include "udf.h" DEFINE_ADJUST(massflux, domain) { int zone_ID = 4; Thread *t = Lookup_Thread(domain,zone_ID); face_t f; float r, x[2]; real summ=0.; real m; real NV_VEC (A); begin_f_loop(f,t) { F_CENTROID(x,f,t); r=x[1]; F_AREA(A,f,t); m=F_U(f,t)*F_R(f,t)*NV_MAG(A)*6.28*r; summ += m; } end_f_loop(f,t) printf("massf: %g\n", summ); } The 6.28 is from 2*pi. It derives because of the area computing in polar coordinates. If you have any idea to carry on the computing in a simpler way, please tell me it. Last thing: I don't get any error while fluent compiles it. It's just that I obtain different values. THANKS 

August 11, 2009, 22:41 
Please check your formulation

#2 
New Member
Bobby
Join Date: Aug 2009
Posts: 7
Rep Power: 9 
I believe that your formulation is incorrect for flux. You just add the mass flow rate for each face and then finally divide by pi*Rmax^2.
I'm not sure why you are using 2*pi*r*area in the evaluation of m. Instead you need to replace area by dr (i.e cell length in r direction). You will have m_dot = rho*U*2*pi*r*dr. I am assuming that the actual flow velocity is in the U direction i.e flow parallel to the area vector. The other way is to use the F_FLUX(f,t) macro and if needed you can play with it. I'm not sure if this macro accounts for axisymmetric calculations! Good Luck and have fun! Last edited by PawnPace; August 12, 2009 at 01:15. 

August 12, 2009, 04:03 
Annulus

#3 
New Member
Carlo Locci
Join Date: Apr 2009
Posts: 8
Rep Power: 10 
Dear PawnPace,
let's imagine an outlet of a 2d grid: it is formed by several segments. Now, when you ask to fluent to consider the case as axisymmetric, you obtain a cylinder as you can see in this link: http://jullio.pe.kr/fluent6.1/help/html/ug/node347.htm Now, doing this in the outlet, for each segment you have an Annulus. The area of an Annulus is: (R^2  r^2)*pi Considering it as infinitesimal you get: ((r+dr)^2r^2)*pi=(r^2+2rdr+dr^2r^2)*pi Neglecting the dr^2 you have that the infinitesimal area of the considered Annulus is 2pi*r*dr. Applying all this to our case, you have that r and dr are respectively the y coordinate and the height of the generic segment of the outlet. You have to sum the area of each Annulus multiplied for the density and for the velocity axial component. By this the 2*pi derives. Anyway, I'm going to try your hints and I'll let you know about 

August 12, 2009, 13:49 

#4 
New Member
Bobby
Join Date: Aug 2009
Posts: 7
Rep Power: 9 
I think there was some misunderstanding. Anyway I just wanted to tell you that your formulation of mass flow rate does not match units on right side of your equation.
Since, you are using 2d formulation and the area for the face (i think it) is the edge length multiplied by unit depth (not sure). Numerically your equation may be correct but dimensionally it is not. Well I hope my posts were helpful! Regards, PawnPace 

August 17, 2009, 11:19 
I did it!

#5 
New Member
Carlo Locci
Join Date: Apr 2009
Posts: 8
Rep Power: 10 
Well, I did it!
#include "udf.h" DEFINE_ADJUST(massflux, domain) { int zone_ID = 4; Thread *t = Lookup_Thread(domain,zone_ID); face_t f; real summ=0.; real m; real sumarea=0.; real area; real NV_VEC (A); begin_f_loop(f,t) { F_AREA(A,f,t); m=F_U(f,t)*F_R(f,t)*NV_MAG(A)*6.28; summ += m; area=NV_MAG(A)*6.28; sumarea += area; } end_f_loop(f,t) printf("massf: ,%g,%g\n", summ,sumarea); } Well, this works fine! It makes me get exactly what I wanted both in terms of area and mass flux. Thanks to your suggestion, I thought that multiply an area by a length (in our case r) could be dimensionally wrong. So I decided to multiply only by the area deleting 2*pi*r. After having done it, results were still wrong. Fortunately I've thought to look at what was the ratio between my (wrong) results and the ones I would have wanted to get. Well, that ratio was exactly 6.28! This is the reason the 6.28 lasts. In order to prove if It was right, I've tried it also in others domains and It computes the right area and mass flux in all of them! So I think that the NV_MAG(A) in axisymmetric cases is just the r*dr we spoke above, which is the difference between R^2 and r^2. Thanks you! 

August 17, 2009, 12:22 

#6 
New Member
Bobby
Join Date: Aug 2009
Posts: 7
Rep Power: 9 
I'm glad that it's resolved! Good Luck and have fun with Fluent! Regards, PawnPace


November 23, 2014, 22:59 
thanks a lot! but I use your code but i didn't got the cooperate massflow.

#7  
New Member
sam toris
Join Date: Mar 2014
Posts: 2
Rep Power: 0 
Quote:
I think the original F_FLUX function could bring a similar flux result, but not accurate, hope for your reply! 1124 11:06 I work it out! I think maybe the unaccuracy was cuased by an unsteady flow. 

Tags 
computing, flux, mass, udf 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Prob with UDF on parallel computing  mainamunna  FLUENT  0  February 12, 2008 09:26 
writing UDF for modelig mass transfer for VOF  ardalan soleymani  FLUENT  0  July 11, 2007 01:09 
UDF solution variable for timeaveraged mass frac?  A. S.  FLUENT  0  May 14, 2007 16:44 
UDF ; Mass tranfer function  Jay  FLUENT  0  March 10, 2005 02:53 
total mass flux correction for compressible fluid?  Francesco Di Maio  Main CFD Forum  0  August 21, 2000 04:23 