
[Sponsors] 
August 22, 2011, 03:51 
UDF in Cylindrical Coordinate

#1 
New Member
Masoud Hassani
Join Date: Aug 2011
Posts: 3
Rep Power: 12 
Hi guys,
I am a newbie in UDF world and I need some help for a simple UDF problem. I have a 3d turbo setup and i need to have tangential velocity profile in inlet as a function of "r" in cylindrical coordinate. I had no idea about C programing and UDF so I used Fluent sample for inlet boundary and changed it to this: #include "udf.h" DEFINE_PROFILE(T_velocity,thread,index) { real x[ND_ND]; real y[ND_ND]; real xx; real yy; face_t f; begin_f_loop(f,thread) /* loops over all faces in the thread passed in the DEFINE macro argument */ { F_CENTROID(y,f,thread); yy = y[1]; F_CENTROID(x,f,thread); xx = x[1]; F_PROFILE(f,thread,index) = 0.00002*(xx*xx+yy*yy)*10000000.028*sqrt(xx*xx+yy*yy)*1000+11.565; } end_f_loop(f,thread) } Clearly it did not work because I did not know what I was doing!!! please helpme to change this UDF to give me velocity in cylindrical coordinate as "0.00002*r^2*10000000.028*r*1000+11.565" where "r" is radial distance from 0,0,0 Thank you 

August 22, 2011, 06:46 

#2 
New Member
Join Date: Aug 2011
Posts: 5
Rep Power: 12 
If I am not mistaken the;
F_CENTROID(x,f,thread) Should give you the x,y,z coordinates for the cell such as; x[0] = x x[1] = y x[2] = z 

August 22, 2011, 07:43 

#3 
New Member
Masoud Hassani
Join Date: Aug 2011
Posts: 3
Rep Power: 12 
Thank you so much! It is so easy


April 18, 2012, 07:55 

#4 
New Member
Aydın Dönmez
Join Date: Feb 2012
Posts: 4
Rep Power: 11 
i also have to define a parabolic tangential profile but the velocity values computed by the udf does not match with the real values. help please!
#include "udf.h" DEFINE_PROFILE(velocity_profile,t,i) { real x[ND_ND]; /* this will hold the position vector */ real r,R,omega; face_t f; R=0.1; omega=20; begin_f_loop(f,t) { F_CENTROID(x,f,t); r=sqrt((x[0]*x[0])+(x[1]*x[1])); F_PROFILE(f,t,i) = (omega*R*R/r)*(1exp(r*r/R*R)); } end_f_loop(f,t) } 

January 4, 2018, 08:54 
UDF Fluent

#5 
New Member
hiba
Join Date: Jan 2018
Posts: 5
Rep Power: 6 
Hello
I have a problem in my UDF fluent. I need to create a heat flux boundary condition in cylindrical coordinate as a function of "r": flux= 650 000 exp(96 r) . Please can you help me . Thank you in advance. #include "udf.h" DEFINE_PROFILE(wallheatgenerate, thread, position) {face_t f; real x[ND_ND]; real y ; real z[ND_ND]; real w ; real r[ND_ND]; begin_f_loop(f, thread) { F_CENTROID(z,f,thread); w = z[0]; F_CENTROID(x,f,thread); y = x[0]; F_CENTROID(r,f,thread); r=y*y+w*w F_PROFILE(f, thread, position) = 650 000 exp(96 r) .; } end_f_loop(f, thread) } 

January 5, 2018, 05:49 

#6 
Senior Member
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24 
What is "r"? Should it be the square root of (x^2+y^2)? Or the square root of (x^2+y^2+z^2)?
Furthermore, look at the comment of Erny of August 22, 2011 10:46, above. You are using "F_CENTROID" three times, but one time is enough, you only need to find the location once. And if you write this: Code:
650 000 exp(96 r) . Finally: put a semicolon ( ; ) at the end of each line. Not a dot ( . ) . 

January 5, 2018, 06:06 

