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

Creating a 3D parabolic velocity profile in a rectangular pipe..

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2021, 13:00
Default Creating a 3D parabolic velocity profile in a rectangular pipe..
  #1
New Member
 
Join Date: Oct 2021
Posts: 15
Rep Power: 4
James_mCFD is on a distinguished road
I'm wondering if anyone can help me. I'm currently writing a UDF to impose a parabolic velocity profile for fluid flow through a rectangular pipe. I have created a parabolic function for the z-direction (vertical plane) and the y-direction (normal to the direction of fluid flow).

I've used the UDF tutorial as a starting point, and have seen one other similar question, but my problem is different in that the width of the pipe is greater than the height of the pipe.

I have defined height as h and width as w, and maximum velocity as u_max.

Velocity profile in the y-direction is defined as:

u_y = -0.01.*(x[1]*x[1]-w*x[1]+0.25*w*w)+u_max

Velocity profile in the z-direction is defined as:

u_z = -0.062.*(x[2]*x[2]-h*x[2]+0.25*h*h)+u_max

I got to the stage where I had to write the F_PROFILE and realised I was mistaken in my technique as I was defining y as u_y and z as u_z. Please see the code below:

#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position)
{

real x[ND_ND]; /* this holds a position vector */
real y, w;
real z, h;
real u, u_max;
face_t f;

h = 2; /* inlet height in mm */
w = 5; /* inlet width in mm */
u_max = 0.062; /* maximum velocity at centre of the pipe in m/s*/

begin_f_loop(f, thread)
{
F_CENTROID(x, f, thread);
y = x[1];
z = x[2];
F_PROFILE(f, thread, position) = ...
}
end_f_loop(f, thread)
}

What I think is required is that I need to create a vector using the F_PROFILE that uses a vector [w,h], and [x[1],x[2]], as well as [0.01, 0.062] and u_max.

My issues are:

1. I'm not sure how to implement this in C and also check the velocity profile quickly using ansys FLUENT.

2. The coefficients in the expressions for the velocity profiles in the two directions are rounded to two decimal places and do not give exactly 0 at the walls; can I use a rounding function within the code that is compatible with the ANSYS compiler and solver?
James_mCFD is offline   Reply With Quote

Old   October 27, 2021, 00:10
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
to define profile in several directions you need several define-profile macros
Code:
DEFINE_PROFILE(inlet_x_velocity)
DEFINE_PROFILE(inlet_y_velocity)
u_y = -0.01.*(x[1]*x[1]-w*x[1]+0.25*w*w)+u_max
DEFINE_PROFILE(inlet_z_velocity)
u_z = -0.062.*(x[2]*x[2]-h*x[2]+0.25*h*h)+u_max
James_mCFD likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   October 27, 2021, 04:53
Default
  #3
New Member
 
Join Date: Oct 2021
Posts: 15
Rep Power: 4
James_mCFD is on a distinguished road
Hi Alexander. Thank you for your suggestions.

Is it necessary to create a profile for each component of the velocity? I have found a similar problem here that used a circular pipe, and for their solution it was suggested that only one DEFINE_PROFILE is necessary.

In case my original question was unclear; what I am after is the velocity in the x-direction, but this velocity changes with dy and dz as described by the functions I derived for my geometry. Velocity in the x-direction should be a component of the velocity in the y and z directions. What makes my problem (seemingly) more complicated is that y>z, so d_u/d_y ≠ d_u/d_z.

Thank you
James_mCFD is offline   Reply With Quote

Old   October 27, 2021, 14:17
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by James_mCFD View Post

In case my original question was unclear; what I am after is the velocity in the x-direction, but this velocity changes with dy and dz as described by the functions I derived for my geometry. Velocity in the x-direction should be a component of the velocity in the y and z directions. What makes my problem (seemingly) more complicated is that y>z, so d_u/d_y ≠ d_u/d_z.

Thank you
You are wrong about that: your velocity in x-direction is not what you have in these two equations. These two equations are for 1D inlets, your inlet is 2D. You need to make an equation for a 2D inlet.

That y>z is really not relevant, if y=z then your approach would also not work. You need to find out how to make a "parabolic" profile on a rectangle.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   October 29, 2021, 10:40
Default
  #5
New Member
 
Join Date: Oct 2021
Posts: 15
Rep Power: 4
James_mCFD is on a distinguished road
Quote:
Originally Posted by pakk View Post
your velocity in x-direction is not what you have in these two equations. These two equations are for 1D inlets, your inlet is 2D. You need to make an equation for a 2D inlet.
I think you misunderstood what I wrote; I know these do not represent velocity in the x-direction; I never said that they did! These are velocity profiles in the y and z-plane. If these functions are plotted with a surface plot using Matlab, it would produce a parabola that represents the velocity front at a single point in time.
James_mCFD is offline   Reply With Quote

Old   October 29, 2021, 13:52
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Your terminology is not standard, that makes it difficult...

You talk about "Velocity profile in the y-direction", where you mean "velocity profile in the x-direction at z=0". Agreed?

"I know these do not represent velocity in the x-direction; I never said that they did!"
Well, you should have said so, because they are in the x-direction and they are velocity profiles. It's just that they are 1d, where you need 2d. You have to make an equation that combines the 1d profiles into a 2d. You, not Fluent.

"If these functions are plotted with a surface plot using Matlab, it would produce a parabola..."
The functions are 1d, a surface plot is 2d,and a parabola is 1d. I don't understand how you see this. Maybe you can show the surface plot that you talk about?

"... that represents the velocity front at a single point in time. "
In time? Is your profile transient? Everything until now suggested a steady-state situation... Do you really mean it like that? If so, you also need to tell us how your profile should change over time.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk 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
Error with UDF in Fluent - UDF for parabolic developed velocity profile. Arun_Prasath_M Main CFD Forum 1 October 20, 2022 20:46
Velocity profile in pipe is not parabolic, chtMultiRegionFoam JeffFoam OpenFOAM Running, Solving & CFD 1 February 22, 2021 15:02
Transient parabolic 3D velocity profile mattialupo Fluent UDF and Scheme Programming 1 October 15, 2019 07:35
Plot velocity profile along longitudinal axis of pipe jorgelmilan EnSight 8 July 7, 2018 14:30
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


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