CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   3D Turbulent Velocity at Inlet (https://www.cfd-online.com/Forums/fluent-udf/145961-3d-turbulent-velocity-inlet.html)

twolf59 December 16, 2014 02:08

3D Turbulent Velocity at Inlet
 
1 Attachment(s)
Hi all,

I am attempting to use the power law to model turbulent flow at the inlet of a horizontal pipe (3D). I dont know almost anything about programming in C, So here is the script I have managed to piece together from other random posts.

Can someone please help me find any potential bugs + improvements?

Currently I believe it only works for an inlet in the YZ plane (X normal). I would like it to both work for a Y normal and Z normal. Can someone help with this?

Additionally, I would like the program to define the diameter as half of the maximum value in the plane. Its a circular inlet centered on the respective axis. so that should work. I dont know how to the command for finding the max value.

Kokemoor December 16, 2014 10:49

Possible bugs:
z =x[1]; //should be x[2]?
F_PROFILE(...)=...-sqrt(pow(x,2)+pow(z,2))/... //should that be pow(y,2)+pow(z,2)?
Why is d in cm instead of m?

There are prettier methods to handle other directions, but the easiest would be simply to make three DEFINE_PROFILE UDFs, one for each direction.

I don't know if there's a quicker way, but the direct approach to finding the diameter would be to loop across all nodes in the inlet face and record the max value.

twolf59 December 16, 2014 12:56

Im not sure if it should be x[2]. Thats actually a question I had. Im not sure how the "face" commands in fluent generate data points. It should be pow(1-pow(pow(x,2)+pow(z,2),.5), thanks for that.
Youre right about d. It should be meters.

I realize I have to make three UDFS. I dont know what changes I should make is the issue.

What would be the command to loop through the nodes, and then find the max? Im unfamiliar with C. . . if this were Matlab I could do all of this no problem haha :)

Thanks

ghost82 December 17, 2014 08:01

x[ND_ND] is a vector, for 3d simulation is:
x[0]-->x coordinate
x[1]-->y coordinate
x[2]-->z coordinate

So declare:

real xcoord;
real ycoord;
real zcoord;

xcoord=x[0];
ycoord=x[1];
zcoord=x[2];

Then use xcoord, ycoord and zcoord in your functions (delete also real y and real z).


Move after face_t f, before the face loop this block:
Code:

real xcoord;
real ycoord;
real zcoord;

xcoord=x[0];
ycoord=x[1];
zcoord=x[2];

n = 7;
d = 10; /* cm */
Umean = 3.1; /* m/s */

Umax = Umean*(((n+1)*(2*n+1))/(2*pow(n,2)));

Always use SI units in udf.

I don't know if you can write this in c:

Code:

real a n;
real Umax Umean;

Write:

Code:

real a, n, Umax, Umean;
or

Code:

real a;
real n;
real Umax;
real Umean;


twolf59 December 17, 2014 12:41

Thank you!
 
Thank you so much!

Lots of help. One more question is that of looping through the nodes to find the maximum value. Would you happen to know how to do that?

Thanks


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