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

Temperature profile for cell zone

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2015, 12:23
Default Temperature profile for cell zone
  #1
New Member
 
R. Raimondi
Join Date: Mar 2015
Posts: 8
Rep Power: 11
Jackino777 is on a distinguished road
hi, I have a problem in writing a UDF for a variable temperature in a 3D cell zone.
This is my first UDF and I don't know very well the C programming, so is like impossible defining the function for me in a few days.
Do you know how can I write a linear function for temperature, where:
Z=0 m => T=24 °C
Z=-3 m => T=18 °C
also:
Z< -3 m => T=18 °C

Thank you!
Jackino777 is offline   Reply With Quote

Old   May 25, 2015, 19:12
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
First, convert your temperature listing to a series of equations that you'll later code into with conditional if statements; it appears there's two segments of the temperature distribution (one linear and one constant). Then have a read of the UDF manual in the section on the DEFINE_PROFILE macro where the usage is detailed and several examples are provided.
`e` is offline   Reply With Quote

Old   May 26, 2015, 11:56
Default
  #3
New Member
 
R. Raimondi
Join Date: Mar 2015
Posts: 8
Rep Power: 11
Jackino777 is on a distinguished road
Thanks for the advices.
I tried to write the code, but I don't know how to put the two conditions (linear and constant) in a single UDF, can you help me with this?
For now I write only the linear part.

The code is:

#include "udf.h"

DEFINE_PROFILE(pressure_profile, t, i)
{
real x[ND_ND]; /* this will hold the position vector */
real z;
face_t f;

begin_f_loop(f, t)
{
F_CENTROID(x,f,t);
z = x[2];
F_PROFILE(f, t, i) = 297+2*z;
}
end_f_loop(f, t)
}

I also put an image of the result
Attached Images
File Type: jpg temperature.jpg (29.7 KB, 12 views)
Jackino777 is offline   Reply With Quote

Old   May 26, 2015, 12:37
Default
  #4
New Member
 
R. Raimondi
Join Date: Mar 2015
Posts: 8
Rep Power: 11
Jackino777 is on a distinguished road
I solved it, i've tried a lot of time and now it's ok.
I write this one, and thanks for everything:

#include "udf.h"

DEFINE_PROFILE(pressure_profile, t, i)
{
real x[ND_ND]; /* this will hold the position vector */
real z;
face_t f;

begin_f_loop(f, t)
{
F_CENTROID(x,f,t);
z = x[2];
if (z > -3)
F_PROFILE(f, t, i) = 291+2*z;
else
F_PROFILE(f, t, i) = 291;
}
end_f_loop(f, t)
}
Jackino777 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
UDF for a horizontal temperature profile CD Fluent UDF and Scheme Programming 9 May 6, 2018 12:13
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 12:25
Segmentation Fault in fluent3DMeshToFoam cwang5 OpenFOAM Bugs 23 April 13, 2011 15:37
Error to re-open fluent case file J.Gimbun FLUENT 0 April 27, 2006 08:42
Fluent incident radiation problem Michael Schwarz Main CFD Forum 0 October 21, 1999 05:56


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