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

Inlet won't apply UDF and has temperature at 0K!

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 17, 2012, 13:11
Default Inlet won't apply UDF and has temperature at 0K!
  #1
New Member
 
Sevy Lee
Join Date: Feb 2012
Posts: 2
Rep Power: 0
tccruise is on a distinguished road
Hi all. I am quite new here. I have a serious problem when simulating an AC in an empty room. The AC has 2 mass flow inlets and 2 pressure outlets. To simulate realistic AC operation, inlet temperature is set via UDF to be a function of both time and average outlet temperature. Both inlets have the same temperature at a given time. The inlets are seperate and named as INRight and INLeft.

My problem is this: while using the exact same UDF for temperature profile, INLeft had a correct temperature profile, as predicted by the UDF; but INRight was always at 0K () throughout its whole face! INRight was actually sending out 1K air (FLUENT will limit temperature to 1K whenever it is below 1K).

I can't have the two inlets as one because they have different inlet directions and should be kept seperate.
To try to find out the problem, I tried setting INLeft to WALL and left only one inlet INRight (Don't know why I did it, just my instinct..) and INRight was still 0K, tried setting temperature with two functions udf_TempL and udf_TempR which had basicly the same code, INRight still 0K. Then I tried setting temperature of INRight to constant, and INLeft turned into 0K! What can that mean? I don't think the UDF is the problem since it gave INLeft a correct temperature with the presence of INRight UDF. But here it is anyway:
#include "udf.h"
real time2=-1;
real cc=0;
DEFINE_PROFILE(un_temp,thread,position)
{
face_t outf,f;
real sum_t1=0;
real sum_t2=0;
real sum_t3=0;
real sum_t4=0;
real sum_t=0;
real A[ND_ND];
real s=0;
real sz1=0;
real sz2=0;
real sz3=0;
real sz4=0;
real tt;
real time1;
real t=0;
real dT;
real inlet;
real setu;//setting temperature
real setd;

Domain *domain=Get_Domain(1);
int ID1=17;
int ID2=18;
int ID3=19;
int ID4=20;
Thread *thread1 = Lookup_Thread(domain, ID1);//outlet_o5l
Thread *thread2 = Lookup_Thread(domain, ID2);//outlet_o5r
Thread *thread3 = Lookup_Thread(domain, ID2);//outlet_o2l
Thread *thread4 = Lookup_Thread(domain, ID2);//outlet_o2r
time1=RP_Get_Real("flow-time");
tt=time1;
setu=294.15;
setd=293.15;
if(time1>time2)
{
//outlet_o5l
begin_f_loop(outf,thread1)
{
// F_AREA(A,outf,thread1);
s=F_FLUX(outf,thread1);//*(A[1])
t=F_T(outf,thread1);
sz1+=s; //
sum_t1+=t*s;
}
end_f_loop(outf,thread1)
if(sz1==0) sum_t1=t;
else sum_t1=sum_t1*1/sz1;
//outlet_o5r
begin_f_loop(outf,thread2)
{
//F_AREA(A,outf,thread2);
s=F_FLUX(outf,thread2);//*(A[1])
t=F_T(outf,thread2);
sz2+=s; //
sum_t2+=t*s;
}
end_f_loop(outf,thread2)
if(sz2==0) sum_t2=t;
else sum_t2=sum_t2*1/sz2;
//outleto2l
begin_f_loop(outf,thread3)
{
//F_AREA(A,outf,thread3);
s=F_FLUX(outf,thread3);//*(A[1])
t=F_T(outf,thread3);
sz3+=s; //
sum_t3+=t*s;
}
end_f_loop(outf,thread3)
if(sz3==0) sum_t3=t;
else sum_t3=sum_t3*1/sz3;
//outleto2r
begin_f_loop(outf,thread4)
{
//F_AREA(A,outf,thread4);
s=F_FLUX(outf,thread4);//*(A[1])
t=F_T(outf,thread4);
sz4+=s; //
sum_t4+=t*s;
}
end_f_loop(outf,thread4)
if(sz4==0) sum_t4=t;
else sum_t4=sum_t4*1/sz4;
sum_t=(sum_t1+sum_t2+sum_t3+sum_t4)/4;
//decide the air temperature of inlet
if (sum_t<setd) cc=cc+1;
if (cc<1)//start
{
if(tt<53)
dT=0.0002*tt*tt*tt-0.023*tt*tt+0.8658*tt-0.5086;
else
dT=0.0094*tt+10.5207;
}
else
{
if(sum_t<=setd)
dT=4.656;
else
{
if(sum_t>=setu)
dT=13.382;
else dT=4.656;
}
}

inlet=sum_t-dT;
if (inlet<280.15) inlet=280.15;
begin_f_loop(f,thread)
{
F_PROFILE(f,thread,position)=inlet;

}
end_f_loop(f,thread)

printf("temp of inlet:%g\n",inlet);
printf("av-temp of outlet:%g\n",sum_t);
printf("c=%g\n",cc);
time2=time1;
}
}


Would somebody PLZ help me! Pretty desperate here.

Last edited by tccruise; February 17, 2012 at 13:32.
tccruise is offline   Reply With Quote

Old   February 19, 2012, 05:10
Default
  #2
New Member
 
Sevy Lee
Join Date: Feb 2012
Posts: 2
Rep Power: 0
tccruise is on a distinguished road
Found a solution!!! THX for reading the tedious post above!

All I have to do is set another UDF which copies the temperature from the correct inlet and applies it to the once erroneous inlet!!

How could I not have figured that out during the past 2 day!

THX again, to those that took their time to read my post! Have a nice day!
tccruise is offline   Reply With Quote

Old   September 14, 2012, 07:08
Default
  #3
New Member
 
n7310889
Join Date: Aug 2012
Posts: 26
Rep Power: 14
n7310889 is on a distinguished road
Hi,
I'm modeling 3D conjugate heat transfer system, where the fluid domain absorb heat from the tube. The tube itself get heat from some external source, however. Since the resultant temperature of the tube outer surface will be very high I have to consider radiation exchange with the evacuated glass envelope. That means I have to apply two conditions: 1. a spatially variable input heat flux profile and 2. radiation exchange. I'm trying to develop an UDF for that. However, I've written a udf for heat flux, and it is running well. Now I'm trying to add radiation in that macro at a fashion like that: F_PROFILE(x,t,i) = given_heat_flux - some_constant*(pow(F_T(f,t),4-pow(Temp_glass,4));
Whenever I try to interprate this macro, fluent shows me parse error, just at this line. One thing I'm wondering is, I'm assigning input heat to a certain face and again use the temperature of the same face to negate radiation exchange from the resultant heat flux! Input heat will be utilized first to raise the face temperature, then radiation exchange will be function of this temperature, is my understanding. I don't understand actually how should I assign radiation exchange in my model. Could you please help me to get rid of this riddle? I'll be thankful really.
Regards
n7310889 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



All times are GMT -4. The time now is 10:40.