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

UDF of linear distribution of temperature in a 2D tank

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

Like Tree1Likes
  • 1 Post By arailos

Reply
 
LinkBack Thread Tools Display Modes
Old   August 18, 2010, 16:04
Default UDF of linear distribution of temperature in a 2D tank
  #1
New Member
 
Arailos
Join Date: Aug 2010
Posts: 4
Rep Power: 6
arailos is on a distinguished road
Hi all,

I am simulating heat transfer from a cylindrical source immersed in a rectangular cavity and I am trying to find out how can I write a UDF in order to have thermally stratified layers with linear distribution of temperature in the whole domain of the tank at the initialization of the simulation.

I am really new to UDF and this is my first attempt.

So far I have written this code but....

///////////////////////////////////////
#include "udf.h"

DEFINE_INIT(linear_temp,d)

{
cell_t c;
Thread *t;
real x[ND_ND];
real Tt=338., Tb=288.;
real xb=0.,xt=-0.5;
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);

C_T(c,t) = Tb+(x-xb)dT ;

}
end_c_loop_all(c,t)
}
}
///////////////////////////////

My tank has a height of 0.5m and is placed horizontally with the gravity vector pointing to the positive of x axis...The bottom temp is 288K and the top temp of the tank is 338K...I can clarify any details needed... The tank is place horizontally because I am going to solve it axisymmetrically and the axis boundary condition should have x-axis direction...

Thanks in advance....

Last edited by arailos; August 19, 2010 at 14:33.
arailos is offline   Reply With Quote

Old   August 19, 2010, 14:14
Default Code found
  #2
New Member
 
Arailos
Join Date: Aug 2010
Posts: 4
Rep Power: 6
arailos is on a distinguished road
hey all,

finally I did it...This is the appropriate code for my case...

////////////////////


#include "udf.h"

DEFINE_INIT(linear_temp,d)

{
cell_t c;
Thread *t;
real xc[ND_ND];
real myx;
real Tt=338., Tb=288.;
real xb=0.,xt=-0.5;
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);

myx=xc[0]

C_T(c,t) = Tb+(myx-xb)dT ;

}
end_c_loop_all(c,t)
}
}
////////////////////

I just post it in case anyone is looking for something similar...
hwangpo likes this.
arailos is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
temperature gradient problem in udf Souviktor Fluent UDF and Scheme Programming 2 March 31, 2009 08:43
UDF velocity and temperature Raj FLUENT 3 February 1, 2009 19:29
UDF reading the temperature gradient Fabian FLUENT 1 May 29, 2003 20:18
udf for repatching a temperature in a volume McGregor FLUENT 4 April 10, 2003 04:28
Temperature Distribution on a circuit board Blackadder Main CFD Forum 1 March 27, 2003 12:32


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