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

Problem using UDF for velocity inlet

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 12, 2018, 10:10
Default Problem using UDF for velocity inlet
  #1
New Member
 
Join Date: Jun 2018
Posts: 7
Rep Power: 8
panasonic18 is on a distinguished road
Hey,



i've real big problem using an UDF for velocity inlet and can't solve it. It's a Mesh over an Airfoil created with ANSYS ICEM 15.0. When i load the Mesh into FLUENT 15.0 everything is fine, no errors.



Hybrid Initialisation is well without using the UDF, so no Errors without using the UDF.



But when i want to implement the UDF and press Hybrid Initialisation, FLUENT says this:



Error: %prf-set-var: invalid flonum
Error Object: -1.#ind


I can't figure out, where the problem is. Also never heard this error before and searching via google wasn't succesfull. So maybe someone coul help me? Here my defined UDF:




#include "udf.h"

#define c_max 30.88 // unit m/s
#define delta 0.04
DEFINE_PROFILE(inlet_velocity, t, i)
{
real x[3];
real y;
face_t f;

begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
y = x[2];

if(x[2] <delta)

F_PROFILE(f,t,i) = c_max * pow(x[2]/delta, 0.2);

else

F_PROFILE(f,t,i) = c_max;
}
end_f_loop(f,t)

}


I appreciate every kind of help.



Best regards
panasonic18 is offline   Reply With Quote

Old   June 12, 2018, 22:55
Default
  #2
Senior Member
 
teguhtf's Avatar
 
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18
teguhtf is on a distinguished road
Dear panasonic18

I think there are mistakes. You define real x[3] but you do not use x[3] in your whole code. you have already written y = x[2] so I think no need to write again x[2] in if(x[2] <delta). Just write if(y <delta). The same case can be applied also in pow(x[2]/delta, 0.2).

For the comment in

#define c_max 30.88 // unit m/s

you should write

#define c_max 30.88 /* unit m/s */

Hope it helps
__________________
Now Or Never!!!
teguhtf is offline   Reply With Quote

Old   June 13, 2018, 03:59
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The line with x[3] is correct, don't change it to x[2]. It signals that x is a three-dimensional array. Better is to change it to x[ND_ND].


I think the real problem (apart from the comment-problem after #define) is that you might take a non-integer exponent of a negative number



If you have a cell with negative y-coordinate, for example y=-0.04, then you calculate:
Code:
pow(-1, 0.2)
A negative number to a non-integer exponent results generally speaking in a complex result. C does not handle this, and gives an error. Here, because 0.2=1/5, it happens to mathematically give a real result, but still you get an error.


If this is really what you want, then you should help the compiler:


Code:
if (x[2]<0) {
  F_PROFILE(f,t,i) = -c_max * pow(-x[2]/delta, 0.2);
} else {
 F_PROFILE(f,t,i) = c_max * pow(x[2]/delta, 0.2);
}
pakk 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 problem- time dependent temperature at inlet kaeran FLUENT 1 June 16, 2015 22:48
Open channel (inlet problem) burak_ekmekci Main CFD Forum 0 December 22, 2014 08:45
UDF profile: Fluent method for coupling inlet and outlet I-mech Fluent UDF and Scheme Programming 0 May 10, 2014 11:36
UDF problem : inlet velocity in cyl. coord. system Jongdae Kim FLUENT 0 June 15, 2004 12:21
UDF 3D inlet b.c. problem Andrew FLUENT 4 May 25, 2004 05:24


All times are GMT -4. The time now is 11:07.