CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF problem???? (https://www.cfd-online.com/Forums/fluent/41675-udf-problem.html)

 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

begin_c_loop (c,t)

{

C_CENTROID(x,c,t);

y=x[1];

y=sqrt(y*y);

z=x[0];

PR=Pin/Pout;

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;

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

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_CENTROID(x3,c0,t0);

z1=x3[0];

F_CENTROID(x4,f,t);

z2=x4[0];

dz=fabs(z1-z2);

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

m1=C_UDMI(c0,t0,5);

C_UDMI(c0,t0,5)=m3;

C_UDMI(c0,t0,6)=m1;

p1=F_P(f,t);

C_UDMI(c0,t0,7)=pg1;

}

F_PROFILE(f, t, i) = m3;

} end_f_loop(f, t) }

DEFINE_EXECUTE_AT_END(execute_at_end)

{

real pg3, pg1, m1;

cell_t c; d=Get_Domain(1);

{

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 03:38.