|
[Sponsors] |
November 20, 2015, 05:45 |
How to use input parameter in UDF?
|
#1 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Hello I have 3D channel flow I wrote a UDF for velocity profile at inlet to get fully developed flow I need to enter average velocity into my UDF as input parameter? How i can do this please? any help is mandatory?
mariam |
|
November 22, 2015, 03:48 |
|
#2 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Nobody know my question?
mariam |
|
November 23, 2015, 08:25 |
|
#3 |
Senior Member
Join Date: Mar 2014
Posts: 375
Rep Power: 13 |
Not sure but the way it sounds "average velocity", I would just use a velocity inlet condition, thats what i suppose it does? why do you even need a UDF for an average profile?
|
|
November 23, 2015, 09:17 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Are you asking us for help on the udf that you wrote? You are the creator, so you should know best how it works...
And anyway, how do you think we can tell you how your own udf works if you don't give us the code? We are not telepathic... |
|
November 23, 2015, 12:38 |
|
#5 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Thanks hwet for the replay. I want use different Uavg values at the udf because I want set different velocities for inlets because I have heat exchanger of two fluids (water and air) contain several inlets for air (its number reach 100) hence I need 100 udf so I just want set Uavg as an input parameter in the udf and let it change inside the udf hope this clear??
|
|
November 23, 2015, 12:45 |
|
#6 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Mr. pakk my question not about the udf and if it working or no. My question about how i can using parameter in udf (see photo)? i need steps how to really applied a parameter to the udf?
|
|
November 25, 2015, 04:34 |
|
#7 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Hi pakk to be more specific I have a UDF which requires a real parameter. Is there a way to give this parameter different values, without having to modify and recompile the udf again? if you want to have a look on the udf i will post it?
|
|
November 25, 2015, 04:42 |
|
#8 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
Code:
(rp-var-define 'tui_alpha 0.05 'real #f) Code:
udf_alpha = RP_Get_Float("tui_alpha"); |
||
November 28, 2015, 16:18 |
|
#9 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Thanks pakk for the valuable answer. Actually I was followed the steps mentioned in user guide and I type the option for my average velocity as below in text interface:
rp-var-define 'Uavg 0.05' real #f the problem when i compile my udf the following error appear to me: Error: rpgetvar: Uave: undefined variable what the problem? knowing i was added the variable in the UDF and here is copy of the full UDF /************************************************** ******************* UDF for specifying steady-state velocity profile boundary condition ************************************************** ********************/ #include"udf.h" /* Geometry description */ #define h 0.002 /*height duct in m */ #define w 0.005 /*weidth duct in m */ #define s 0.004 /*step weidth duct in m */ /*********** **************************** Inlet velocity profile ***************************************/ DEFINE_PROFILE(inlet_z1_velocity,t,i) { real x,z1[ND_ND]; real radx,rady,; real N1,M1,Alfa; real y; face_t f; real Uave=RP_Get_Real("Uave"); Alfa =(w/h); /* Aspect ratio of the inlet duct */ M1 = 1.7 + 0.5 * pow(fabs(Alfa),-1.4); if (Alfa <= (1/3)) N1 = 2.0 ; else { N1 = 2 + 0.3*(Alfa - (1/3)); } /*********************************************/ begin_f_loop(f,t) { F_CENTROID(z1,f,t); y = z1[1]; x = z1[2]; rady = (1.0-pow(fabs(y-h/2)/(h/2),N1)); radx = (1.0-pow(fabs(x-((w/2)+ s))/(w/2),M1)); F_PROFILE(f,t,i) = Uave*((M1+1)/M1)*((N1+1)/N1)*rady*radx; } end_f_loop(f,t) } |
|
November 29, 2015, 06:58 |
|
#10 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
rp-var-define 'Uavg 0.05' real #f
real Uave=RP_Get_Real("Uave"); Then it is not rp-var-define 'Uavg 0.05' real #f but rp-var-define 'Uavg 0.05 'real #f
__________________
Google is your friend and the same for the search button! |
|
November 29, 2015, 14:38 |
|
#11 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Thanks ghost for the reply. I not understand your replay clearly may you tell me what the error with my expression? It seem you wrote similar expression to the one I wrote?
mariam |
|
November 29, 2015, 14:40 |
|
#12 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
You defined Uavg as variable but you call Uave in udf, which is not defined. So, change Uavg to Uave
__________________
Google is your friend and the same for the search button! |
|
November 29, 2015, 16:44 |
|
#13 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
I fixed this error but the current error shown in picture is still appearing to me as soon as i open fluent?? what its reason?
|
|
November 29, 2015, 16:50 |
|
#14 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
Fluent cannot find the libudf folder with compiled udf to load it, nor the .c file to autocompile udf.
Do you have the libudf folder or the .c file in the same folder in which you have the .cas?
__________________
Google is your friend and the same for the search button! |
|
November 29, 2015, 16:59 |
|
#15 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
Cannot find the libudf folder? may you tell me where i can find it please?
|
|
November 29, 2015, 17:03 |
|
#16 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
You start with the cas and .c files in some folder; when you compile the .c file fluent automatically creates the "libudf" folder inside the folder where you have .c and .cas files. Inside the libudf folder there are other folders and your compiled udf. If you don't have the libudf folder fluent searches for the .c file and if it finds it, it will try to automatically recompile the code, recreating the libudf folder.
__________________
Google is your friend and the same for the search button! |
|
December 1, 2015, 02:54 |
don't understand some of the terms in UDF
|
#17 |
Member
|
Can anyone please explain the purpose of the terms used in the following UDF
Code:
#include"udf.h" DEFINE_GRID_MOTION(twist,domain,dt,time,dtime) { Thread *tf = DT_THREAD(dt); face_t f; Node *v; real NV_VEC(axis); real delta,xaxis,yaxis,teta,xn,yn,dx,dy,H; int n; H = 0.1; /*z-dimension of the model*/ teta = 10*3.14/180; /*rotation angle*/ begin_f_loop(f,tf) { f_node_loop(f,tf,n) { v = F_NODE(f,tf,n); /* update node if the current node has not been previously visited when looping through previous faces */ if ( NODE_POS_NEED_UPDATE (v)) { /* indicate that node position has been update so that it's not updated more than once */ NODE_POS_UPDATED(v); xn = cos(teta)*NODE_X(v)-sin(teta)*NODE_Y(v); yn = sin(teta)*NODE_X(v)+cos(teta)*NODE_Y(v); dx = xn-NODE_X(v); dy = yn-NODE_Y(v); xaxis = dx/sqrt(pow(dx,2) + pow(dy,2)); yaxis = dy/sqrt(pow(dx,2) + pow(dy,2)); NV_D(axis, =, xaxis,yaxis, 0.0); delta = sqrt(pow(dx,2) + pow(dy,2))*NODE_Z(v)/H; NV_V_VS(NODE_COORD(v), =, NODE_COORD(v), +, axis,*,delta); } } } end_f_loop(f,tf); } thank you |
|
December 2, 2015, 15:38 |
|
#18 |
Senior Member
Bruno
Join Date: Mar 2009
Location: Brazil
Posts: 277
Rep Power: 21 |
It's math. Everything it does is written there, and the functions (NODE_X(), NODE_Y(), NV_D(), etc) are in the manual.
What don't you understand? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Use Input parameter in the monitor window drag and lift calculation | Anna Tian | FLUENT | 5 | September 1, 2014 21:44 |
parse error while interpreting udf | Kristin | Fluent UDF and Scheme Programming | 3 | March 15, 2012 07:43 |
Tablular values as input to UDF | BS | FLUENT | 0 | March 30, 2008 19:59 |
DEFINE_GEOM UDF Problems | Pat | FLUENT | 0 | August 14, 2003 14:16 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |