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

UDF : velocity, k and epsilon (radial profile)

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 19, 2013, 06:03
Question UDF : velocity, k and epsilon (radial profile)
  #1
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
Hello,

I am an user of FINE/Open. I would like to make a comparison with Fluent. Therefore, I need a little help in Fluent:

I have a radial profile (in inlet) for speed, k and epsilon. And I'd like to define an UDF. Is it possible to give a profile of a distance and say that the problem is cylindrical in an UDF? (To simplify the problem).

To complicate matters, my inlet surface is divided into two inlet in Fluent (I imported the Hexpress mesh to Gambit and I could not merge the surfaces).


Thanks a lot !
cdiako is offline   Reply With Quote

Old   July 19, 2013, 06:28
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
You can use the
Code:
DEFINE_PROFILE
macro.
blackmask is offline   Reply With Quote

Old   July 19, 2013, 06:35
Default
  #3
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
Can you give me a little example?
For example, if I have a velocity profile:

for r = 0, v = 25 m / s
r= 0.02m = r v = 10 m / s
r = 0.03 m, v = 0.5 m / s
r = 0.2 m, v = 0 m/s
cdiako is offline   Reply With Quote

Old   July 19, 2013, 07:11
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
For simplicity, I assume that the velocity profile is piece-wise constant.

Code:
#include "udf.h"
DEFINE_PROFILE(inlet_axial_velocity, thread, position)
{
real orig[ND_ND] = {1.0, 2.0, 3.0};
real x[ND_ND];
face_t f;
real r;
real v;

begin_f_loop(f,thread)
{
F_CENTROID(x, f, thread);
NV_VV(x,=,x,-,orig);
r = NV_MAG(x);
if ( r < 0.02) {
v = 25.0;
} else if ( r < 0.03) {
 v = 10.0;
} else if ( r < 0.2) {
 v = 0.5;
} else {
 v = 0.0;
}
F_PROFILE(f, thread, position) = v;
}
end_f_loop(f, thread)
}
blackmask is offline   Reply With Quote

Old   July 19, 2013, 09:23
Default
  #5
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
Ok, thank you very much ! I must just read a little about commands that you used in the code.

I may come back with some questions in a few days
cdiako is offline   Reply With Quote

Old   July 19, 2013, 11:10
Default
  #6
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
I have a small question about the line

real orig [ND_ND] = ...

if the inlet face has a distance on 0.06m (on the z axis) above the origin. I can replace our line by :

static const real origin [3]= {0.0; 0.0; 0.06}

it's correct?

Thank you again for the help !
cdiako is offline   Reply With Quote

Old   July 19, 2013, 11:16
Default
  #7
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Yes, and
r = NV_MAG(x);
should be replaced by
r = sqrt(x[0]*x[0]+x[1]*x[1]);
I made a mistake in my previous post.
blackmask is offline   Reply With Quote

Old   July 19, 2013, 11:22
Default
  #8
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
Ok, thank you! I didn't see the fault.
cdiako is offline   Reply With Quote

Old   July 19, 2013, 11:27
Default
  #9
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
I took r as the distance between x and the origin in my #4 post, i.e., r=|X-O|. But in fact r should be the length of projection of the vector <X-O> onto the (r, theta) plane, that's why x[2] vanishes in #7.
blackmask is offline   Reply With Quote

Old   July 19, 2013, 11:33
Default
  #10
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
Yes yes, I understood. I meant that I hadn't seen the fault before you say it.
cdiako is offline   Reply With Quote

Old   July 19, 2013, 12:21
Default
  #11
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
And just a last thing : you have simplify the case, but if we want to interpolate the velocity, we must use a loop or there is another possibility (a function) ?
cdiako is offline   Reply With Quote

Old   July 19, 2013, 22:02
Default
  #12
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Yes, you simply change
F_PROFILE(f, thread, position) = v;to
F_PROFILE(f, thread, position) = some_func(r);where
Code:
real some_func(real r) {
real vel;
real r0[] = {0.0, 0.02, 0.03, 0.20};
real v0[] = {25.0, 20.0, 10.0, 0.00};
// interpolation the value of vel at r 
return vel;
}
blackmask is offline   Reply With Quote

Old   July 20, 2013, 12:15
Default
  #13
Member
 
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 13
str6073 is on a distinguished road
hi guys
i need a udf for a work. i'll explain what i need . I want to provide a linear varying temperature boundary condition on the circular side of a cylinder . can you help me?? My idea about udf is very small. diameter of cylinder is 41.3 mm . temperature may vary from 25 to 50 degrees
str6073 is offline   Reply With Quote

Old   July 22, 2013, 06:37
Default
  #14
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
@blackmask : Thank you ! can you tell me if the code is correct?

#include "udf.h"

