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 unsteady velocity inlet

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 1 Post By chem engineer
  • 2 Post By `e`
  • 1 Post By chem engineer
  • 2 Post By upeksa

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2015, 03:16
Default UDF for unsteady velocity inlet
  #1
Member
 
Lida
Join Date: Apr 2015
Posts: 39
Rep Power: 11
chem engineer is on a distinguished road
Hello everyone,
I'm new and amateur in the world of CFD and fluent and I should use a udf for a velocity inlet in a cylindrical pipe.the velocity inlet follow a step function as is described:
for (t=time) t<10 v=6.5*(1-r/3.5)^(1/7)
t>10 v=0
I don't know how to write a step function.

does anyone can help me?
Thank you in advance
Akash Siddique likes this.
chem engineer is offline   Reply With Quote

Old   April 11, 2015, 03:54
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Here's a start with the structure of the code, add in your velocity profile equation and you're set.

Code:
#include "udf.h"

DEFINE_PROFILE(unsteady_velocity_profile, t, i)
{
    real current_time;
    face_t f;
    current_time = CURRENT_TIME;

    begin_f_loop(f, t)
    {
        if (current_time < 10.)
        {
            // first period of time
        }
        else
        {
            // second period of time
        }
    }
    end_f_loop(f, t)
}
chem engineer and tooraj like this.
`e` is offline   Reply With Quote

Old   April 12, 2015, 04:17
Default
  #3
Member
 
Lida
Join Date: Apr 2015
Posts: 39
Rep Power: 11
chem engineer is on a distinguished road
Quote:
Originally Posted by `e` View Post
Here's a start with the structure of the code, add in your velocity profile equation and you're set.

Code:
#include "udf.h"

DEFINE_PROFILE(unsteady_velocity_profile, t, i)
{
    real current_time;
    face_t f;
    current_time = CURRENT_TIME;

    begin_f_loop(f, t)
    {
        if (current_time < 10.)
        {
            // first period of time
        }
        else
        {
            // second period of time
        }
    }
    end_f_loop(f, t)
}
thank you so much for your answer.
should I use this macro in a main steady state program? and do I need to use two loops for time and location? is the macro i have written and attached here correct?
Attached Images
File Type: jpg Capture.JPG (32.2 KB, 216 views)
tooraj likes this.
chem engineer is offline   Reply With Quote

Old   April 12, 2015, 04:20
Default
  #4
Member
 
Lida
Join Date: Apr 2015
Posts: 39
Rep Power: 11
chem engineer is on a distinguished road
thank you so much for your answer.
should I use this code in a main steady state code? and do I need to use two loops for time and location? is the code i have written correct?


#include "udf.h"

DEFINE_PROFILE(unsteady_velocity_profile, t, i)
{
real current_time;
real x[ND_ND];
real y,u;
face_t f;
current_time = CURRENT_TIME;
begin_f_loop(f, t)
{
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
if (current_time < 10.)
{
u=6.5*(1-y/3.5)^(1/7);
}
else
{
u=0;
}
}
end_f_loop(f, thread)
}
end_f_loop(f, t)
}
chem engineer is offline   Reply With Quote

Old   April 12, 2015, 04:53
Default
  #5
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Don't use two for loops. Set your boundary value with F_PROFILE(f,t,i); setting u=.. has nothing to do with the boundary condition value. Have a read of the UDF Manual for details.
`e` is offline   Reply With Quote

Old   April 12, 2015, 06:28
Default
  #6
Member
 
Lida
Join Date: Apr 2015
Posts: 39
Rep Power: 11
chem engineer is on a distinguished road
Quote:
Originally Posted by `e` View Post
Don't use two for loops. Set your boundary value with F_PROFILE(f,t,i); setting u=.. has nothing to do with the boundary condition value. Have a read of the UDF Manual for details.
according to what I read in UDF manuals, because this pipe is 2D I should define real x[ND_ND] that stand for a 2D array: x[1]=x & x[2]=y. x is the horizontal direction of flow and y is the vertical. I understood my mistake about defining "u" and I used F_PROFILE. so is this new code correct. if it is not would you please write the correct form?

DEFINE_PROFILE(unsteady_velocity_profile, t, i)
{
real current_time;
real x[ND_ND];
real y;
face_t f;
current_time = CURRENT_TIME;
begin_f_loop(f, t)
{
F_CENTROID(x,f,t);
y = x[1];
if (current_time < 10.)
{
F_PROFILE(f,t,i)=6.5*(1-y/3.5)^(1/7);
}
else
{
F_PROFILE(f,t,i)=0;
}
}
end_f_loop(f, t)
}
chem engineer is offline   Reply With Quote

Old   April 12, 2015, 06:34
Default
  #7
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
This code is looking good, have you tried compiling and running this boundary condition profile?
`e` is offline   Reply With Quote

Old   April 12, 2015, 07:25
Default
  #8
Member
 
Lida
Join Date: Apr 2015
Posts: 39
Rep Power: 11
chem engineer is on a distinguished road
Quote:
Originally Posted by `e` View Post
This code is looking good, have you tried compiling and running this boundary condition profile?
I tried to compile it but I faced this error:

