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

defining temperature profile with UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 2, 2010, 12:21
Default defining temperature profile with UDF
  #1
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
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.
Attached Images
File Type: bmp 123.bmp (32.6 KB, 208 views)
mohammadkm is offline   Reply With Quote

Old   August 3, 2010, 00:18
Default
  #2
New Member
 
Join Date: Jul 2010
Posts: 6
Rep Power: 16
oldfreshman is on a distinguished road
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);
"
oldfreshman is offline   Reply With Quote

Old   August 3, 2010, 03:28
Default
  #3
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
Thanks for your help.
I will try this. But what's the difference between them?
mohammadkm is offline   Reply With Quote

Old   August 3, 2010, 04:17
Default
  #4
New Member
 
Join Date: Jul 2010
Posts: 6
Rep Power: 16
oldfreshman is on a distinguished road
eg. 295, the type of variable is "int";
295., "real";
maybe this is ur problem.
oldfreshman is offline   Reply With Quote

Old   August 3, 2010, 04:24
Default
  #5
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
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);
mohammadkm is offline   Reply With Quote

Old   August 3, 2010, 06:29
Default
  #6
New Member
 
Join Date: Jul 2010
Posts: 6
Rep Power: 16
oldfreshman is on a distinguished road
4.331683168.
oh, i don't think it a right way to discribe a real value either.
oldfreshman is offline   Reply With Quote

Old   August 3, 2010, 12:58
Default
  #7
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
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
mohammadkm is offline   Reply With Quote

Old   June 24, 2013, 16:52
Default hi
  #8
New Member
 
UMICH
Join Date: Jun 2013
Posts: 1
Rep Power: 0
drek26 is on a distinguished road
How can I do the same problem but in 3d, thanks



Quote:
Originally Posted by oldfreshman View Post
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);
"
drek26 is offline   Reply With Quote

Old   July 2, 2013, 01:30
Default
  #9
New Member
 
hamid
Join Date: Jul 2013
Posts: 5
Rep Power: 13
Hamid-Moezzi is on a distinguished road
hi all,
i am trying to write a udf for a linear temperature distribution along the wall as a temperature boundary condition. the wall is subjected to an end of 325 K and an end of 300 K temperature and a linear distribution should be peresent for the wall. the wall position from the origin -0.06 to +0.06 . i found a udf here but it seems that does not work because after interpreting and when i want to initialize an access violation error occurs. please please help me. this is the first time that i work with ansys fluent.
thank you.
////////////////////
#include "udf.h"
DEFINE_INIT(linear_temp,d)
{
cell_t c;
Thread *t;
real xc[ND_ND];
real m;
real Tt=325., Tb=300.;
real xb=0.06,xt=-0.06;
real dT=(Tt-Tb)/(xt-xb);
/* loop over all cell threads in the domain */
thread_loop_c(t,d)
{
/* loop over all cells */
begin_c_loop_all(c,t)
{
C_CENTROID(xc,c,t);
m=xc[0];
C_T(c,t)=Tb+(m-xb)*dT;
}
end_c_loop_all(c,t)
}
}
////////////////////
Hamid-Moezzi is offline   Reply With Quote

Old   July 2, 2013, 08:26
Default
  #10
Member
 
Yash Ganatra
Join Date: Mar 2013
Posts: 67
Rep Power: 13
yashganatra is on a distinguished road
You can't use C_T(c,t) = something ; FLUENT automatically computes cell temperature ; so that's the reason I guess access violation is coming ; go through FLUENT UDF MANUAL especially the DEFINE_PROFILE macro.
yashganatra is offline   Reply With Quote

Old   July 3, 2013, 01:09
Default
  #11
New Member
 
hamid
Join Date: Jul 2013
Posts: 5
Rep Power: 13
Hamid-Moezzi is on a distinguished road
thanks yashganatra,
I have change my udf to the the following code. is it correct for a wall boudary condition???
best regards
////////////////////
#include "udf.h"
DEFINE_PROFILE(linear_temp,thread,i)
{
real x[ND_ND];
real m;
real Tt=325.,Tb=300.;
real xb=0.06,xt=-0.06;
real dT=(Tt-Tb)/(xt-xb);
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
m=x[0];
F_PROFILE(f,thread,i)=Tb+(m-xb)*dT;
}
end_f_loop(f,thread)
}
////////////////////
Hamid-Moezzi is offline   Reply With Quote

Old   July 3, 2013, 01:15
Default
  #12
Member
 
Yash Ganatra
Join Date: Mar 2013
Posts: 67
Rep Power: 13
yashganatra is on a distinguished road
Just try it out and get back.

Yash
yashganatra 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
UDF error - parabolic velocity profile - 3D turbine Zaqie Fluent UDF and Scheme Programming 9 June 25, 2016 20:08
specified shear at wall - temperature gradient - UDF - access violation error senD Fluent UDF and Scheme Programming 9 September 18, 2014 08:29
Define profile inlet_temperature in UDF mohammadkm Fluent UDF and Scheme Programming 19 December 24, 2013 23:42
UDF temp. profile BC Shashikant FLUENT 0 June 24, 2006 04:16
temperature profile on boundary sivakumar FLUENT 5 November 24, 2002 01:58


All times are GMT -4. The time now is 15:23.