#7 
New Member
hiba
Join Date: Jan 2018
Posts: 5
Rep Power: 6 
Think you pakk for your interest
r=x²+ z² I'm using "F_CENTROID" once time but i found the same problem. #include "udf.h" DEFINE_PROFILE(wallheatgenerate, thread, position) {face_t f; real x[ND_ND]; real y ; real z[ND_ND]; real w ; real r[ND_ND]; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); y = x[0]; r=y*y+w*w F_PROFILE(f, thread, position) = 650 000 exp(96 r); } end_f_loop(f, thread) } Please help me 

January 5, 2018, 06:09 

#8 
Senior Member
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24 
Read the rest of my post. I told you everything you need to know to solve your problem.


January 5, 2018, 06:14 

#9 
New Member
hiba
Join Date: Jan 2018
Posts: 5
Rep Power: 6 
For this UDF, the same problem
#include "udf.h" DEFINE_PROFILE(wallheatgenerate, thread, position) {face_t f; real x[ND_ND]; real y ; real z[ND_ND]; real w ; real r[ND_ND]; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); y = x[0]; r=y*y+w*w F_PROFILE(f, thread, position) = 650 000* exp(96* r); } end_f_loop(f, thread) } 

January 5, 2018, 06:30 

#10 
New Member
hiba
Join Date: Jan 2018
Posts: 5
Rep Power: 6 
my problem is to define the radius of the cylinder "r=x²+z²" and to create the function of the flux distribution according to the cylinder radius because in fluent there is that the cartesian coordinates.
Think you for your comments, I well understand the ";" and "*" 

January 5, 2018, 07:41 

#11 
Senior Member
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24 
Code:
#include "udf.h" DEFINE_PROFILE(wallheatgenerate, thread, position) {face_t f; real x[ND_ND]; real y ; real z[ND_ND]; real w ; real r[ND_ND]; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); y = x[0]; r=y*y+w*w F_PROFILE(f, thread, position) = 650 000* exp(96* r); } end_f_loop(f, thread) } Code:
real coordinates[ND_ND]; ... F_CENTROID(coordinates,f,thread); 2. Why do you still no use a semicolon in your calculation of radius? 3. Why do you not use the square root in your calculation of radius? 4. Why do you write "650 000" with a space in between? The compiler does not understand what you mean by this, it just sees two numbers (650 and 0) directly behind each other. 

January 5, 2018, 07:49 

#12 
New Member
hiba
Join Date: Jan 2018
Posts: 5
Rep Power: 6 
Thank you very much pakk for your interest and your help. I well understand you.


January 11, 2018, 00:53 
Request for guidance about UDF DEFINE_PROFILE

#13  
New Member
Masroor
Join Date: Nov 2015
Posts: 9
Rep Power: 8 
Quote:
Hope you will be fine and healthy while reading this message I have written a UDF for gas volume fraction at inlet boundary of a 3D cylinder. When I try to compile the UDF in ansys fluent I receive a message and it fails to be compliled. The message is "The UDF library you are trying to load (libudf) is not compiled for 3d on the current platform (win64). The system cannot find the file specified. C:\Users\Masroor\Desktop\Nonuniform holdup at boundary condition\libudf\win64\3d\libudf.dll" Then I tried to interpret the UDF and received the following error "Error: C:\\Users\\Masroor\\Desktop\\Nonuniform holdup at boundary condition\\nonuniform gas holdup at inlet3.c: line 49: parse error. Error: C:\\Users\\Masroor\\Desktop\\Nonuniform holdup at boundary condition\\nonuniform gas holdup at inlet3.c: line 50: f: undeclared variable " I need your expert and valuable suggestions and guidance to overcome that problem. Below this I am pasting the .c code /****************************************** Customized gas holdup at inlet *******************************************/ #include "udf.h" #define VG 0.044 /* constants */ #define D 0.12 #define R 0.06 #define ST 0.0732 #define AVGH 0.184 #define RHOL 998.2 #define RHOG 1.225 #define MUL 0.001003 #define G 9.81 DEFINE_PROFILE(air_vof_profile,t,i) { real r, a, rho, m, reyp, Fr, Mo, coeff, wholdup; real x[ND_ND]; real z; z = x[2]; /*compute rho*/ rho = RHOL  RHOG; /*compute Reynold's number*/ reyp = D*VG*rho/MUL; /*compute Fr number*/ Fr = pow(VG,2)/(G*D); /*compute Mo number*/ Mo= G*pow(MUL,4)*(rho)/(pow(0.0732,3)*pow(RHOL,2)); /*compute m*/ m = 2.188*(pow(reyp,0.598))*pow(Fr,0.146)*pow(Mo,0.004); /*compute a*/ a = (m+2)/m; /*compute coeff*/ coeff = 4.32*(pow(reyp,0.2492))/100; /*compute r*/ r = sqrt((x[0]*x[0])+(x[2]*x[2])); /*compute wholdup*/ wholdup = 1coeff*(r/R); face_t f; begin_f_loop(f, t) { F_CENTROID(x, f, t); F_PROFILE(f,t,i) = a*(AVGHwholdup)*(1(pow((r/R),m)+wholdup; } end_f_loop(f,t) } Your cooperation will highly be appreciated. Thanking you in advance and looking forward to receive a positive and quick response from your side. 

