
[Sponsors] 
March 7, 2018, 22:37 
Error undeclared variable

#1 
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 5 
Hi everyone,
I want to interpret a udf file to ansys fluent 15, but i encounter this error: "line 29: ads: undeclared variable" Here is my code (I have bolded the line 29): #include "udf.h" DEFINE_ADJUST(adsorption,domain) { Thread *t; cell_t c; real E,A,P; thread_loop_c(t,domain) { begin_c_loop(c,t) { real tem=C_T(c,t); P=C_P(c,t)+RP_Get_Real("operatingpressure"); E=3080+18.9*tem; A=8.31429*tem*log(1.47E9/P); C_UDSI(c,t,ads)=71.6*exp(A*A/(E*E)); } end_c_loop(c,t) } } DEFINE_ADJUST(q_ads, domain) { Thread *t; cell_t c; real dt; thread_loop_c(t,domain) { begin_c_loop(c,t) { dt = RP_Get_Real("physicaltimestep"); C_UDSI(c,t,q_ads)=C_UDSI_M1(c,t,q_ads)+0.15*dt*(C_ UDSI_M1(c,t,ads)C_UDSI_M1(c,t,q_ads)); } end_c_loop(c,t) } } DEFINE_ADJUST(d_ads, domain) { Thread*t; cell_t c; thread_loop_c(t,domain) { begin_c_loop(c,t) { C_UDSI(c,t,d_ads)=0.532224*0.15* (C_UDSI(c,t,ads)C_UDSI(c,t,q_ads)); } end_c_loop(c,t) } } DEFINE_SOURCE(m_src,c,t,dS,eqn) { dS[eqn]=0.0; return C_UDSI_M1(c,t,d_ads); } DEFINE_ADJUST(H_ads,domain) { Thread*t; cell_t c; real p_operating, p_static; thread_loop_c(t,domain) { begin_c_loop(c,t) { C_UDSI(c,t,H_ads)=3080* sqrt(log(71.6/C_UDSI_M1(c,t,ads))); } end_c_loop(c,t) } } DEFINE_SOURCE(esrc,c,t,dS,eqn) { real e_source; e_source=C_UDSI_M1(c,t,d_ads)* 0.496056352e3*3080 *sqrt(log(71.6/C_UDSI_M1(c,t,ads))); dS[eqn] = 0.0; return e_source; } Hope someone can help me to solve it. Many thanks! 

March 7, 2018, 23:20 

#2 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 1,424
Rep Power: 21 
Code:
C_UDSI(c,t,ads)=71.6*exp(A*A/(E*E)); Best regards 

March 8, 2018, 04:13 

#3 
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 5 

March 8, 2018, 08:56 

#4 
Senior Member
Join Date: Nov 2013
Posts: 1,472
Rep Power: 20 
Very nice that you want that, but how can the compiler know that?
You never tell the compiler what "ads" is... Personally, I would just replace it by the number 0. 

March 11, 2018, 09:01 

#5 
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 5 
I'm new at CFD software, my senior was using this code, so I don't know some, can you tell me how the compiler can read "ads"? Many thanks


March 11, 2018, 23:13 

#6 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 1,424
Rep Power: 21 
As pakk has mentioned, I think you should change ads or q_ads/d_ads to 0 everywhere in your udf code where UDSI is.
was Code:
C_UDSI(c,t,ads) Code:
C_UDSI(c,t,0) 

March 14, 2018, 20:02 

#7  
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 5 
Quote:
C_UDSI(c,t,d_ads)=0.532224*0.15*(C_UDSI(c,t,ads)C_UDSI(c,t,q_ads)); Will it work if just be the following equation? C_UDSI(c,t,0)=0.532224*0.15*(C_UDSI(c,t,0)C_UDSI(c,t,0)); 

March 14, 2018, 21:31 

#8 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 1,424
Rep Power: 21 
to differentiate variables you need to use integer values, for instance
ads change to 0 d_ads change to 1 and so on You may find more details in Ansys Fluent Customization manual best regards 

March 14, 2018, 23:15 

#9 
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 5 
Thank you so much, I'm really really newbie, it look likes very easy evidently, again, thank you so much


August 13, 2020, 06:01 

#10 
New Member
arun km
Join Date: Dec 2011
Location: Chennai,India
Posts: 3
Rep Power: 10 

Tags 
udf code, udf error, udf undeclared variable 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
OpenFoam1.6ext Allwmake compilation error  one last barrier  Pat84  OpenFOAM Installation  15  July 25, 2012 21:49 
emag beta feature: charge density  charlotte  CFX  4  March 22, 2011 09:14 
error in COMSOL:'ERROR:6164 Duplicate Variable'  bhushas  Main CFD Forum  1  May 30, 2008 04:35 
Env variable not set  gruber2  OpenFOAM Installation  5  December 30, 2005 04:27 
Replace periodic by inletoutlet pair  lego  CFX  3  November 5, 2002 20:09 