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

Emergency:UDF for a time dependent parabolic velocity

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 22, 2010, 11:31
Question Emergency:UDF for a time dependent parabolic velocity
  #1
New Member
 
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 16
zumaqiong is on a distinguished road
I meet some problems when using ANSYS UDF.
Now I want to write a UDF file for a time dependent parabolic velocity, and prescribe this velocity at inlet boundary as the boundary conditions.
But now I have a big problem that as I prescribe my velocity as parabolic, why there will be much inverse flow so that the velocity magnitude becomes negative? And as I define Y velocity as parabolic and X velocity is zero, why there will be X velocity that is not zero?
And another question is that I see the results of vector in Tecplot, there are two velocities at the inlet boundary,one is correct, but the other is not correct. Why????
Here, I attached my UDF file.
Maybe you can find the problem and help me!

Thank you very much!

#include"udf.h"
DEFINE_PROFILE(flow_at_inlet,thread,index)
{
real x[ND_ND],velocity;
/* velocity is defined, but not used in the main function??.*/
real y;
face_t f;
real t;
int n;
real T=1;

begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y=x[0];
t=RP_Get_Real("flow-time");
n=(int)(t/T);
F_PROFILE(f,thread,index)=-1360.41*(0.0001-y*y)*exp(-0.5*pow(15.15*t-3.46-15.15*n,2));
velocity=F_PROFILE(f,thread,index);
}
end_f_loop(f,thread)
}

Last edited by zumaqiong; March 22, 2010 at 13:54.
zumaqiong is offline   Reply With Quote

Old   March 22, 2010, 14:10
Default
  #2
Senior Member
 
Join Date: Nov 2009
Posts: 411
Rep Power: 19
DoHander is on a distinguished road
Maybe because your velocity is negative ???4

F_PROFILE(f,thread,index)=-1360.41*(0.0001-y*y)*exp(-0.5*pow(15.15*t-3.46-15.15*n,2));

This is a parabolic profile but from right to left, so the flow will exit ....

Do
DoHander is offline   Reply With Quote

Old   March 22, 2010, 14:24
Default
  #3
New Member
 
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 16
zumaqiong is on a distinguished road
Quote:
Originally Posted by DoHander View Post
Maybe because your velocity is negative ???4

F_PROFILE(f,thread,index)=-1360.41*(0.0001-y*y)*exp(-0.5*pow(15.15*t-3.46-15.15*n,2));

This is a parabolic profile but from right to left, so the flow will exit ....

Do
Hi!
The velocity is negative, but after running some time, the velocity is inverse.
but as i prescribe the velocity, at the boundary, the velocity should be always in one direction.
zumaqiong is offline   Reply With Quote

Old   March 23, 2010, 16:36
Default
  #4
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 157
Rep Power: 18
Micael is on a distinguished road
This is not clear to me. Why there is that comment?
/* velocity is defined, but not used in the main function??.*/

Did you find that UDF somewhere and try to modify it for your need?

Take the time to analyse and understand each line of the code, you will find the problem(s).

Have a nice day.

Micaël
Micael is offline   Reply With Quote

Old   March 23, 2010, 17:26
Default
  #5
New Member
 
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 16
zumaqiong is on a distinguished road
Quote:
Originally Posted by Micael View Post
This is not clear to me. Why there is that comment?
/* velocity is defined, but not used in the main function??.*/

Did you find that UDF somewhere and try to modify it for your need?

Take the time to analyse and understand each line of the code, you will find the problem(s).

Have a nice day.

Micaël
Hi! Thank you for your reply.
This code is done by myself. At first, I didnt used velocity, So i wrote this comment to let me know VELOCITY was not used. but then, I gave F_PROFILE value to velocity, so it is used. Well, u can ignore this comment.
Sorry for bringing this confusion.
I tried to decrease the residual, and the reverse flow becomes smaller.
but im not sure if the problem is about residual. I just want to be sure that this velocity inlet udf is right. because at the boundary, as we prescribe the velocity profile, it could not be some other profile. so this velocity is negative, it should not be positive when it runs for some time because the maximum of it is ZERO.
So I just wonder if there is some problem with this udf. If not, why the velocity at the boundary can change direction and profile?
Thank you!
Expecting for your reply!
zumaqiong is offline   Reply With Quote

Old   March 23, 2010, 20:48
Default
  #6
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 157
Rep Power: 18
Micael is on a distinguished road
What is the range of x and y at this inlet?

Usually, we denote
x=x[0];
y=x[1];
z=x[2]; / for 3D case

Are you sure you do what you want when writing y=x[0]; ?

Where do you hook the function?

What are you trying to do with n=(int)(t/T); ?
"int" is not declared and anyway you cannot use this keyword for a variable. What those parentheses are suppose to do? It looks like an opperation is missing.

Are you really trying to define an inlet velocity as negative?

"velocity" is not used at all. The function return F_PROFILE to each face on the boundary. The next line really do nothing.
Micael is offline   Reply With Quote

Old   March 24, 2010, 14:00
Default
  #7
New Member
 
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 16
zumaqiong is on a distinguished road
Quote:
Originally Posted by Micael View Post
What is the range of x and y at this inlet?

Usually, we denote
x=x[0];
y=x[1];
z=x[2]; / for 3D case

