CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF modification (http://www.cfd-online.com/Forums/fluent/28235-udf-modification.html)

merac February 21, 2001 04:26

UDF modification
 
Hi folks, I'm relatively new to CFD & Fluent and am trying to simulate (in 3D) the flow of water through a pipe. I've spotted a boundary condition UDF on the Fluent documentation site ('parabolic velocity inlet profile in a turbine vane')which I think will help my simulation. The problem is that this UDF is for a 2D problem. My question is (given my very basic knowledge of C) how can I modify the UDF to work in 3D? I've tried to edit here and there, but the results are incorrect. Is it just a case of adding a z component to the UDF? and if so, how? Please help!

Here's the UDF: /************************************************** ***********************/ /* vprofile.c */ /* UDF for specifying a steady-state velocity profile boundary condition */ /************************************************** ***********************/

#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position) { real x[ND_ND]; /* this will hold the position vector */

real y; face_t f;

begin_f_loop(f, thread)

{

F_CENTROID(x,f,thread);

y = x[1];

F_PROFILE(f, thread, position) = 20. - y*y/(.0745*.0745)*20.;

} end_f_loop(f, thread) }

Ashutosh February 21, 2001 06:24

Re: UDF modification
 
Try like shown below: It should work.

#include "udf.h" DEFINE_PROFILE(inlet_x_velocity, thread, position) { real x[ND_ND]; /* this will hold the position vector */

face_t f; cell_t c; real x[ND_ND]; real y,xref,yref,zref;

xref=0.0; yref=0.0; zref=0.0; begin_f_loop (f,thread) {

F_CENTROID(x,f,thread);

y = sqrt((x[0]-xref)*(x[0]-xref)+(x[2]-zref)*(x[2]-zref));

F_PROFILE(f,thread,nv)= 20. - y*y/ (.0745*.0745) *20.;

} end_f_loop(f, thread)

}

cfd February 27, 2001 13:21

Re: UDF modification
 
it can't work

merac February 28, 2001 07:10

Re: UDF modification
 
Sorry, but it didn't work. I switched around the x,y,z terms as my flow is in the -ve z direction and it gives a wild overestimation of the inlet velocity at initialisation. It wouldn't compile at first, and when I sorted that out, it didn't seem to work anyway. When I tried using the unmodified 2D UDF supplied by Fluent, the inflow was like a slot within the pipe, so it it not just a case of adding the z direction (x[0] x[1] x[2]) to this UDF?

Ashutosh March 1, 2001 06:42

Re: UDF modification
 
This works. You should have y-axis along the length of cylinder.The center of cylinder should pass though the center point. Create a plane slicing at x=0, and see the x-y plot of y-velocity on this sliced plane. You will see the parabola. Your cylinder radius should be 0.0745 to get the parabolic profile. You will see 20m/s at the center and zero at the walls. Try for more cells in radial direction. Enjoy!!!

#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position) {

real x[ND_ND]; /* this will hold the position vector */

face_t f; cell_t c; real y,xref,yref,zref;

xref=0.0; yref=0.0; zref=0.0;

begin_f_loop (f,thread) {

F_CENTROID(x,f,thread);

y = sqrt((x[0]-xref)*(x[0]-xref)+(x[2]-zref)*(x[2]-zref));

F_PROFILE(f,thread,position)= 20. - y*y/ (.0745*.0745) *20.;

} end_f_loop(f, thread)

}


All times are GMT -4. The time now is 11:41.