CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Error undeclared variable

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By AlexanderZ
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 7, 2018, 23:37
Default Error undeclared variable
  #1
New Member
 
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9
andrk is on a distinguished road
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!
andrk is offline   Reply With Quote

Old   March 8, 2018, 00:20
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
C_UDSI(c,t,ads)=71.6*exp(-A*A/(E*E));
what is "ads" here? why do you use ads?


Best regards
annan likes this.
AlexanderZ is offline   Reply With Quote

Old   March 8, 2018, 05:13
Default
  #3
New Member
 
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9
andrk is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
Code:
C_UDSI(c,t,ads)=71.6*exp(-A*A/(E*E));
what is "ads" here? why do you use ads?


Best regards
I want "ads" represent the absolute adsorption isotermal

represent this equation:

na = 71.6 * exp [-(A)^2/E^2]
andrk is offline   Reply With Quote

Old   March 8, 2018, 09:56
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   March 11, 2018, 10:01
Default
  #5
New Member
 
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9
andrk is on a distinguished road
Quote:
Originally Posted by pakk View Post
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.
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
andrk is offline   Reply With Quote

Old   March 12, 2018, 00:13
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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)
to be
Code:
C_UDSI(c,t,0)
AlexanderZ is offline   Reply With Quote

Old   March 14, 2018, 21:02
Default
  #7
New Member
 
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9
andrk is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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)
to be
Code:
C_UDSI(c,t,0)
If I change that, then how to differentiate 4 same equations C_UDSI(c,t,0)? While I hsve to use in this equation

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));
andrk is offline   Reply With Quote

Old   March 14, 2018, 22:31
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
andrk likes this.
AlexanderZ is offline   Reply With Quote

Old   March 15, 2018, 00:15
Default
  #9
New Member
 
Andre Kurniawan
Join Date: Sep 2017
Posts: 6
Rep Power: 9
andrk is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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
Thank you so much, I'm really really newbie, it look likes very easy evidently, again, thank you so much
andrk is offline   Reply With Quote

Old   August 13, 2020, 07:01
Default
  #10
New Member
 
arun km
Join Date: Dec 2011
Location: Chennai,India
Posts: 3
Rep Power: 15
arun km is on a distinguished road
Quote:
Originally Posted by andrk View Post
Thank you so much, I'm really really newbie, it look likes very easy evidently, again, thank you so much
Did you resolve the issue
arun km is offline   Reply With Quote

Reply

Tags
udf code, udf error, udf undeclared variable


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 13:56.