|
[Sponsors] |
May 31, 2012, 14:24 |
Problem in UDF compilation
|
#1 |
New Member
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 14 |
here is part of udf, where I am getting error (not defined variable)
# include "udf.h" # define C 0.3 # define diam2 2.e-4 # define Cmu 0.09 DEFINE_EXCHANGE_PROPERTY(modified_drag,cell,mix_th read,s_col,f_col) { Thread*thread_l; Thread*thread_g; real slip_x; real slip_y; real slip_z; real slip; real k_l; real d_l; real mu_t_l; real mu_l; real rho_l; real rho_g; real reyp; real cd; /* liquid phase-primary*/ thread_l=THREAD_SUB_THREAD(mix_thread,s_col); /* gas phase-secondary*/ thread_g=THREAD_SUB_THREAD(mix_thread,f_col); /* slip velocity*/ slip_x=C_U(cell,thread_l)-C_U(cell,thread_g); slip_y=C_V(cell,thread_l)-C_U(cell,thread_g); slip_z=C_W(cell,thread_l)-C_W(cell,thread_g); /*Parameters*/ rho_g = C_R(cell, thread_g); rho_l = C_R(cell, thread_l); mu_l = C_MU_L(cell, thread_l); /*turbulent kinetic energy and dissipation rate for liquid*/ k_l=C_K_L(cell,thread_l); d_l=C_D_L(cell,thread_l); It says C_D_L is not defined |
|
May 31, 2012, 15:45 |
|
#2 |
Member
Fer Villa
Join Date: Apr 2012
Posts: 35
Rep Power: 14 |
In Fluent,
the turbulent kinetic energy is:C_K(c,t) the turbulent kinetic energy dissipation rate is: C_D(c,t) C_K_L(c,t) is laminar thermal conductivity C_D_L(c,t) I don't know. you are sure that variable macro there |
|
June 1, 2012, 01:34 |
|
#3 |
New Member
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 14 |
I have intended to model a new drag law for two-phase flow (gas -liquid).
Here L denotes the liquid phase. Here is the full UDF. Please go through and suggest me why it is saying d_l=C_D_L(cell,thread_l); C_D_L is undeclared variable. |
|
June 1, 2012, 10:59 |
|
#4 | |
Member
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 16 |
Quote:
You are modelling a two phase flow. Fluent does not know if one phase is liquid or not, it only knows it as "one phase" and the "other phase". You are the one referring to one of the phases as liquid. Fluent knows the cell content with the thread. Therefore, appending _L to the variable does not mean the variable will refer to the liquid phase. You should call the correct thread. If you could have written it as C_D_S to mean solid and C_D_V to mean vapour and your code will not run (or run correctly). If you add _G to mean Gas you will be wrong because most of the _G in the variables refer to gradient. To answer your question, I will suggest you do the following. (1) Turn on the correct Turbulence model (k-eps) I guess. (2) Change your code lines to: /*turbulent kinetic energy and dissipation rate for liquid*/ k_l=C_K(cell,thread_l); d_l=C_D(cell,thread_l); You have to be sure these refer to the correct threads respectively: /* liquid phase-primary*/ thread_l=THREAD_SUB_THREAD(mix_thread,s_col); /* gas phase-secondary*/ thread_g=THREAD_SUB_THREAD(mix_thread,f_col); If your code works please reply in this thread it may help someone else. |
||
June 1, 2012, 11:23 |
|
#5 |
New Member
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 14 |
Thanks
It is working. |
|
June 1, 2012, 11:52 |
|
#6 |
New Member
Tamphasana
Join Date: Jun 2012
Posts: 9
Rep Power: 14 |
thanks for you reply Galileo, the same udf code has successfully interpreted but the problem is while doing iteration it shows error like
FLUENT received fatal signal (ACCESS_VIOLATION) This problem has solved now but again after exactly 11th iteration error shows as Error: divergence detected in AMG solver:k Error Object) I need your help Last edited by thiyam; June 1, 2012 at 12:34. |
|
June 1, 2012, 12:18 |
|
#7 |
New Member
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 14 |
The udf is working fine but when i go for iteration, it shows error like Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: ()
Please suggest me |
|
June 4, 2012, 02:30 |
|
#8 |
New Member
Bimlesh
Join Date: May 2012
Posts: 12
Rep Power: 14 |
While compiling I am getting Warning C4700: Local variable mu_l used without having been initialized.
I am also getting no changes in gas phase wile iterating. Please suggests me. |
|
June 5, 2012, 02:44 |
|
#9 |
New Member
Join Date: Aug 2009
Posts: 6
Rep Power: 17 |
could anyone help me: i provided an udf that set a profile on the boundary, at first i couldnt even interprete this udf, however by adding two lines in code i finally could interprete it. now i encounter a new problem, when i start iterating, an error entitled "Floating point error: invalid number" appears. what should i do?
thank you in advance #include "udf.h" DEFINE_PROFILE(heatflux, thread, position){ #if !RP_HOST real y[ND_ND]; /* this will hold the position vector */ real z; face_t f; begin_f_loop(f, thread) { F_CENTROID(y,f,thread); z = y[2]; F_PROFILE(f, thread, position) = 283889.07*cos((4.0*atan(1.0)/0.815)*(z+0.01005)); } end_f_loop(f, thread) #endif } |
|
June 7, 2012, 10:56 |
|
#10 | |
Member
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 16 |
Quote:
Hi, Sorry for the late response. 1.) That warning is telling you that you have declared a variable but you did not initialise it before using it. That can be ignored or you put an initial value like in this example: real mu_l=0.; or /* DECLARATIONS of variables */ real a; real b; real mu_l; /* Initialising varibles */ a=b=mu_l=0.; 2.) I don't really know what you are trying to achieve, but generally when you write a code like that, you need to HOOK the UDF to the interface. So please check UDF manual for how to hook your particular UDF to FLUENT. You may want to check this: FLUENT MANUAL |
||
June 7, 2012, 11:11 |
|
#11 | |
Member
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 16 |
Quote:
Hi, You need to check if it is a machine issue (eg are you using double or single precision solver?). Try and change the solver. You can also check through to understand what is going on at the stage of iteration and debug, just like you will debug any "normal" code. int Stopper; Stopper=0; #if !RP_HOST real y[ND_ND]; /* this will hold the position vector */ real z; real ATAN,COS,Profile; face_t f; begin_f_loop(f, thread) { F_CENTROID(y,f,thread); z = y[2]; ATAN=atan(1.0); COS= cos((4.0*ATAN/0.815); Profile=283889.07*COS*(z+0.01005)); if (Stopper<20) {Stopper++; /*Print only twenty times DONT HANG MY COMPUTER INSIDE A LOOP */ CX_Message(" Z= %g Atan=%g Cos=%g Profile Val=%g",z,ATAN,COS,Profile); } F_PROFILE(f, thread, position) =Profile; } end_f_loop(f, thread) #endif Hope it works/helps? Last edited by Galileo; June 7, 2012 at 11:33. |
||
June 7, 2012, 11:22 |
|
#12 | |
Member
Engr Adeniyi
Join Date: Jan 2011
Posts: 32
Rep Power: 16 |
Quote:
Hi, That error might be that you are attempting to access a variable from a model you are not using. Eg If you are accessing turbulence variables from UDF while your model setup is laminar, you will face such issue. If also, you are solving a model with k-epsilon and you are trying to access FLUENT data from k-omega, you will also face such. Try and look through the variables and be sure you have switched on the correct variable. If you face divergence problem, it is possible you have the wrong discritisation scheme and your solution is not converging. It is also possible you are getting a division by zero or too big number. So debug your code by printing the values you are changing. You can print using: (Formatting using C-formating). But becareful when printing inside a big loop. You can use a stopping criteria to stop print, eg using a counter variable. CX_Message("*****VARIABLES C_Mu =%E, C_K=%E", c_mu,c_k); |
||
June 9, 2012, 04:21 |
|
#13 | |
New Member
Join Date: Aug 2009
Posts: 6
Rep Power: 17 |
Quote:
it should be mentioned that this code works properly by one processor. however, when i use parallel mode in fluent, i encounter this error after iteration. can i interprete udf in parallel mode or should compile? |
||
September 19, 2014, 02:56 |
if u want to know email me
|
#14 |
New Member
sarighulikhan
Join Date: Mar 2014
Posts: 15
Rep Power: 12 |
becouse u restrict host from getting access to real r
hamed.moradkhani@yahoo.com |
|
September 19, 2014, 07:20 |
udf for superheated steam
|
#15 |
New Member
viral nagar
Join Date: Jun 2014
Location: surat,gujarat
Posts: 8
Rep Power: 12 |
can anyone give me the udf file for superheated steam properties?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM | Rizwan | Fluent UDF and Scheme Programming | 40 | March 18, 2018 07:05 |
UDF problem | mansha goraya | FLUENT | 0 | October 29, 2007 01:31 |
udf compiling problem | akr | FLUENT | 3 | August 22, 2007 08:14 |
UDF PROBLEM | anant | FLUENT | 2 | January 17, 2007 01:15 |
parallel UDF problem | kerem | FLUENT | 2 | June 20, 2006 07:56 |