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

UDF temperature profile

Register Blogs Community New Posts Updated Threads Search

Like Tree23Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 12, 2013, 10:50
Default UDF temperature profile
  #1
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14
asal is on a distinguished road
Hello every body.

I have a geometry with inlet dimension of z=1.2 and y=2.46 at the inlet. I want to define an inlet temperature profile at the inlet using UDF.
the temperature varies along the y coordinate.


#include "udf.h"

DEFINE_PROFILE(inlet_x_temperature, thread, position)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
F_PROFILE(f, thread, position) = ...;
}
end_f_loop(f, thread)
}

But I got error. "floating point exception"

this is simple sketch of the geometry:


I think something with the coordinate should be the problem.
could any body help me?

Moreover I read somewhere that it is possible to define the boundary with the coordinated.

for instance I have two array
y = [0.2 0.4 ... 2.4]
t = [21 15 ... 18]
then I can define a temperature inlet profile based on the y coordinate and temperature array.
Any idea?

thanks.

Last edited by asal; February 13, 2013 at 10:07.
asal is offline   Reply With Quote

Old   February 12, 2013, 11:28
Default
  #2
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Which formula describes your function? Without knowing what you put instead of the "..." in

F_PROFILE(f, thread, position) = ...;

no one can guess what is causing the error.
flotus1 is offline   Reply With Quote

Old   February 12, 2013, 11:47
Default
  #3
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14
asal is on a distinguished road
Sorry.
I think it is not important!!

F_PROFILE(f, thread, position) = 19.59+0.532*y+0.36*y*y-0.157*y*y*y;
asal is offline   Reply With Quote

Old   February 12, 2013, 11:55
Default
  #4
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Wait a minute: When does the error occur?
When you try to interpret/compile your UDF or during the solution process?
What are the possible values y can have, i.e. what is the physical extent of the boundary?
flotus1 is offline   Reply With Quote

Old   February 12, 2013, 12:30
Default
  #5
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14
asal is on a distinguished road
I got error at the beginning of simulation process, no error for interpret/compile.
y values start from zero to 2.46 (the y dimension of the geometry). I have a data array for y and temperature as below:
y = [0.2 0.4 0.6 ... 2.2 2.4]
temp = [19 20 20.4 .... 19.54 20]
So the UDF should specify this temperature profile at the inlet varied in y direction.
see the above figure.
asal is offline   Reply With Quote

Old   February 12, 2013, 12:46
Default
  #6
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
I guess that the problem arises from the °C/K difference.

Fluent expects the output of UDFs to be in SI-Units. Therefore, the output of the UDF is interpreted as a Temperature between 21 and 23 K.
This might be inconsistent with the initial values you provide, causing the solution to diverge.


For the definition of BCs via arrays: Fluent can read (and write) profiles for boundary conditions.
The easiest way to get familiar with is is to write such a profile at the boundary condition of interest. From the file created, you can derive the necessary file format to provide profile data.
teguhtf, virgy, asal and 4 others like this.
flotus1 is offline   Reply With Quote

Old   February 13, 2013, 10:13
Default
  #7
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14
asal is on a distinguished road
Hello and thanks a lot for your helpful hint.
I change my equation to SI-Units and everything done.
just few questions:
could you please briefly describe what theses lines means.

real x[ND_ND]; /* this will hold the position vector */
what "this will hold the position vector" exactly mean?
also

real y;

face_t f;


F_CENTROID(x,f,thread);

y = x[1];


for instance y = x[1]; if I change it to y = x[0]; then what is going on?
if my temperature varies along the Z or X coordinate, then how should I change the code? I am quite familiar with C programming. I understand the loop. just I have problem with the coordinated and so on.

thanks.
asal is offline   Reply With Quote

Old   February 13, 2013, 11:36
Default
  #8
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Glad I could help.
Lets take a look at your further questions.

x[ND_ND] is an array of dimension 2 if you are running the 2D solver and dimension 3 if you are running the 3D solver (which is obviously the case).
Accordingly, x[0] corresponds to the x-position, x[1] is the y position and x[2] is the z position.
Now the comment "this will hold the position vector" should become clear.

with "real y" you define a variable of type real with the name y. Usual syntax...

face_t f : same thing, f appears in the loop arguments. The exact definition can be found in the UDF manual.

F_CENTROID(x,f,thread); Here you evaluate the position of the face centroid and assign it to the variable x.

y=x[1]; This step is a bit redundant. You might aswell use x[1] in the following equation directly. It just makes the equation look better and maybe saves some computing time.
amirreza, asal, mrenergy and 6 others like this.
flotus1 is offline   Reply With Quote