1 file(s) copied.
The system cannot find the file specified.
(system "copy C:\Fluent.Inc\fluent6.3.26\src\makefile_nt.udf libudf\ntx86\2ddp\makefile")
1 file(s) copied.
(chdir "libudf")()
(chdir "ntx86\2ddp")()
'nmake' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.

Done.
"C:/Users/LIDA/Desktop"

Opening library "libudf"...
Error: open_udf_library: The system cannot find the file specified.

Error Object: ()

as far as I searched and found, I should use Microsoft visual Studio program to compile it.but I haven't install it yet.
chem engineer is offline   Reply With Quote

Old   April 12, 2015, 08:09
Default
  #9
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Yea, you require a compiler such as Microsoft Visual Studio contains for compiling UDFs. Otherwise try interpreting this UDF (it may not require compiling).
`e` is offline   Reply With Quote

Old   April 12, 2015, 08:55
Default
  #10
Member
 
Lida
Join Date: Apr 2015
Posts: 39
Rep Power: 11
chem engineer is on a distinguished road
Quote:
Originally Posted by `e` View Post
Yea, you require a compiler such as Microsoft Visual Studio contains for compiling UDFs. Otherwise try interpreting this UDF (it may not require compiling).
I faced this error while interpreting it:

cpp -I"C:\Fluent.Inc\fluent6.3.26/src" -I"C:\Fluent.Inc\fluent6.3.26/cortex/src" -I"C:\Fluent.Inc\fluent6.3.26/client/src" -I"C:\Fluent.Inc\fluent6.3.26/multiport/src" -I. -DUDFCONFIG_H="<udfconfig.h>" "C:\Users\LIDA\Desktop\inlet.c"
Error: C:\Users\LIDA\Desktop\inlet.c: line 12: thread: undeclared variable

I don't know what does it mean and also if it can be solved or not.
chem engineer is offline   Reply With Quote

Old   April 12, 2015, 19:25
Default
  #11
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by chem engineer View Post
Error: C:\Users\LIDA\Desktop\inlet.c: line 12: thread: undeclared variable

I don't know what does it mean and also if it can be solved or not.
Your error has provided the error type (undeclared variable, you should declare variables before using them) and where it has occurred (line 12 of inlet.c: your UDF?).
`e` is offline   Reply With Quote

Old   April 13, 2015, 03:37
Default
  #12
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 12
upeksa is on a distinguished road
the line:

F_PROFILE(f,t,i)=6.5*(1-y/3.5)^(1/7);

is wrong.

Use:
F_PROFILE(f,t,i)=6.5*pow((1-y/3.5),(1/7)) ;
chem engineer and Oula like this.
upeksa is offline   Reply With Quote

Old   August 9, 2015, 12:52
Default
  #13
New Member
 
tooraj
Join Date: Aug 2015
Posts: 1
Rep Power: 0
tooraj is on a distinguished road
hello every one
i have two formolas and i want to write them in c+


the inlet velocity in the z direction from 0 to the prabolic profile
V(r)= 4.5 ( (r+0.1mm)/0.2mm)(1-(r+0.1mm)/0.2mm)
during the 2µs. the velocity is then v(r) for 10µs and finally decreases to 0 another 2µs the time dependent velocity profile in the z direction can then be defined as:
v(r,t)=(step(t-1.〖10〗^(-6))-step(t-13.〖10〗^(-6))).v(r)
where t is given in seconds and step(t) is a smooth step function

PLEASE help me


i wrote this but fluent cant run it:

#include "udf.h"

DEFINE_PROFILE( unsteady_velocity_profile, t, i,r,t,v,a,b,total,)
{
real current_time;
real x[ND_ND];
real y;
face_t f;
current_time = CURRENT_TIME;
begin_f_loop(f, t)
{
F_CENTROID(x,f,t);
y = x[1];
if (current_time < 10.)
{
F_PROFILE(f,t,i)=4.5*pow[(y+(0.1*0.001))/(0.2*0.001)]*[1-((y+(0.1*0.001))/0.2*0.001))];
}
"a event folat from 0 through 200*0.001
for(i=0;i<=200*0.001;i+=0.000001)
{
a+=i;
}
cout<<"sum in step one is"<<a;
"b even float from 0 through 200*0.001
for(i=0;i<=200*0.001;i+=13*0.000001)
{
b+=i;
}
cout<<"sum in step two is"<<b;
v total=(a-b)*v;
cout<<"total is:"<<total<<end l;
}
tooraj 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: Change boundary condition. Velocity inlet to pressure inlet at time "t" jpina FLUENT 10 April 11, 2015 14:19
UDF for 3D rectangular Inlet velocity Mohammed Attya Fluent UDF and Scheme Programming 0 January 28, 2015 13:18
(UDF) Sinusoidal inlet velocity in Fluent star Fluent UDF and Scheme Programming 1 December 19, 2013 16:23
Fluent UDF load and apply inlet velocity b.c. Knut Lehmann Main CFD Forum 2 June 29, 2007 04:53
Urgent! Help on UDF to set inlet velocity Ray Hong FLUENT 4 December 30, 2005 12:32


All times are GMT -4. The time now is 23:03.