January 11, 2018, 04:39 

#14  
Senior Member
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24 
Quote:
Probably you also got a message when you tried to compile, but it did not come up in a separate screen, but was written to the normal TUI field. Read there... Quote:
These lines are: Code:
[49] face_t f; [50] begin_f_loop(f, t) The error for line 50 means "You use "f", but I don't know what "f" is." You try to define "f" in line 49, so because Fluent does not know what you mean, it can not use "f" in line 50. This suggests that fixing the error for line 49 will also fix the error for line 50. This is usually the case: if you get a series of errors/warnings, focus on the first one. And the reason that you get errors: in this version of C, you are supposed to declare variables at the beginning of a function, not halfway. So, move your line 49 higher up in your code, to where you declare the rest of your variables (lines 18 to 20). You might find additional problems because your folder has a space in its name. Better to avoid these. This *should* not be a problem, but the Fluent programmers did not program this properly. 

January 11, 2018, 06:05 
Request for guidance about UDF DEFINE_PROFILE

#15  
New Member
Masroor
Join Date: Nov 2015
Posts: 9
Rep Power: 8 
Quote:
Thank you for your quick reply. I resolved that error and got my UDF complied, but this does not give the value which is desirable. There should be a nonuniform gas volume fraction at at inlet, but it gives a constant value throughout the inlet face and that value is 0.1..... I am confused with loop, if the value is not changing that means loop fails to work in UDF. I am pasting here the revised UDF that was complied but failed to get the result I want. Your help is needed Once again thank you /****************************************** Customized gas holdup at inlet *******************************************/ #include "udf.h" #define FLUID_ID 12 /* constants */ #define VG 0.044 #define D 0.12 #define R 0.06 #define ST 0.0732 #define AVGH 0.184 #define RHOL 998.2 #define RHOG 1.225 #define MUL 0.001003 #define G 9.81 DEFINE_PROFILE(air_vof_profile,t,i) { face_t f; real r, a, rho, m, reyp, Fr, Mo, coeff, n, wholdup; real x[ND_ND]; real X, Z; X = x[0]; Z = x[2]; /*compute rho*/ rho = (RHOL  RHOG); /*compute Reynold's number*/ reyp = D*VG*rho/MUL; /*compute Fr number*/ Fr = (pow(VG,2))/(G*D); /*compute Mo number*/ Mo= G*(pow(MUL,4))/(rho*(pow(ST,3))); /*compute m*/ m = 2188*(pow(reyp,0.598))*(pow(Fr,0.146))*(pow(Mo,0.004)); /*compute a*/ a = (m+2)/m; /*compute coeff*/ coeff = 0.0432*(pow(reyp,0.2492)); /*compute r*/ r = sqrt(X*X + Z*Z); /*compute n*/ n = r/R; /*compute wholdup*/ wholdup = 1  (coeff*(pow(n,m))); begin_f_loop(f, t) { F_CENTROID(x,f,t); F_PROFILE(f,t,i) = a*(AVGHwholdup)*(1(pow(n,m))) + wholdup; } end_f_loop(f, t) } 