Old   February 14, 2013, 07:39
Default
  #9
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14
asal is on a distinguished road
Hello again and thanks for your helpful answer.
Just one more questions. How can I use two profile simultaneously? when I add the second one, then the first is vanished and I cannot use it anymore in the boundary setting! For instance I want to use both velocity and temperature profile at the inlet at the same time. first I have interpreted the velocity and then, when I interpreted the temperature profile, then the first one in not available in the boundary setting to select.
what should I do?
thanks.
asal is offline   Reply With Quote

Old   February 14, 2013, 07:55
Default
  #10
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Did you try to put both UDFs in one text file?

Then when interpreting the file, both UDFs should be available.
amirreza, asal, 6863523 and 1 others like this.
flotus1 is offline   Reply With Quote

Old   February 14, 2013, 08:02
Default
  #11
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14
asal is on a distinguished road
Great!
It works. thank you so much.
asal is offline   Reply With Quote

Old   July 23, 2013, 09:31
Default
  #12
Member
 
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 13
str6073 is on a distinguished road
hi
i need a udf for a project work. I'm quite new to this area and have a very short time frame for completing this work. so i really need your help. I need a linearly varying temperature profile boundary condition to be applied on the circular face of a cylinder.temperature varies from 25 to 50 degrees from bottom to top. diameter of circle is 470 mm . Can you help me???
str6073 is offline   Reply With Quote

Old   July 23, 2013, 09:40
Default
  #13
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
"Linearly varying" with respect to which variable?
Could you make a small sketch of what you need?
flotus1 is offline   Reply With Quote

Old   July 23, 2013, 10:18
Default
  #14
Member
 
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 13
str6073 is on a distinguished road
thanx for replying . consider a horizontal cylinder. on one of its circular faces i need this temperature variation from bottom to top.
str6073 is offline   Reply With Quote

Old   July 23, 2013, 10:42
Default
  #15
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Since you refuse to be more descriptive, I have to make some assumptions
With "degrees" you mean °C, so I change the temperature variation from 298K-323K.
The x-axis coincides with the axis of the cylinder and the y-axis is from "bottom" to "top".
Thus the temperature varies linearly with the y-axis, with the highest temperature at the greatest positive y-extent of the surface.

Code:
#include "udf.h"

DEFINE_PROFILE(temp_linear, thread, position) 
{
real x[ND_ND];
face_t f;
real tmin, tmax, d;

tmin = 298.0;
tmax = 323.0;
d = 0.47;

  begin_f_loop(f, thread)
    {
      F_CENTROID(x,f,thread);
      F_PROFILE(f, thread, position) = (tmin+tmax)/2.0 + (tmax-tmin)/d*x[1];
    }
  end_f_loop(f, thread)
}
flotus1 is offline   Reply With Quote

Old   July 23, 2013, 15:21
Default
  #16
Member
 
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 13
str6073 is on a distinguished road
have you seen the image i attached ?? i'm not sure if it is visible or not . else please tell me i will upload another one.
str6073 is offline   Reply With Quote

Old   July 23, 2013, 15:26
Default
  #17
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
I dont see an image attached to your post.
flotus1 is offline   Reply With Quote

Old   July 24, 2013, 01:42
Default
  #18
Member
 
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 13
str6073 is on a distinguished road
i'm uploading it again. thanx for your help
Attached Images
File Type: jpg sooraj.jpg (10.8 KB, 139 views)
str6073 is offline   Reply With Quote

Old   July 24, 2013, 04:04
Default
  #19
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Without a coordinate system, this image doesnt add much information.
Did you at least try the UDF i proposed 4 posts ago? Just change x[1] if the y-axis is not the direction in which the temperature rises.
flotus1 is offline   Reply With Quote

Old   July 24, 2013, 06:35
Default
  #20
Member
 
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 13
str6073 is on a distinguished road
sorry for not mentioning the coordinates. axis of the cylinder is in z direction and temperature rise is in y direction .Does that change anything in the code?? i tried the given code and it runs without any problem. Also may i know your real name so that i can give you credits in the report i'm going to make??
str6073 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
please help UDF for velocity profile in y-directio raju Fluent UDF and Scheme Programming 6 April 13, 2019 00:21
UDF error - parabolic velocity profile - 3D turbine Zaqie Fluent UDF and Scheme Programming 9 June 25, 2016 20:08
defining temperature profile with UDF mohammadkm Fluent UDF and Scheme Programming 11 July 3, 2013 01:15
UDF temp. profile BC Shashikant FLUENT 0 June 24, 2006 04:16
temperature profile on boundary sivakumar FLUENT 5 November 24, 2002 01:58


All times are GMT -4. The time now is 22:04.