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

Udf function average temp inlet - outlet

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 7, 2011, 14:33
Default SOLVED:Udf function average temp inlet - outlet
  #1
New Member
 
Join Date: Apr 2009
Location: Mexico
Posts: 7
Rep Power: 17
erodv is on a distinguished road
Hello,

I would appreciate if somebody take a look in the UDF and give me some advices. I am trying to get the average temperature at the outlet of a pipe, and after some manipulations use it in the pressure inlet of the next time step. It compiles and the simulation runs up to the first time step. It starts with reversed flow then just after the first time step prints Temperature limited to 1 in the domain 1. Tavg prints -nan.

Thanks

DEFINE_EXECUTE_AT_END(Temp_inlet)
{
Domain *d;
real Temp_t;
real area;
real area_tot;
real tavg;
real A[ND_ND];
Thread *t;
face_t f;
d=Get_Domain(1);

t=Lookup_Thread(d,11);

begin_f_loop(f,t)
{
area = F_AREA(A,f,t);
Temp_t += F_T(f,t);
area_tot += area;
tavg += Temp_t*area;
}
end_f_loop(f,t)
tavg /= area_tot;
tavg_tot1=tavg;
printf("\n Tavg = %f\n",tavg_tot1); /*output -nan*/
}

DEFINE_PROFILE(Temp_inlet,t,i)
{
face_t f;
real time;
real current_time;
time=CURRENT_TIMESTEP;
current_time=CURRENT_TIME;

if (current_time >=10.)
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=((fabs(flow_tot)*(tavg_tot-tavg_tot1)*time)/15.)+tavg_tot1;
}
end_f_loop(f,t)
}
else
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=288.16;
}
end_f_loop(f,t)
}
}

Last edited by erodv; March 7, 2011 at 19:56. Reason: SOLVED
erodv is offline   Reply With Quote

Old   March 7, 2011, 15:08
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi,
I think the problem is in your face loop, substitute this and check. hope that help you:
Quote:
tavg=0;
area_tot=0;
begin_f_loop(f,t)
{
F_AREA(A,f,t);
AREA=NV_MAG(A);
area_tot += AREA;
tavg +=F_T(f,t)*AREA;
}
end_f_loop(f,t)
tavg /= area_tot;
Amir is offline   Reply With Quote

Old   March 7, 2011, 19:54
Default Solved
  #3
New Member
 
Join Date: Apr 2009
Location: Mexico
Posts: 7
Rep Power: 17
erodv is on a distinguished road
Thanks Amir, I did your proposed changes and it worked, this thread has been solved .
erodv is offline   Reply With Quote

Old   November 14, 2016, 09:29
Default
  #4
New Member
 
alper yıldırım
Join Date: Feb 2014
Posts: 10
Rep Power: 12
shzinwoyk is on a distinguished road
Quote:
Originally Posted by erodv View Post
Thanks Amir, I did your proposed changes and it worked, this thread has been solved .

Hi,

Could u share correct form of the UDF? I am working on similar problem.

Thx
shzinwoyk is offline   Reply With Quote

Old   October 6, 2017, 11:16
Default inlet average temperature udf
  #5
New Member
 
sina sadighi
Join Date: Jul 2017
Posts: 5
Rep Power: 9
sinasadighi is on a distinguished road
hi
this is my code , when i put outlet id in it , it works .
but when i put inlet id in it , it doesn't work .
pls help what should i do .


#include "udf.h"

DEFINE_ADJUST(temp_ave, domain)
{
int ID = 9 ;
FILE *output;
Thread *thread=Lookup_Thread(domain, ID);
real total_temp=0;
real ave_T, T;
int i=0;
face_t face;

begin_f_loop(face, thread)
{
T = F_T(face, thread);
total_temp = total_temp + T;
i = i+1;
}
end_f_loop(face, thread)

ave_T = total_temp / i ;

printf("inlet average of temp : %f\n" , ave_T);

output = fopen("inlet average of temp.txt","a");
fprintf(output, "inlet average of temp: %f\n", ave_T);
fclose(output);
}
sinasadighi is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
unsteady inlet velocity udf jill FLUENT 8 February 10, 2015 06:04
Inlet but not outlet mireis FLUENT 1 June 10, 2010 10:56
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35
Question about inlet and outlet BC babyface Main CFD Forum 1 January 15, 2003 09:17
UDF in Fluent to Match Mass Flow at Pressure Outlet Jonas Larsson Main CFD Forum 1 April 29, 1999 10:44


All times are GMT -4. The time now is 08:11.