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

Consulting for some issues of FLUENT UDF and UDS

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2012, 04:48
Default Consulting for some issues of FLUENT UDF and UDS
  #1
New Member
 
Nick Wu
Join Date: Apr 2012
Location: Shanghai China
Posts: 1
Rep Power: 0
wjl163 is on a distinguished road
Hello everyone!
I am a new learner of FLUENT, my FLUENT version is 6.3.26. I am working on a numerical simulation project studying PM2.5 particle trajectory in a wire-plate electrostatic precipitator, I have created a UDF to do the simulation, here is the UDF:
#include "udf.h"
#include "dpm.h"
#include "surf.h"
#include "metric.h"
#include "math.h"
#define Pia 3.14
#define epsilon_0 8.85e-12
#define epsilon_r 4.0
#define K0 1.38e-23
#define e 1.6e-19
#define N 1.0e+15
#define number 1
#define mi 4.82E-26
#define B 0.0
enum
{
v,
rho,
N_REQUIRED_UDS
};
DEFINE_SOURCE(v_source,c,t,dS,eqn)
{
real source;
source = 0;
dS[eqn] = 0;
return source;
}
DEFINE_SOURCE(rho_source,c,t,dS,eqn)
{
real *grad_v, div_v, con, source;
grad_v = C_UDSI_G(c,t,v);
div_v = NV_DOT(grad_v, grad_v);

con=div_v+C_UDSI(c,t,rho)/epsilon_0;
source = con * C_UDSI(c,t,rho);
dS[eqn] =div_v+2*C_UDSI(c,t,rho)/epsilon_0;
return source;
}

DEFINE_UDS_FLUX(rho_flux,f,t,i)
{
cell_t c0, c1 = -1;
Thread *t0, *t1 = NULL;
real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0; /* declaring vectors psi and A */
real *grad_v, *grad_v1;
real dens;
c0 = F_C0(f,t);
t0 = F_C0_THREAD(f,t);
F_AREA(A, f, t);
/* If face lies at domain boundary, use face values; */
/* If face lies IN the domain, use average of adjacent cells. */
if (BOUNDARY_FACE_THREAD_P(t)) /*Most face values will be available*/
{

/* Depending on its BC, density may not be set on face thread*/
if (NNULLP(THREAD_STORAGE(t,SV_DENSITY)))
dens = F_R(f,t); /* Set dens to face value if available */
else
dens = C_R(c0,t0); /* else, set dens to cell value */

NV_DS(psi_vec, =, C_UDSI_G(c0,t0,v)[0], C_UDSI_G(c0,t0,v)[1], 0, *, dens);
flux = NV_DOT(psi_vec, A); /* flux through Face */
}
else
{
c1 = F_C1(f,t); /* Get cell on other side of face */
t1 = F_C1_THREAD(f,t);
grad_v = C_UDSI_G(c0,t0,v);
grad_v1 = C_UDSI_G(c1,t1,v);
NV_DS(psi_vec, =, grad_v[0],grad_v[1],0,*,C_R(c0,t0));
NV_DS(psi_vec, +=, grad_v1[0],grad_v1[1],0,*,C_R(c1,t1));
flux = NV_DOT(psi_vec, A)/2.0; /* Average flux through face */
}
/* Fluent will multiply the returned value by phi_f (the scalar's
value at the face) to get the "complete'' advective term. */
return F_FLUX(f,t) / dens;
}

DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
real bforce=0.,Qk,Qd,Q;
real x[ND_ND];
cell_t c=RP_CELL(&(p->cCell));
Thread *t=RP_THREAD(&(p->cCell));
C_CENTROID(x,c,t);
if(i==1)
Qd=3*Pia*epsilon_0*(epsilon_r/(epsilon_r+2))*pow(P_DIAM(p),2.0)*C_UDSI_G(c,t,0)[1];
Qk=2*Pia*epsilon_0*K0*P_T(p)*P_DIAM(p)/e*log(1+pow(e,2.)*N*P_DIAM(p)*P_TIME(p)*number/(2*epsilon_0*sqrt(16*mi*K0*P_T(p)/3)));
Q=fabs(Qd)+fabs(Qk);
bforce=Q*C_UDSI_G(c,t,0)[1]+Q*B*P_VEL(p)[0];
return (bforce/P_MASS(p));
}

DEFINE_DPM_DRAG(particle_drag_force, Re, p)
{
float w, drag_force;
printf ("Re is %6.3f\n", Re);
/* Note: when you print a "real" data, use "%g" instead of "%f" */
if (Re < 0.01)
{
drag_force=18.0;
return (drag_force);
}
else if (Re < 20.0)
{
w = log10(Re);
drag_force = 18.0 + 2.367*pow(Re,0.82-0.05*w) ;
return (drag_force);
}
else
/* Note: suggested valid range 20 < Re < 260 */
{
drag_force = 18.0 + 3.483*pow(Re,0.6305) ;
return (drag_force);
}
}
After the UDF programming, I have copied a schematic procedure to help me complete the simulation, attached below.
I don't know how to realize this process, and how to set the UDS scalar in this case, please tell me how to do? Thank you.
Attached Images
File Type: jpg Fig.4.jpg (49.1 KB, 73 views)
wjl163 is offline   Reply With Quote

Old   November 3, 2012, 07:09
Default
  #2
New Member
 
IVI
Join Date: Oct 2012
Posts: 14
Rep Power: 13
89566008 is on a distinguished road
hi Nick Wu
I also studying on ESP and need help . Do you solve your problem ? can you help me ?
thank you
89566008 is offline   Reply With Quote

Old   November 12, 2012, 03:24
Default
  #3
Senior Member
 
SSL
Join Date: Oct 2012
Posts: 226
Rep Power: 14
msaeedsadeghi is on a distinguished road
There is no need of creating procedure. Fluent solves equations one by one, and then it solves UDS(s).
You should just hook functions in right places. Fluent will use them when needed. and in an iterative solution it will be converged.
msaeedsadeghi is offline   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
Two questions on Fluent UDF Steven Fluent UDF and Scheme Programming 7 March 23, 2018 03:22
connection between udf and uds a.maroofi Fluent UDF and Scheme Programming 1 September 19, 2010 08:46
Fluent 6.3 pemfc module, UDS diffusivity yerem3 FLUENT 0 January 19, 2010 03:10
Fluent udf--assigning u-velocity to uds tas38 FLUENT 1 August 11, 2009 10:41
Associating profile files for the UDS though a UDF Bharath FLUENT 0 December 1, 2006 15:58


All times are GMT -4. The time now is 07:52.