|
[Sponsors] |
March 7, 2018, 23:37 |
Error undeclared variable
|
#1 |
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
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("operating-pressure"); 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("physical-time-step"); 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 8, 2018, 00:20 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
C_UDSI(c,t,ads)=71.6*exp(-A*A/(E*E)); Best regards |
|
March 8, 2018, 05:13 |
|
#3 |
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
||
March 8, 2018, 09:56 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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, 10:01 |
|
#5 |
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
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 12, 2018, 00:13 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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, 21:02 |
|
#7 | |
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
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, 22:31 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 15, 2018, 00:15 |
|
#9 |
New Member
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9 |
Thank you so much, I'm really really newbie, it look likes very easy evidently, again, thank you so much
|
|
August 13, 2020, 07:01 |
|
#10 |
New Member
arun km
Join Date: Dec 2011
Location: Chennai,India
Posts: 3
Rep Power: 14 |
||
Tags |
udf code, udf error, udf undeclared variable |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFoam-1.6-ext Allwmake compilation error - one last barrier | Pat84 | OpenFOAM Installation | 15 | July 25, 2012 22:49 |
emag beta feature: charge density | charlotte | CFX | 4 | March 22, 2011 10:14 |
error in COMSOL:'ERROR:6164 Duplicate Variable' | bhushas | COMSOL | 1 | May 30, 2008 05:35 |
Env variable not set | gruber2 | OpenFOAM Installation | 5 | December 30, 2005 05:27 |
Replace periodic by inlet-outlet pair | lego | CFX | 3 | November 5, 2002 21:09 |