# Turek-Hron UDF

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

August 7, 2019, 06:29
Turek-Hron UDF
#1
New Member

omid
Join Date: Jun 2019
Posts: 8
Rep Power: 3
Hello i'm trying to write a UDF for this two inlet BCs:
(1.5*4/0.1681)*y*(0.41-y)*(0.5*(1-cos(0.5*Pi*t))) if t<2sec
(1.5*4/0.1681)*y*(0.41-y) otherwise

the UDF i have wrote is like below but it doesn't work correctly because i get the velocity vector like the picture i have attached, and the velocity shouldn't be like that after 2 seconds:

/************************************************** *********************
UDF for specifying transient velocity profile boundary condition
************************************************** **********************/

#include "udf.h"

#define H 0.41
#define PI 3.14

{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;

begin_f_loop(f, thread) /* loops over all faces in the thread passed in the DEFINE macro argument */

{
y = x[1];
{
if(CURRENT_TIME<2)
}
{
if(CURRENT_TIME>=2)
}
}
}
Attached Images
 Capture11.PNG (40.8 KB, 4 views)

 August 8, 2019, 02:31 #2 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,425 Rep Power: 21 try this code Code: ```/************************************************** ********************* UDF for specifying transient velocity profile boundary condition ************************************************** **********************/ #include "udf.h" #define H 0.41 #define PI 3.14 DEFINE_PROFILE(inlet_velocity, thread, index) { real x[ND_ND]; /* this will hold the position vector */ real y; real time; face_t f; time = CURRENT_TIME; begin_f_loop(f, thread) /* loops over all faces in the thread passed in the DEFINE macro argument */ { F_CENTROID(x, f, thread); y = x[1]; { if(time<2) F_PROFILE(f, thread, index) =((1.5*1)*(4/0.1681)*y*(H-y))*((1-cos(PI*time/2))/2); } { if(time>=2) F_PROFILE(f, thread, index) =((1.5*1)*(4/0.1681)*y*(H-y)); } } end_f_loop(f, thread) }``` best regards

 Tags fluent - udf, udf code

 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 03:18 JuanJoMex FLUENT 0 February 8, 2018 13:43 robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 01:53 shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14 Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01

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