CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   defining temperature profile with UDF (http://www.cfd-online.com/Forums/fluent-udf/78786-defining-temperature-profile-udf.html)

mohammadkm August 2, 2010 11:21

defining temperature profile with UDF
 
1 Attachment(s)
Dear all
I tried to define the temperature profile which is attached, with UDF.
Here is the UDF:
DEFINE_PROFILE(x_temperature,thread,index)
{
Domain *domain=Get_Domain(1);
real x[ND_ND]; /* this will hold the position vector */
real y,b;
face_t f;
begin_f_loop(f,thread) /* loops over all faces in the thread passed in the DEFINE macro argument */
{
F_CENTROID(x,f,thread);
y = x[1];
b=x[0];
F_PROFILE(f,thread,index) =295+(11734506.78*(pow((y/2),2)-(pow(y,4)/(8.1*0.00001))))-4.331683168+(15.8038854*b);
}
end_f_loop(f,thread)
}
////////////////////////////////////
I hook the UDF in the boundary condition and i can get the results without any problem. However the results are wrong.
Have i written the UDF correctly?
Please help me, i really stuck on this problem.

oldfreshman August 2, 2010 23:18

how about change"F_PROFILE(f,thread,index) =295+(11734506.78*(pow((y/2),2)-(pow(y,4)/(8.1*0.00001))))-4.331683168+(15.8038854*b);
"
to this
"F_PROFILE(f,thread,index) =295.+(11734506.78*(pow((y/2.),2.)-(pow(y,4.)/(8.1*0.00001))))-4.331683168+(15.8038854*b);
"

mohammadkm August 3, 2010 02:28

Thanks for your help.
I will try this. But what's the difference between them?

oldfreshman August 3, 2010 03:17

eg. 295, the type of variable is "int";
295., "real";
maybe this is ur problem.

mohammadkm August 3, 2010 03:24

Thanks for your reply.
why shouldn't i put "." after 4.331683168.
For example
F_PROFILE(f,thread,index) =295.+(11734506.78*(pow((y/2.),2.)-(pow(y,4.)/(8.1*0.00001))))-4.331683168.+(15.8038854*b);

oldfreshman August 3, 2010 05:29

4.331683168.
oh, i don't think it a right way to discribe a real value either.

mohammadkm August 3, 2010 11:58

Thanks again for your reply.
I checked that code too, but unfortunately the results were still the same and there was no difference between them.
I have a question about velocity profile.
Should i make this change in velocity profile too?
I defined velocity profile too.
UDF is:
# include "udf.h"
# include "math.h"
DEFINE_PROFILE(x_velocity,thread,index)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;
begin_f_loop(f,thread) /* loops over all faces in the thread passed in the DEFINE macro argument */
{
F_CENTROID(x,f,thread);
y = x[1];
F_PROFILE(f,thread,index) =2* 0.05391789*(1-((y/0.00225)*(y/0.00225))) ;
}
end_f_loop(f,thread)
}
DEFINE_PROFILE(x_temperature,thread,index)
{
Domain *domain=Get_Domain(1);
real x[ND_ND]; /* this will hold the position vector */
real y,b;
face_t f;
begin_f_loop(f,thread) /* loops over all faces in the thread passed in the DEFINE macro argument */
{
F_CENTROID(x,f,thread);
y = x[1];
b=x[0];
F_PROFILE(f,thread,index) =295+(11734506.78*(pow((y/2),2)-(pow(y,4)/(8.1*0.00001))))-4.331683168+(15.8038854*b);
}
end_f_loop(f,thread)
}

Thanks again


All times are GMT -4. The time now is 21:33.