Emergency:UDF for a time dependent parabolic velocity
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) } 
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 
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. 
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 
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! 
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. 
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! 
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? 
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 ! 
Yea, just make the UDF returns a positive number for velocity (change the velocity sign).

4 Attachment(s)
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! 
Please, give a better description of the problem you want to solve. I still have no idea what you really want to do.

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! 
All times are GMT 4. The time now is 18:30. 