
[Sponsors] 
March 22, 2010, 11:31 
Emergency:UDF for a time dependent parabolic velocity

#1 
New Member
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 8 
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("flowtime"); n=(int)(t/T); F_PROFILE(f,thread,index)=1360.41*(0.0001y*y)*exp(0.5*pow(15.15*t3.4615.15*n,2)); velocity=F_PROFILE(f,thread,index); } end_f_loop(f,thread) } Last edited by zumaqiong; March 22, 2010 at 13:54. 

March 22, 2010, 14:10 

#2 
Senior Member
Join Date: Nov 2009
Posts: 411
Rep Power: 11 
Maybe because your velocity is negative ???4
F_PROFILE(f,thread,index)=1360.41*(0.0001y*y)*exp(0.5*pow(15.15*t3.4615.15*n,2)); This is a parabolic profile but from right to left, so the flow will exit .... Do 

March 22, 2010, 14:24 

#3  
New Member
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 8 
Quote:
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. 

March 23, 2010, 16:36 

#4 
Senior Member
Micael Boulet
Join Date: Mar 2009
Location: Quebec, Canada
Posts: 101
Rep Power: 10 
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 

March 23, 2010, 17:26 

#5  
New Member
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 8 
Quote:
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! 

March 23, 2010, 20:48 

#6 
Senior Member
Micael Boulet
Join Date: Mar 2009
Location: Quebec, Canada
Posts: 101
Rep Power: 10 
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. 

March 24, 2010, 14:00 

#7  
New Member
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 8 
Quote:
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! 

March 24, 2010, 14:43 

#8 
Senior Member
Micael Boulet
Join Date: Mar 2009
Location: Quebec, Canada
Posts: 101
Rep Power: 10 
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? 

March 24, 2010, 15:39 

#9  
New Member
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 8 
Quote:
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 ! 

March 24, 2010, 16:19 

#10 
Senior Member
Micael Boulet
Join Date: Mar 2009
Location: Quebec, Canada
Posts: 101
Rep Power: 10 
Yea, just make the UDF returns a positive number for velocity (change the velocity sign).


March 25, 2010, 11:20 

#11  
New Member
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 8 
Quote:
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! 

March 25, 2010, 12:38 

#12 
Senior Member
Micael Boulet
Join Date: Mar 2009
Location: Quebec, Canada
Posts: 101
Rep Power: 10 
Please, give a better description of the problem you want to solve. I still have no idea what you really want to do.


March 25, 2010, 13:00 

#13  
New Member
zumaqiong
Join Date: Jan 2010
Posts: 11
Rep Power: 8 
Quote:
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 defaultinterior 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! 

Tags 
parabolic, time dependent, velocity inlet 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Plotting a velocity versus time graph  wanie  FLUENT  1  March 10, 2012 06:23 
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 11:16 
Modeling in micron scale using icoFoam  m9819348  OpenFOAM Running, Solving & CFD  7  October 27, 2007 00:36 
Modification in a Time Dependent Velocity  Guillermo Solano  Phoenics  4  April 8, 2002 03:34 