Are you sure you do what you want when writing y=x[0]; ?

Where do you hook the function?

What are you trying to do with n=(int)(t/T); ?
"int" is not declared and anyway you cannot use this keyword for a variable. What those parentheses are suppose to do? It looks like an opperation is missing.

Are you really trying to define an inlet velocity as negative?

"velocity" is not used at all. The function return F_PROFILE to each face on the boundary. The next line really do nothing.
Hi!Thank you for your reply!
Well,if I use y=x[0] and it still stands for x position, then i will not want to change it.
"int" here means to find integer of t/T, because i need this integer to make the velocity function be a periodic velocity.
because the flow is coming from upside , and the y coordinate is upside positive, so i have to define it as negative.
but it seems that the interior flow at inlet boundary is coming outside. the inlet velocity is ok now. i cannot figure out why the flow interior can go outside from inlet boundary?

Thank you!
zumaqiong is offline   Reply With Quote

Old   March 24, 2010, 14:43
Default
  #8
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 157
Rep Power: 18
Micael is on a distinguished road
Ok, I understand n=(int)(t/T); now. I just learn something.

How do you hook the UDF?

Try with the velocity as positive. For an inlet velocity boundary, I think the orientation of the flow is positive toward the interior. If you want the flow to go toward the interior, you have to give a positive number to the solver, no matter what the axis are. I am not 100% sure of this, though. Can you try and give a feed back?
Micael is offline   Reply With Quote

Old   March 24, 2010, 15:39
Default
  #9
New Member
 
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 16
zumaqiong is on a distinguished road
Quote:
Originally Posted by Micael View Post
Ok, I understand n=(int)(t/T); now. I just learn something.

How do you hook the UDF?

Try with the velocity as positive. For an inlet velocity boundary, I think the orientation of the flow is positive toward the interior. If you want the flow to go toward the interior, you have to give a positive number to the solver, no matter what the axis are. I am not 100% sure of this, though. Can you try and give a feed back?
Hi!
Thank you very much!
I interpret my udf to fluent.
can u make it more clear that how to give a positive number to the solver? Just change the velocity sign as positive?
Thank you !
zumaqiong is offline   Reply With Quote

Old   March 24, 2010, 16:19
Default
  #10
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 157
Rep Power: 18
Micael is on a distinguished road
Yea, just make the UDF returns a positive number for velocity (change the velocity sign).
Micael is offline   Reply With Quote

Old   March 25, 2010, 11:20
Default
  #11
New Member
 
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 16
zumaqiong is on a distinguished road
Quote:
Originally Posted by Micael View Post
Yea, just make the UDF returns a positive number for velocity (change the velocity sign).
Hi!
I have changed it but it doesnt work.
And i have found a problem that in the inlet boundary,there are 2 velocities, one is correct, it is the inlet velocity. and the other is the velocity of "default interior"(in Fluent, it is called).and it is the default interior in the boundary that is incorrect. and i attach some figures to show it. do u know why there are 2 velocities in the boundary and how to let default interior not be in the boundary?

Thank you!
Attached Images
File Type: jpg yveloinlet.jpg (42.5 KB, 82 views)
File Type: jpg xveloinlet.jpg (39.3 KB, 50 views)
File Type: jpg contrast.jpg (47.2 KB, 62 views)
File Type: jpg inletvector.jpg (50.8 KB, 51 views)
zumaqiong is offline   Reply With Quote

Old   March 25, 2010, 12:38
Default
  #12
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 157
Rep Power: 18
Micael is on a distinguished road
Please, give a better description of the problem you want to solve. I still have no idea what you really want to do.
Micael is offline   Reply With Quote

Old   March 25, 2010, 13:00
Default
  #13
New Member
 
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 16
zumaqiong is on a distinguished road
Quote:
Originally Posted by Micael View Post
Please, give a better description of the problem you want to solve. I still have no idea what you really want to do.
Sorry to make u confused.
Well, i sent some figures and u can see in one figure with the name "inletvector",there are some little blue arrows upwards, it means that the velocity in the inlet boundary is positive.
but from the figure named "yveloinlet" and "xveloinlet", it is clear that the maximum of y velocity in the inlet boundary is 0, and x velocity is always 0.
and from the figure named "contrast", u can see that compared with the y velocity in the inlet boundary(red line), the white one standing for y velocity of default-interior is bigger than 0 when at x=0.01,while the red one is 0 at x=0.01.
So, there are 2 different velocities in the inlet boundary, one is the inlet boundary defined by udf, and the other is velocity of default interior.
it is strange and i dont know what the problem is.
Can u understand now?
and do u know why it happens?
Thank you!
zumaqiong is offline   Reply With Quote

Reply

Tags
parabolic, time dependent, velocity inlet


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
Plotting a velocity versus time graph wanie FLUENT 4 February 3, 2017 01:11
time dependent source using DEFINE_SOURCE T81 Fluent UDF and Scheme Programming 5 February 28, 2011 18:23
Differences between serial and parallel runs carsten OpenFOAM Bugs 11 September 12, 2008 12:16
Modeling in micron scale using icoFoam m9819348 OpenFOAM Running, Solving & CFD 7 October 27, 2007 01:36
Modification in a Time Dependent Velocity Guillermo Solano Phoenics 4 April 8, 2002 04:34


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