CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF temperature profile (http://www.cfd-online.com/Forums/fluent-udf/113104-udf-temperature-profile.html)

asal February 12, 2013 10:50

UDF temperature profile
 
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.

flotus1 February 12, 2013 11:28

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.

asal February 12, 2013 11:47

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;

flotus1 February 12, 2013 11:55

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?

asal February 12, 2013 12:30

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.

flotus1 February 12, 2013 12:46

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.

asal February 13, 2013 10:13

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.

flotus1 February 13, 2013 11:36

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.

asal February 14, 2013 07:39

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.

flotus1 February 14, 2013 07:55

Did you try to put both UDFs in one text file?

Then when interpreting the file, both UDFs should be available.

asal February 14, 2013 08:02

Great!
It works. thank you so much.

str6073 July 23, 2013 08:31

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???

flotus1 July 23, 2013 08:40

"Linearly varying" with respect to which variable?
Could you make a small sketch of what you need?

str6073 July 23, 2013 09:18

thanx for replying . consider a horizontal cylinder. on one of its circular faces i need this temperature variation from bottom to top. http://www.filesnack.com/files/ch9qollj

flotus1 July 23, 2013 09:42

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)
}


str6073 July 23, 2013 14:21

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.

flotus1 July 23, 2013 14:26

I dont see an image attached to your post.

str6073 July 24, 2013 00:42

1 Attachment(s)
i'm uploading it again. thanx for your help

flotus1 July 24, 2013 03:04

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.

str6073 July 24, 2013 05:35

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??


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