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

UDF problem????

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 11, 2006, 22:43
Default UDF problem????
  #1
Mech
Guest
 
Posts: n/a
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_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;

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

z1=x3[0];

F_CENTROID(x4,f,t);

z2=x4[0];

dz=fabs(z1-z2);

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

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)

{

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)

} }

  Reply With Quote

Old   July 12, 2006, 15:03
Default Re: UDF problem????
  #2
Vivek
Guest
 
Posts: n/a
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.
  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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 06:05
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 06:56
UDF problem mansha goraya FLUENT 0 October 29, 2007 00:31
udf compiling problem akr FLUENT 3 August 22, 2007 07:14
UDF problem chiseung FLUENT 4 January 10, 2002 09:58


All times are GMT -4. The time now is 12:01.