real some_func(real r)
{
real vel;
real r0[] = {0.0, 0.02, 0.03, 0.20};
real v0[] = {25.0, 20.0, 10.0, 0.00};
int j=0;
int i=0;

while(i<=ND_ND)
{

if(r==0)
{
vel[i]=v0[0];
}

if(r<0.2)
{
while (r<r0[j])
{
j++;
}
vel[i]=((v0[j+1]-v0[j])/(r0[j+1]-r0[j]))*(r-r0[j])+v0[j];
}

else
{
vel[i]=0;
}

i++;

}

return vel;
}


DEFINE_PROFILE(inlet_axial_velocity, thread, position)
{
static const real orig[3]={0.0, 0.0, 0.06};
real x[ND_ND];
face_t f;
real r;
real v;
int i=0;

begin_f_loop(f,thread)
{
F_CENTROID(x, f, thread);
NV_VV(x,=,x,-,orig);
r = sqrt(x[0]*x[0]+x[1]*x[1]);
F_PROFILE(f, thread, position) = some_func(r);
}
end_f_loop(f, thread)
}

@ str6063 : I started too. So, I do not know how to help you.
cdiako is offline   Reply With Quote

Old   July 22, 2013, 21:55
Default
  #15
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
A linear interpolation could be implemented as follows:
Code:
#include "udf.h"

real some_func(real r)
{
        real vel;
        real r0[] = {0.0, 0.02, 0.03, 0.20};
        real v0[] = {25.0, 20.0, 10.0, 0.00};
        int i=0;

        if ( r >= r0[3] ) return 0.0;
        while( r >= r0[++i]) ;

        return v0[i-1]+(v0[i] - v0[i-1])/(r0[i] - r0[i-1]);

}


DEFINE_PROFILE(inlet_axial_velocity, thread, position)
{
        static const real orig[3]={0.0, 0.0, 0.06};
        real x[ND_ND];
        face_t f;
        real r;
        real v;

        begin_f_loop(f,thread)
        {
                F_CENTROID(x, f, thread);
                NV_VV(x,=,x,-,orig);
                r = sqrt(x[0]*x[0]+x[1]*x[1]);
                F_PROFILE(f, thread, position) = some_func(r);
        }
        end_f_loop(f, thread)
}
blackmask is offline   Reply With Quote

Old   July 23, 2013, 05:10
Default
  #16
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
Thank you again !

Juste to be sure, I think that there is two mistake :

1) the 4 int the two vector : real r0[4]={...};
2) the second return : I think, it must be :

return return v0[i-1]+((v0[i] - v0[i-1])/(r0[i] - r0[i-1]))*(r-r0[i-1]);

and for k and epsilon, I suppose that is exactly the same ?

And now, I have an other question : In my domain, I have a fluid part and a solid part. In the solid, I'd like inserting a localized heat source in terms of x, y and z. Is this possible? (and in the definition of the coordinates, it slightly exceeds? eg, due to an imprecise geometry, my x-coordinate exceeds of 1 mm, how Fluent work? ) Can you help me ?

Thank you again for your help !
cdiako is offline   Reply With Quote

Old   July 23, 2013, 05:16
Default
  #17
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
(I forgot to say that I want to insert the heat source in the solid)
cdiako is offline   Reply With Quote

Old   July 23, 2013, 05:30
Default
  #18
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
#16
1) c array is zero-based so that the last index in the array is length of array minus one
2) you are right, I forget the (r - r0[i-1]) term

You can use
Code:
FLUID_THREAD_P
blackmask is offline   Reply With Quote

Old   July 23, 2013, 05:43
Default
  #19
New Member
 
Join Date: Jul 2013
Posts: 21
Rep Power: 13
cdiako is on a distinguished road
You can help me to construct the udf ? if I have this coordonates for the heat source :

- x : x=0 to 0.001
- y : y=0 to 0.0015
- z : z=0.001 to 0.00012

vol=0.001*0.0015*0.0002;
HT=10/vol;

thanks a lot !
cdiako is offline   Reply With Quote

Old   July 23, 2013, 06:03
Default
  #20
Member
 
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 13
str6073 is on a distinguished road
hi
i need a udf for a work. i'll explain what i need . I want to provide a linear varying temperature boundary condition on the circular side of a cylinder . can you help me?? My idea about udf is very small. diameter of cylinder is 470mm. temperature may vary from 25 to 50 degrees from botom to top
str6073 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 inlet velocity profile Bollonga Fluent UDF and Scheme Programming 4 June 29, 2021 05:40
SimpleFoam k and epsilon bounded nedved OpenFOAM Running, Solving & CFD 16 March 4, 2017 09:30
UDF to define velocity, k, epsilon profiles at velocity-inlet aerospain FLUENT 0 July 8, 2011 08:14
SimpleFoam k and epsilon bounded nedved OpenFOAM Running, Solving & CFD 1 November 25, 2008 21:21
UDF velocity profile problem Steve FLUENT 0 January 18, 2005 13:11


All times are GMT -4. The time now is 16:09.