January 11, 2018, 06:34 

#16 
Senior Member
Join Date: Nov 2013
Posts: 1,969
Rep Power: 24 
It is because your equations are a function of position. So you should recalculate them for every position. Instead, you calculate your equations before you go into the loop...
I think this could work: Code:
DEFINE_PROFILE(air_vof_profile,t,i) { face_t f; real r, a, rho, m, reyp, Fr, Mo, coeff, n, wholdup; real x[ND_ND]; real X, Z; /*compute rho*/ rho = (RHOL  RHOG); /*compute Reynold's number*/ reyp = D*VG*rho/MUL; /*compute Fr number*/ Fr = (pow(VG,2))/(G*D); /*compute Mo number*/ Mo= G*(pow(MUL,4))/(rho*(pow(ST,3))); /*compute m*/ m = 2188*(pow(reyp,0.598))*(pow(Fr,0.146))*(pow(Mo,0.004)); /*compute a*/ a = (m+2)/m; /*compute coeff*/ coeff = 0.0432*(pow(reyp,0.2492)); begin_f_loop(f, t) { /*compute r*/ F_CENTROID(x,f,t); X = x[0]; Z = x[2]; r = sqrt(X*X + Z*Z); /*compute n*/ n = r/R; /*compute wholdup*/ wholdup = 1  (coeff*(pow(n,m))); F_PROFILE(f,t,i) = a*(AVGHwholdup)*(1(pow(n,m))) + wholdup; } end_f_loop(f, t) } 

January 12, 2018, 02:13 
Nonuniform gas volume fraction at inlet boundary

#17 
New Member
Masroor
Join Date: Nov 2015
Posts: 9
Rep Power: 8 
Hi,
First of all I would thank you for your expert suggestions. I adopted this strategy and got the required profile at inlet. Now I have problem with simulation. I used that UDF for gas vol fraction at inlet which resulted some volume fraction of liquid also at that boundary. Depending upon requirement of simulation, I kept the Velocity of liquid equal to 0, because it is a semi batched column with liquid already patahced in the domain. When I started calculation, I found reversed flow at many faces of outlet. The outlet was set as pressure outlet. After very few time steps, the Fluent exited itself (mean the simulation failed to proceed). I am confused whether the problem is associated with UDF or boundary conditions? Your suggestions are required. Thank you very much in advance 

January 12, 2018, 06:04 
Request for guidance about UDF DEFINE_PROFILE

#18  
New Member
Masroor
Join Date: Nov 2015
Posts: 9
Rep Power: 8 
Quote:
Hi, First of all I would thank you for your expert suggestions. I adopted this strategy and got the required profile at inlet. Now I have problem with simulation. I used that UDF for gas vol fraction at inlet which resulted some volume fraction of liquid also at that boundary. Depending upon requirement of simulation, I kept the Velocity of liquid equal to 0, because it is a semi batched column with liquid already patahced in the domain. When I started calculation, I found reversed flow at many faces of outlet. The outlet was set as pressure outlet. After very few time steps, the Fluent exited itself (mean the simulation failed to proceed). I am confused whether the problem is associated with UDF or boundary conditions? Your suggestions are required. Thank you very much in advance 

October 20, 2019, 19:09 

#19 
New Member
Nourhan Bahgat
Join Date: Aug 2019
Posts: 13
Rep Power: 4 
Please I have an excel sheet for heat flux change with angle around absorber , how write it as a udf code in fluent to use it as a boundary condition for external wall


Tags 
cylindrical, inlet, udf 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
cylindrical coordinate vs cartesian coordinate  Lam  FLUENT  10  May 11, 2013 14:05 
cylindrical coordinate Gambit  noussa  ANSYS Meshing & Geometry  2  June 12, 2010 10:07 
CFD Software with Cylindrical and Spherical Coordinate  cfd2010  Main CFD Forum  0  June 9, 2010 22:55 
cartesian to cylindrical coordinate UDF  Manoj  FLUENT  0  December 15, 2005 10:43 
Cording Ground.for in Cylindrical coordinate  J.H. Lee.  Phoenics  2  March 28, 2003 05:28 