# Define profile inlet_temperature in UDF

 Register Blogs Members List Search Today's Posts Mark Forums Read

April 26, 2010, 08:27
#3
Senior Member

Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 12
Quote:
What you're doing is tricky. You're looping over one boundary and use the index to address another boundary. Are you sure they have the same number of faces? Otherwise it can easily happen that F_T(f,t0) is out of bounds.

 April 26, 2010, 08:30 #4 Senior Member     Dragos Join Date: Mar 2009 Posts: 648 Rep Power: 12 Print the values of y and you will see what temperatures you should produce: Code: ```DEFINE_PROFILE(x_temperature,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]; Message0("y= %e\n",y); F_PROFILE(f,thread,index) =383+(4.603027808*0.000001*(1-(pow((y/0.00225),4)))); } end_f_loop(f,thread) }```

 April 27, 2010, 02:37 #6 Senior Member     Dragos Join Date: Mar 2009 Posts: 648 Rep Power: 12 As I said in the above post Define profile inlet_temperature in UDF, print the values using a "Message" statement. This time, you update the face using an older value plus something related to the position of the face centroid. F_PROFILE(f,thread,index) points to the same variable as F_T(f,thread). Is this what you want? Most likely, the initial value of the temperature on the surface pointed by F_T(f,thread) is not defined (probably 0), and substracting from that another number will give you a negative number, which should represent a temperature, hence the error.

 May 2, 2010, 16:58 #7 Member   mohammad Join Date: Apr 2010 Posts: 42 Rep Power: 8 Thanks for your help dmoroian As you said i added Message0("y= %e\n",y); to my code and in console message, i got this: y= 1.910808e-003 y= 1.928399e-003 y= 1.945314e-003 y= 1.961578e-003 .... I don't know whats the problem with my code. wall temperature is constant and equal 383K.

 May 3, 2010, 04:52 #9 Senior Member     Dragos Join Date: Mar 2009 Posts: 648 Rep Power: 12 Where do you hook your x_temperature? After I red your posts, I got the impression that you are trying to setup the temperature in the entire domain. I don't think you can do that with a DEFINE_PROFILE macro! Dragos

 May 3, 2010, 16:19 #10 Member   mohammad Join Date: Apr 2010 Posts: 42 Rep Power: 8 Dear dmoroian I hook my x_temperature in Boundary condition>inlet(velocity inlet)>Thermal change constant value to libudf:x_temperature. If i cant do it with define_profile macro, so how can i do it? I just want to define develop flow in tube and not to have transient. thanks

May 4, 2010, 01:57
#11
Senior Member

Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 12
If you hook your function as a boundary condition, then it's ok.

Quote:
 Originally Posted by mohammadkm This time i tried to define profile y = x[1]; ... b=x[0]; a=295+(15.8038854*b); F_PROFILE(f,thread,index) =a-(14.85148515*(0.75-((y/0.00225)*(y/0.00225))+(0.25*(pow((y/0.00225),4))))); ...
I assume that Ox is the axial coordinate, and Oy is the radial coordinate of your domain.
You define your temperature as T_inlet = 295+15.8*x-(14.9*(0.75-(y/0.00225)^2+(0.25*(y/0.0025)^4)
Taking an example: x=0, y=1.91e-3 => T_inlet=293
...so what is the problem?

 May 7, 2010, 05:31 #13 Senior Member     Dragos Join Date: Mar 2009 Posts: 648 Rep Power: 12 If you found the solution, you are supposed to share it with the rest of the forum, then for a new problem, open a new thread. However, your code should work if you have run at least one iteration, have convective scalars and tell fluent to store the gradients (all three of them are described in the manuals).

 May 7, 2010, 06:03 #14 Member   mohammad Join Date: Apr 2010 Posts: 42 Rep Power: 8 my problem was : when we write: a=295+(15.8038854*b); we assume that inlet temperature is 295K. and when we hook this to fluent, fluent compute inlet temperature 283K!!!( it must be 295K not 283K),So the formula of perofile temperature or surface temperature is wrong or incomplete.(Im not sure) F_PROFILE(f,thread,index) =a-(14.85148515*(0.75-((y/0.00225)*(y/0.00225))+(0.25*(pow((y/0.00225),4))))); I found another profile temperature in "Heat Convection(Latif M. Jiji)" and i hooked this code to fluent: 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) } As we can see i assume inlet temperature 295 K and fluent compute inlet temperature 295.27K, so the profile temperature is right and problem solved. Thanks dmoroian for your help. I hope it can be helpful for other users.

 March 13, 2012, 03:35 #15 Member   Shashank Join Date: Apr 2011 Posts: 70 Rep Power: 7 Mohammad, Could you tell me exactly how you solved the last bit? How did FLUENT respond to the changes you made in your code? You mean instead of a proposed constant (say "a" in your case), we need to put that value (295 in your case) into the profile? Thanks, Shashank

 March 13, 2012, 03:59 #16 Member   Shashank Join Date: Apr 2011 Posts: 70 Rep Power: 7 Or did you use a different profile in the fluid altogether?! If yes, then how should that affect the temperature of the wall? It should be 295 in both cases. Obviously, Fluent does something different in the second case, which is what I am asking from you.

 March 14, 2012, 12:28 #17 Member   mohammad Join Date: Apr 2010 Posts: 42 Rep Power: 8 Dear shashank The first temp profile is a function of heat flux, and I couldn't write the UDF. So, I used another profile temp which is not function of heat flux , and I got it from "Heat Convection(Latif M. Jiji)". The second formula was easy to write the udf.

December 23, 2013, 01:57
#18
New Member

xingangzheng
Join Date: Jul 2009
Posts: 11
Rep Power: 9
Quote:
Do you know the differences betewen the c_T_G and C_T_RG and how to use the C_T_RG ?
Thank you!

 December 23, 2013, 04:32 #19 Member   mohammad Join Date: Apr 2010 Posts: 42 Rep Power: 8 Dear USTBdynamic, I do not have experience in working with C_T_RG. But, I got this from Fluent guidance. " Therefore, if your UDF needs to compute face values from cell gradients, you should use the reconstruction gradient (RG) values instead of non-limited gradient (G) values." I always compute cell values rather than face values and I have gotten good results. Best regards, Mohammad

December 24, 2013, 23:42
#20
New Member

xingangzheng
Join Date: Jul 2009
Posts: 11
Rep Power: 9
thank you very much!

Quote:
 Originally Posted by mohammadkm Dear USTBdynamic, I do not have experience in working with C_T_RG. But, I got this from Fluent guidance. " Therefore, if your UDF needs to compute face values from cell gradients, you should use the reconstruction gradient (RG) values instead of non-limited gradient (G) values." I always compute cell values rather than face values and I have gotten good results. Best regards, Mohammad

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Ashi Fluent UDF and Scheme Programming 0 May 25, 2009 09:39 Travis FLUENT 4 January 15, 2009 12:48 Bo FLUENT 1 July 16, 2008 06:47 umesh FLUENT 4 July 13, 2003 17:07 ramesh FLUENT 0 June 29, 2003 14:14

All times are GMT -4. The time now is 16:32.