
[Sponsors] 
July 19, 2013, 05:03 
UDF : velocity, k and epsilon (radial profile)

#1 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
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 ! 

July 19, 2013, 05:28 

#2 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
You can use the
Code:
DEFINE_PROFILE 

July 19, 2013, 05:35 

#3 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
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 

July 19, 2013, 06:11 

#4 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
For simplicity, I assume that the velocity profile is piecewise 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) } 

July 19, 2013, 08:23 

#5 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
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 

July 19, 2013, 10:10 

#6 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
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 ! 

July 19, 2013, 10:16 

#7 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
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. 

July 19, 2013, 10:22 

#8 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
Ok, thank you! I didn't see the fault.


July 19, 2013, 10:27 

#9 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
I took r as the distance between x and the origin in my #4 post, i.e., r=XO. But in fact r should be the length of projection of the vector <XO> onto the (r, theta) plane, that's why x[2] vanishes in #7.


July 19, 2013, 10:33 

#10 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
Yes yes, I understood. I meant that I hadn't seen the fault before you say it.


July 19, 2013, 11:21 

#11 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
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) ?


July 19, 2013, 21:02 

#12 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
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; } 

July 20, 2013, 11:15 

#13 
Member
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 5 
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 

July 22, 2013, 05:37 

#14 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
@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]))*(rr0[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. 

July 22, 2013, 20:55 

#15 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
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[i1]+(v0[i]  v0[i1])/(r0[i]  r0[i1]); } 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) } 

July 23, 2013, 04:10 

#16 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
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[i1]+((v0[i]  v0[i1])/(r0[i]  r0[i1]))*(rr0[i1]); 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 xcoordinate exceeds of 1 mm, how Fluent work? ) Can you help me ? Thank you again for your help ! 

July 23, 2013, 04:16 

#17 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
(I forgot to say that I want to insert the heat source in the solid)


July 23, 2013, 04:30 

#18 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 12 
#16
1) c array is zerobased so that the last index in the array is length of array minus one 2) you are right, I forget the (r  r0[i1]) term You can use Code:
FLUID_THREAD_P 

July 23, 2013, 04:43 

#19 
New Member
Join Date: Jul 2013
Posts: 21
Rep Power: 4 
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 ! 

July 23, 2013, 05:03 

#20 
Member
sooraj
Join Date: Dec 2012
Posts: 38
Rep Power: 5 
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 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF for inlet velocity profile  Bollonga  Fluent UDF and Scheme Programming  1  October 6, 2015 12:53 
SimpleFoam k and epsilon bounded  nedved  OpenFOAM Running, Solving & CFD  13  November 4, 2013 15:13 
UDF to define velocity, k, epsilon profiles at velocityinlet  aerospain  FLUENT  0  July 8, 2011 07: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 