# UDF temperature profile

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

 February 12, 2013, 09:50 UDF temperature profile #1 Senior Member   Astio Lamar Join Date: May 2012 Location: Pipe Posts: 186 Rep Power: 11 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 09:07.

 February 12, 2013, 10:28 #2 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 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.

 February 12, 2013, 10:47 #3 Senior Member   Astio Lamar Join Date: May 2012 Location: Pipe Posts: 186 Rep Power: 11 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;

 February 12, 2013, 10:55 #4 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 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?

 February 12, 2013, 11:30 #5 Senior Member   Astio Lamar Join Date: May 2012 Location: Pipe Posts: 186 Rep Power: 11 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.

 February 12, 2013, 11:46 #6 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 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.

 February 13, 2013, 09:13 #7 Senior Member   Astio Lamar Join Date: May 2012 Location: Pipe Posts: 186 Rep Power: 11 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.

 February 13, 2013, 10:36 #8 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 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.

 February 14, 2013, 06:39 #9 Senior Member   Astio Lamar Join Date: May 2012 Location: Pipe Posts: 186 Rep Power: 11 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.

 February 14, 2013, 06:55 #10 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 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.

 February 14, 2013, 07:02 #11 Senior Member   Astio Lamar Join Date: May 2012 Location: Pipe Posts: 186 Rep Power: 11 Great! It works. thank you so much.

 July 23, 2013, 08:31 #12 Member   sooraj Join Date: Dec 2012 Posts: 38 Rep Power: 10 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???

 July 23, 2013, 08:40 #13 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 "Linearly varying" with respect to which variable? Could you make a small sketch of what you need?

 July 23, 2013, 09:18 #14 Member   sooraj Join Date: Dec 2012 Posts: 38 Rep Power: 10 thanx for replying . consider a horizontal cylinder. on one of its circular faces i need this temperature variation from bottom to top.

 July 23, 2013, 09:42 #15 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 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) }```

 July 23, 2013, 14:21 #16 Member   sooraj Join Date: Dec 2012 Posts: 38 Rep Power: 10 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.

 July 23, 2013, 14:26 #17 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 I dont see an image attached to your post.

July 24, 2013, 00:42
#18
Member

sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 10
Attached Images
 sooraj.jpg (10.8 KB, 136 views)

 July 24, 2013, 03:04 #19 Super Moderator     Alex Join Date: Jun 2012 Location: Germany Posts: 2,791 Rep Power: 39 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.

 July 24, 2013, 05:35 #20 Member   sooraj Join Date: Dec 2012 Posts: 38 Rep Power: 10 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??