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

UDF for perpertual velocity step change

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 17, 2014, 04:55
Default UDF for perpertual velocity step change
  #1
New Member
 
Wanda Selamat
Join Date: Oct 2013
Posts: 1
Rep Power: 0
romanpicisan is on a distinguished road
Hi, I am working on a UDF to mimic a daily water flow in pipe for a year period. Water will start flowing from 9:00 am (32400 s + 86400 x day) until 6:00 pm (64800 s + 86400 x day) daily at a velocity of 0.0562 m/s. A velocity ramp in a period of 10 s will be given before start-up and after shut-down of the flow.

The plot (unfinished) of the intended scheme would somewhat look like the attached photo, which was obtained using a UDF by manually inserting the values in the conditions/statements (about 4000 lines). With the help of a spreadsheet to write the lines, it was still manageable.

However, I would like to have a UDF that is simple and robust. I had tried numerous UDF but to no avail. The most promising one that I could come up with is as follows.

I would appreciate if someone can assist me on this. Thanks.

#include "udf.h"

DEFINE_PROFILE(discontinuous_1y,x,i)
{
int t = CURRENT_TIME;
face_t f;
real off = 0, on = 0.0562; //velocity during no-flow and flow
real ramp = 10, v; //ramp time 10 s before flow and after flow is given
real slope = on/ramp; //slope used during ramp time
int start, stop;
int *time;
time = &t;

if(t < 86400) //1 day equals 86400 s
{
if(*time % 86400 == 64800) //9:00 am day-0
start = *time;
else if(*time % 86400 == 43200) //6:00 pm day-0
stop = *time;
}
else
{
if(*time % 86400 == 32400) //9:00 am day-i
start = *time;
else if(*time % 86400 == 64800) //6:00 pm day-i
stop = *time;
}

begin_f_loop(f,x)
{
if(t <= 32400)
v = off;
else if(t <= (start + ramp) && t > start)
v = slope * (t - start);
else if(t <= stop && t > (start + ramp))
v = on;
else if(t <= (stop + ramp) && t > stop)
v = on - slope * (t - stop);
else
v = off;
F_PROFILE(f,x,i) = v;
}
end_f_loop(f,x)
}

DEFINE_DELTAT(deltat_1y,d)
{
int t = CURRENT_TIME;
real tstep, off = 5399, on = 3239, up = 10, down = 2; //time step values
real ramp = 10;
int start;
int stop;
int *time;
time = &t;

if(t < 86400)
{
if(*time % 86400 == 64800)
start = *time;
else if(*time % 86400 == 43200)
stop = *time;
}
else
{
if(*time % 86400 == 32400)
start = *time;
else if(*time % 86400 == 64800)
stop = *time;
}

if(t < 32400)
tstep = 3600;
else if(t < (start + ramp) && t >= start)
tstep = up;
else if(t < stop && t >= (start + ramp))
tstep = on;
else if(t < (stop + ramp) && t >= stop)
tstep = down;
else
tstep = off;
return tstep;
}
Attached Images
File Type: jpg Untitled.jpg (17.7 KB, 9 views)

Last edited by romanpicisan; February 17, 2014 at 10:03.
romanpicisan 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 error - parabolic velocity profile - 3D turbine Zaqie Fluent UDF and Scheme Programming 9 June 25, 2016 19:08
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03
DPM UDF particle position using the macro P_POS(p)[i] dm2747 FLUENT 0 April 17, 2009 01:29
UDF problem : inlet velocity in cyl. coord. system Jongdae Kim FLUENT 0 June 15, 2004 11:21
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


All times are GMT -4. The time now is 18:38.