CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF problem???? (

Mech July 11, 2006 22:43

UDF problem????
Hi I have coded the following UDF to adjust mass flow rate at the outlet. I have fixed pressure inlet and want to get given outlet pressure by adjusting massflow rate. When I use this UDF then the simulation does not converge. I am using pressure inlet at inlet boundary and mass flow inlet at outlet boundary.Can anybody correct it or give me suggestion. Thank in advance. Mech

#include <udf.h> #include <math.h> #define H 1.2e-06 #define L 0.003 #define W 0.00004 #define rhoin 2.92 #define cp 1038.45 #define therm 0.0242 #define Pin 272260.8 #define Pout 100800.00 #define Patm 100800.00

DEFINE_ADJUST(my_adjust, d) { Thread *t; cell_t c; real x[ND_ND]; double y, fst1, lst1, PR, z;

thread_loop_c (t,d) {

begin_c_loop (c,t)







C_UDMI(c,t,1) = y;

C_UDMI(c,t,2) = (sqrt(gamma * R * temin));


end_c_loop (c,t) } }

DEFINE_PROFILE(mass_flow_inlet, t, i) {

real x3[ND_ND], x4[ND_ND]; real val, lamda, grad, Kn, du, dz, z1, z2, m3, dp, dx, p1; real pg1, m1;

face_t f;

cell_t c0;

Thread *t0;

m1=0.725; /*mass flux m1 assumed*/

pg1=5.70e+07; /*pressure gradient pg1*/

p1=100820.00 ; /*outlet pressure p1 */

begin_f_loop(f, t)


c0 = F_C0(f, t);

t0 = t -> t0;

dp=fabs(C_P(c0, t0)-F_P(f, t));






C_UDMI(c0,t0,4)= -(dp/dz); /* pressure gradient*/

C_UDMI(c0,t0,5)= C_R(c0,t0)*C_U(c0,t0)*H;

/* mass flow 2*rho*u*H */

if(F_P(f,t) != 100800.0)

{ m3=C_UDMI(c0,t0,5)-((Patm-F_P(f,t))/(p1-F_P(f,t)))*(C_UDMI(c0,t0,5)-m1);







F_PROFILE(f, t, i) = m3;

} end_f_loop(f, t) }



Thread *t; Domain *d;

real pg3, pg1, m1;

cell_t c; d=Get_Domain(1);

thread_loop_c (t,d)


begin_c_loop (c,t)


if((fabs(C_UDMI(c, t, 5)-C_UDMI(c,t,6))/H)> 1.5e-05)

{ C_P_G(c, t)[0]= -(C_UDMI(c, t, 4)- (C_UDMI(c, t, 5)/(C_UDMI(c, t, 5)-C_UDMI(c,t,6)))*(C_UDMI(c, t, 4)-C_UDMI(c, t, 7)));

C_UDMI(c, t, 7)= C_UDMI(c, t, 4); C_UDMI(c, t, 4)=C_P_G(c,t)[0];



end_c_loop (c,t)

} }

Vivek July 12, 2006 15:03

Re: UDF problem????
A simpler way to do without using udfs is set mass flow to a constat value and run the analysis for two such flow rates. Get the pressure drop across the system for each case. Plot a quadratic equation in excel for mass flow vs pressure drop(Use 0,0 as another point). calculate the requried mass flow from the equation. and set it as boundary condition. The back pressure will be pretty close to the value u want.

All times are GMT -4. The time now is 13:05.