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

temperature varies with time

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By aozdogan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 7, 2014, 16:59
Default temperature varies with time
  #1
New Member
 
Ayse Ozdogan
Join Date: Oct 2014
Posts: 4
Rep Power: 11
aozdogan is on a distinguished road
Hi all,
I am trying to write a udf code to define boundary conditions for the inlet and outlet temperature that are varying with time. I create a txt/or c file, but I dont know how to read this file. Does anyone have experienced with this type problem?

Thanks
aozdogan is offline   Reply With Quote

Old   October 8, 2014, 10:32
Default
  #2
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 13
Kokemoor is on a distinguished road
You might be able to use profiles instead of UDFs. They're less powerful, but simpler. Check out Section 6.6 of the Fluent User's Guide.
Kokemoor is offline   Reply With Quote

Old   October 8, 2014, 10:39
Default
  #3
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
I would go for a DEFINE_PROFILE udf, see the examples in sections 2.3.19.10 and 2.3.19.11 of the UDF Manual release 15.0. Then read section 2.3.19.12 in order to know how to hook the boundary profile in your model.
macfly is offline   Reply With Quote

Old   October 8, 2014, 13:05
Default
  #4
New Member
 
Ayse Ozdogan
Join Date: Oct 2014
Posts: 4
Rep Power: 11
aozdogan is on a distinguished road
Quote:
Originally Posted by macfly View Post
I would go for a DEFINE_PROFILE udf, see the examples in sections 2.3.19.10 and 2.3.19.11 of the UDF Manual release 15.0. Then read section 2.3.19.12 in order to know how to hook the boundary profile in your model.
thanks Kokemoor and macfly.
I went over all you mentioned here, but none of them has an example related to my problem. Since my experimental data is a large demand even though I cut off using monthly base temperature vs time, the best way to assign this data to fluent is to have txt file and read it by udf. I am still stuck how to manage
aozdogan is offline   Reply With Quote

Old   October 9, 2014, 07:58
Default
  #5
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Example 2.3.19.11 is perfectly related to your case with time-varying specification of a profile. If your case has a lot of time steps and a lot of if(CURRENT_TIME <= ...) you could automate the writing of the UDF in Python, Matlab or any other programming language.
macfly is offline   Reply With Quote

Old   October 9, 2014, 11:01
Default got a code working :)
  #6
New Member
 
Ayse Ozdogan
Join Date: Oct 2014
Posts: 4
Rep Power: 11
aozdogan is on a distinguished road
thanks macfly! your are right it is exactly matching with my problem except that I have a lots of case file.I looked at the fluent 14.5 release but I just found fluent 15. Anyway, finally I got my code is working know. Here is my code;
#include "udf.h"
#include "mem.h"
double time;
double timef[51], temp1f[51], temp2f[51];
int vcount=0;
FILE *fp;
DEFINE_INIT(read_file, d)
{
/*reads data from file and stores as global variables*/
int i;
fp=fopen("timevstemp.txt", "r");
for (i=0;i<51; i++){
fscanf(fp,"%lf %lf %lf", &timef[i], &temp1f[i], &temp2f[i]);
}
fclose(fp);
printf(" %f %f %f %\n", timef[0], temp1f[0], temp2f[0]);
}
DEFINE_PROFILE(tempout, t, nv)
{
face_t f;
double x[ND_ND];
int row1=1; /*initalize row to 1*/
int prow1=0;
double Tout;
time=CURRENT_TIME;
while((time) >= timef[row1] ){
row1=row1+1;
}
prow1=row1-1;
Tout= 273.15+ temp1f[prow1] + ((time)-(timef[prow1]))*(temp1f[row1] - temp1f[prow1])/
(timef[row1]-timef[prow1]);
printf(" Tout %f temp1 %f tempf %f \n",Tout, temp1f[prow1], temp1f[row1]);
begin_f_loop(f, t)
{
F_CENTROID(x,f,t);
F_PROFILE(f,t,nv)= Tout;

}
end_f_loop(f,t)
}
DEFINE_PROFILE(tempin, t, nv)
{
face_t f;
double x[ND_ND];
int row1=1; /*initalize row to 1*/
int prow1=0;
double Tin;
time=CURRENT_TIME;
while((time) >= timef[row1] ){
row1=row1+1;
}
prow1=row1-1;
Tin= 273.15+ temp2f[prow1] + ((time)-(timef[prow1]))*(temp2f[row1] - temp2f[prow1])/
(timef[row1] - timef[prow1]);
begin_f_loop(f, t)
{
F_CENTROID(x,f,t);
F_PROFILE(f,t,nv)= Tin;

}
end_f_loop(f,t)
}
macfly likes this.
aozdogan 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
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 07:15
Transient simulation not converging skabilan OpenFOAM Running, Solving & CFD 14 December 16, 2019 23:12
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 13:12
Transient simulation : Static temperature and time averaged static temperature saisanthoshm88 CFX 4 July 4, 2013 02:18
Low Mixing time Problem Mavier CFX 5 April 29, 2013 00:00


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