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

3D Turbulent Velocity at Inlet

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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 16, 2014, 03:08
Red face 3D Turbulent Velocity at Inlet
  #1
New Member
 
daniel
Join Date: Sep 2014
Posts: 16
Rep Power: 4
twolf59 is on a distinguished road
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.
Attached Files
File Type: c PowerLaw.c (596 Bytes, 13 views)
twolf59 is offline   Reply With Quote

Old   December 16, 2014, 11:49
Default
  #2
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 121
Rep Power: 6
Kokemoor is on a distinguished road
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.
Kokemoor is offline   Reply With Quote

Old   December 16, 2014, 13:56
Default
  #3
New Member
 
daniel
Join Date: Sep 2014
Posts: 16
Rep Power: 4
twolf59 is on a distinguished road
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
twolf59 is offline   Reply With Quote

Old   December 17, 2014, 09:01
Default
  #4
Senior Member
 
ghost82's Avatar
 
Daniele
Join Date: Oct 2010
Location: Italy
Posts: 992
Rep Power: 16
ghost82 will become famous soon enough
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!
ghost82 is offline   Reply With Quote

Old   December 17, 2014, 13:41
Default Thank you!
  #5
New Member
 
daniel
Join Date: Sep 2014
Posts: 16
Rep Power: 4
twolf59 is on a distinguished road
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
twolf59 is offline   Reply With Quote

Reply

Tags
inlet, pipe, power law, turbulent, udf

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Density for Velocity Inlet Face arkie87 FLUENT 0 November 7, 2012 16:15
Steady pipe flow mean velocity higher than inlet velocity anita OpenFOAM Running, Solving & CFD 7 September 25, 2012 05:35
FSI- Pipe- uniform velocity profile inlet Absy Main CFD Forum 0 April 6, 2010 03:01
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 02:15
UDF paraboloid velocity inlet Ronak Shah FLUENT 0 June 4, 2003 09:44


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