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

UDF for a time varying temperature boundary condition

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

Like Tree1Likes
  • 1 Post By ghost82

Reply
 
LinkBack Thread Tools Display Modes
Old   October 11, 2013, 03:12
Unhappy UDF for a time varying temperature boundary condition
  #1
New Member
 
Sam
Join Date: Sep 2013
Posts: 4
Rep Power: 3
sparke03 is on a distinguished road
Hello,

I'm VERY new to Fluent and I'm attempting to write a UDF that will make the temperature at a wall a function of time. I've never programmed in C before either so I'm having some trouble getting the correct sytax.

Here's my UDF:

#include "udf.h"

DEFINE_PROFILE(HC_temp_BC,thread,i)
{
face_t f;
begin_f_loop(f,thread)
{
time=CURRENT_TIME;
F_PROFILE(f,thread,i)=(-4*10^(-17))*t^5 + (1*10^(-12))*t^4 - (1*10^(-8))*t^3 + (5*10^(-2))*t^2 - (0.0357*t)+304.5;
}
end_f_loop(f,thread)
}


I didn't compile it. I've been trying to use Fluent's interpreter but every time I try to interpret it I get this error:

"Error: /home/aero/Desktop/HC_temp.c: line 2: syntax error"

I'm sure the solution is very simple, but I'm a complete noob so I could use some help. Thanks!
sparke03 is offline   Reply With Quote

Old   October 11, 2013, 11:18
Default
  #2
Senior Member
 
ghost82's Avatar
 
Daniele
Join Date: Oct 2010
Location: Italy
Posts: 899
Rep Power: 15
ghost82 will become famous soon enough
Quote:
Originally Posted by sparke03 View Post
Hello,

I'm VERY new to Fluent and I'm attempting to write a UDF that will make the temperature at a wall a function of time. I've never programmed in C before either so I'm having some trouble getting the correct sytax.

Here's my UDF:

#include "udf.h"

DEFINE_PROFILE(HC_temp_BC,thread,i)
{
face_t f;
begin_f_loop(f,thread)
{
time=CURRENT_TIME;
F_PROFILE(f,thread,i)=(-4*10^(-17))*t^5 + (1*10^(-12))*t^4 - (1*10^(-8))*t^3 + (5*10^(-2))*t^2 - (0.0357*t)+304.5;
}
end_f_loop(f,thread)
}


I didn't compile it. I've been trying to use Fluent's interpreter but every time I try to interpret it I get this error:

"Error: /home/aero/Desktop/HC_temp.c: line 2: syntax error"

I'm sure the solution is very simple, but I'm a complete noob so I could use some help. Thanks!
Sintax error refers to exponential "^'; right sintax is pow(x,y) which returns x raised to y;
try this:

Code:
#include "udf.h"

DEFINE_PROFILE(HC_temp_BC,thread,i)
{
face_t f;
begin_f_loop(f,thread)
{
time=CURRENT_TIME;
F_PROFILE(f,thread,i)=(-4*pow(10,-17))*pow(t,5)+pow(10,-12)*pow(t,4)-pow(10,-8)*pow(t,3)+5*pow(10,-2)*pow(t,2)-0.0357*t+304.5;
}
end_f_loop(f,thread)
}
Daniele
sircorp likes this.
ghost82 is offline   Reply With Quote

Old   October 11, 2013, 11:25
Default
  #3
Senior Member
 
ghost82's Avatar
 
Daniele
Join Date: Oct 2010
Location: Italy
Posts: 899
Rep Power: 15
ghost82 will become famous soon enough
But you have error on line 2?
Make sure you are writing in txt file, then rename .txt to .c and that there aren't "hidden" characters in line 2.

Daniele
ghost82 is offline   Reply With Quote

Old   October 16, 2013, 01:05
Default
  #4
New Member
 
Sam
Join Date: Sep 2013
Posts: 4
Rep Power: 3
sparke03 is on a distinguished road
Thank you Ghost82. I've never coded in C before so I'd written the equation as if I were coding it in MATLAB. Thanks for correcting me!

I finally figured out why I was getting a sytax error on line 2. I had written the function on my PC (Windows), and then sent it to one of the university's computers (Linux) to run it in Fluent. I just rewrote the function on the Linux computer and it worked perfectly.
sparke03 is offline   Reply With Quote

Reply

Tags
ansys, fluent, temperature, transient bc, udf

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
Wind turbine simulation Saturn CFX 34 October 16, 2014 05:27
How to get free stream temperature in boundary condition saharesobh FLUENT 0 October 9, 2012 17:12
vorticity boundary condition bearcharge Main CFD Forum 0 May 14, 2010 11:32
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 6 April 17, 2010 23:40
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


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