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

UDF for linear temperature variation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 2, 2016, 01:30
Post UDF for linear temperature variation
  #1
New Member
 
Join Date: Sep 2016
Posts: 10
Rep Power: 9
nonstopthinker is on a distinguished road
hey.

I am modelling a coolant flow in a rectangular channel.. I have inlet temperature, top wall temperature, bottom wall temperature, and exit pressure.

i want to define a linear temperature variation for the side walls (i know the top wall and bottom wall temperatures) by means of udf.

kindly help me in writing this code, as i am new to udf. The following is the code i have written. However, i am not getting the correct temperature profile. Please help

Code:
# include "udf.h" 
 
DEFINE_PROFILE(tsw, thread, position) 
{ 
real x[ND_ND]; /* this will hold the position vector */ 
real y; 
double y1,y2,tsw; 
int i,j1; 
double yy[1300]; 
real T; 
cell_t c; 
face_t f; 
begin_c_loop(c, thread) 
{ 
    C_CENTROID(x,c,thread); 
        /* temp=C_T(c,thread);*/ 
    for (i=0;i<100;i++) 
    { 
     tsw=264.341*yy[i]+600;} 
    } 
     if (y1>=yy[100]) {tsw=600;} 
    F_PROFILE(c, thread, position) = tsw; 
    /*printf("%f\t%f\t%f\t%f\n",y1,y2,tsw,temp);*/ 
} 
end_c_loop(c, thread) 
}
nonstopthinker is offline   Reply With Quote

Old   September 2, 2016, 09:41
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by nonstopthinker View Post
hey.

I am modelling a coolant flow in a rectangular channel.. I have inlet temperature, top wall temperature, bottom wall temperature, and exit pressure.

i want to define a linear temperature variation for the side walls (i know the top wall and bottom wall temperatures) by means of udf.

kindly help me in writing this code, as i am new to udf. The following is the code i have written. However, i am not getting the correct temperature profile. Please help

Code:
# include "udf.h" 
 
DEFINE_PROFILE(tsw, thread, position) 
{ 
real x[ND_ND]; /* this will hold the position vector */ 
real y; 
double y1,y2,tsw; 
int i,j1; 
double yy[1300]; 
real T; 
cell_t c; 
face_t f; 
begin_c_loop(c, thread) 
{ 
    C_CENTROID(x,c,thread); 
        /* temp=C_T(c,thread);*/ 
    for (i=0;i<100;i++) 
    { 
     tsw=264.341*yy[i]+600;} 
    } 
     if (y1>=yy[100]) {tsw=600;} 
    F_PROFILE(c, thread, position) = tsw; 
    /*printf("%f\t%f\t%f\t%f\n",y1,y2,tsw,temp);*/ 
} 
end_c_loop(c, thread) 
}
What temperature are you getting?

about the code, what is the value of y1? Not defined anywhere.

you can also work your code in something like

if (i <100)
{
...
}
else
{
...
}

I will make it clear and easier.
Bruno Machado is offline   Reply With Quote

Old   September 4, 2016, 00:36
Default
  #3
D.M
Member
 
Davoud Malekian
Join Date: Jan 2016
Posts: 53
Rep Power: 10
D.M is on a distinguished road
Hello nonstopthinker,

The question is that why you guys loop over cells to define a specific boundary condition. the name "boundary condition" always make it clear that it is a boundary "face thread" that you are trying to approach not bunch of cells, so maybe change the code like below :

first i have to ask u some questions:
do you have any source of data that "yy" is saved there?? cause yy[0] , yy[1] , ... yy[1300], won't give you anything unless you define values for all the 1300 components of this array called "yy"!
another question! you have used just 101 components of this array "yy" in your code so why giving it 1301 components?!

man i don't see anything in your code that defines values or something for y1 and y2! as i see in your code y2 hasn't been used even once so its better to be removed , and about y1 you must specify it's value like this
"double y1 = 80;" (for example).


#include "udf.h"
static int conter = 0;
DEFINE_PROFILE(temprature, t, i)
{
real x[ND_ND]; /* this will hold the position vector */
double y1,tsw;
double yy[1300];
face_t f;
begin_f_loop(f, t)
{
F_CENTROID(x,f,t);
/* temp=C_T(c,t);*/
for (conter=0;conter<100;conter++)
{
tsw=264.341*yy[conter]+600;}
}
if (y1>=yy[100]) {tsw=600;}
F_PROFILE(f, t, i) = tsw;
/*printf("%f\t%f\t%f\t%f\n",y1,y2,tsw,temp);*/
}
end_f_loop(f, t)
}

and one more thing , the code won't work untill u give values to y1 and yy.

Last edited by D.M; September 4, 2016 at 10:29.
D.M 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 to change heat transfer coefficient with wall temperature emmkell Fluent UDF and Scheme Programming 18 August 7, 2018 03:44
UDF for a horizontal temperature profile CD Fluent UDF and Scheme Programming 9 May 6, 2018 12:13
UDF problem- time dependent temperature at inlet kaeran FLUENT 1 June 16, 2015 21:48
UDF for heat convection coefficient with fixed surface temperature Boo85 Fluent UDF and Scheme Programming 2 July 10, 2012 18:43
Please Help! Temperature profile UDF for 3D geometry subhankar_bhandari FLUENT 2 April 16, 2011 05:30


All times are GMT -4. The time now is 03:14.