# 3D Turbulent Velocity at Inlet

 Register Blogs Members List Search Today's Posts Mark Forums Read

December 16, 2014, 02:08
3D Turbulent Velocity at Inlet
#1
New Member

daniel
Join Date: Sep 2014
Posts: 17
Rep Power: 11
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.

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.
Attached Files
 PowerLaw.c (596 Bytes, 23 views)

 December 16, 2014, 10:49 #2 Senior Member   Andrew Kokemoor Join Date: Aug 2013 Posts: 122 Rep Power: 13 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.

 December 16, 2014, 12:56 #3 New Member   daniel Join Date: Sep 2014 Posts: 17 Rep Power: 11 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

 December 17, 2014, 08:01 #4 Senior Member     Rick Join Date: Oct 2010 Posts: 1,016 Rep Power: 26 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;``` __________________ Google is your friend and the same for the search button!

 December 17, 2014, 12:41 Thank you! #5 New Member   daniel Join Date: Sep 2014 Posts: 17 Rep Power: 11 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

 Tags inlet, pipe, power law, turbulent, udf