CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   volume flow rate error in udf (http://www.cfd-online.com/Forums/fluent-udf/78065-volume-flow-rate-error-udf.html)

 jjchristophe July 12, 2010 08:49

volume flow rate error in udf

In order to model a specific pressure outlet condition, I wrote a UDF that compute the outlet pressure with the following equation:
p_out=k*(4e6)*Q_out+2000 (1)
where p_out is the outlet pressure, Q_out the outlet volume flow rate and k a coefficient that i use to increase the resistance at the outlet.
In my real model I have 19 outlets, and 8 should use this condition (for the other k=1).
I tested my UDF on a cylinder of 1cm radius and 8cm length, for Re=1000 at the inlet (velocity inlet), with k=2 and 200.
among the different test, I output the outlet pressure and I compared it with the expected pressure from equ. (1).
I was really surprised of the difference: p_out=2009Pa instead of 2928Pa for k=2 and 5327Pa instead of 94800Pa for k=200.
Could you tell me if there is any problem in my udf, especially the way to obtain the outlet volume flow rate?
the code is as follow:

#include "udf.h"
{
real Q=0.;
real t=CURRENT_TIME;
real A[ND_ND];
face_t f;
float u,v,w,vi,vn;
float k=2.0;
{
{
vi=u*u+v*v+w*w;
vn=sqrt(vi);
Q=Q+NV_MAG(A)*vn;
u=0.;
v=0.;
w=0.;
vn=0.;
Q=0.;
}
}

Thank you for any help

 jjchristophe July 13, 2010 04:23

It seems there were some mistake in my UDF, so I re wrote it as follow:

#include "udf.h"
{
real Q=0.;
real t=CURRENT_TIME;
real A[ND_ND];
face_t f;
float u,v,w,vi,vn;
float k=2.0;
{
{
vi=u*u+v*v+w*w;
vn=sqrt(vi);
Q=Q+NV_MAG(A)*vn;
u=0.;
v=0.;
w=0.;
vn=0.;
}