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

UDF error message: C_PB_DISCI(c,t, i) undeclared variable

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 2018, 18:05
Default UDF error message: C_PB_DISCI(c,t, i) undeclared variable
  #1
New Member
 
Join Date: Apr 2018
Posts: 4
Rep Power: 8
pooneh61 is on a distinguished road
I am trying to access the PBE bin fractions using C_PB_DISCI(c,t, i) in population balance add-on module. When I interpret the UDF, it shows an error message "undeclared variable c_pb_disci". If I include sg_pb.h, a new error message will come up "line 123: parse error".

I think the problem is macro C_PB_DISCI(c,t, i), because when I replace this with other cell variables there are no more errors. I have copied the code below.

Thanks in advance for your help.


include "udf.h"
#include "sg_mphase.h"
/*#include "sg_pb.h"*/
#define mu 0.0014
#define sdas 0.00155

DEFINE_SOURCE(SRCE_Xmom,cell,thread,dS,i)
{
real source;
real fs,a,b,c,d,e,f;
real k;


Thread *tm = THREAD_SUPER_THREAD(thread);
Thread *ts;
ts = THREAD_SUB_THREAD(tm,1);


a = C_PB_DISCI(cell, ts, 0);
b = C_PB_DISCI(cell, ts, 1);
c = C_PB_DISCI(cell, ts, 2);
d = C_PB_DISCI(cell, ts, 3);
e = C_PB_DISCI(cell, ts, 4);
f = C_PB_DISCI(cell, ts, 5);

/* calculate the maximum volume fraction of secondary phase between all the bins*/

if(a>b && a>c && a>d && a>e && a>f)
{fs=a;}
else if(b>a && b>c && b>d && b>e && b>f)
{fs=b;}
else if(c>a && c>b && c>d && c>e && c>f)
{fs=c;}
else if(d>a && d>b && d>c && d>e && d>f)
{fs=d;}
else if(e>a && e>b && e>c && e>d && e>f)
{fs=e;}
else if(f>a && f>b && f>c && f>d && f>e)
{fs=f;}

k = sdas * sdas /180.0 *(1-fs)*(1-fs)*(1-fs)/(fs*fs);
source= -mu/k*C_U(cell,thread);
dS[i] = -mu/k;
return source;
}
pooneh61 is offline   Reply With Quote

Old   July 6, 2018, 04:58
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Pooneh61,

I would not expect interpreting to work for these UDFs. You need to install a (free) compiler. There are some useful posts on compiling UDFs -- for example: links to instructions Visual Studio 2017 for udf use - which modules do I need?; troubleshooting errors How to solve UDF compilation problems in Fluent.; the basic steps of compile/load/hook The UDF library you are trying to load (libudf) is not compiled for 3D on the current.

A couple of comments on your code:
• Your big set of "if" statements to find the largest value looks correct, except that it will fail to put any value into fs if the two largest values are equal. Maybe this is unlikely (*except* if someone initialises the values that way, when it becomes very likely), but it is bad practice in general. Also, of course, it would become increasingly tedious if the number of intervals extended beyond 6 (which is a small number of intervals). See if you can find a solution using a for() loop.
• Using the maximum value of C_PB_DISCI seems strange to me from a physical perspective. First, is it really reasonable that the drag is defined by a value of 0.6 in bin3 (for example), regardless of whether there is a value 0.4 in bin2, or 0.4 in bin4, or small values in all other bins? Second, please note that C_PB_DISCI values are not volume fractions -- they are proportions of the volume fraction of that secondary phase. The sum of the full set of C_PB_DISCI values should always be 1.0.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   July 20, 2018, 14:43
Default
  #3
New Member
 
Join Date: Apr 2018
Posts: 4
Rep Power: 8
pooneh61 is on a distinguished road
Quote:
Originally Posted by obscureed View Post
Hi Pooneh61,

I would not expect interpreting to work for these UDFs. You need to install a (free) compiler. There are some useful posts on compiling UDFs -- for example: links to instructions Visual Studio 2017 for udf use - which modules do I need?; troubleshooting errors How to solve UDF compilation problems in Fluent.; the basic steps of compile/load/hook The UDF library you are trying to load (libudf) is not compiled for 3D on the current.

A couple of comments on your code:
• Your big set of "if" statements to find the largest value looks correct, except that it will fail to put any value into fs if the two largest values are equal. Maybe this is unlikely (*except* if someone initialises the values that way, when it becomes very likely), but it is bad practice in general. Also, of course, it would become increasingly tedious if the number of intervals extended beyond 6 (which is a small number of intervals). See if you can find a solution using a for() loop.
• Using the maximum value of C_PB_DISCI seems strange to me from a physical perspective. First, is it really reasonable that the drag is defined by a value of 0.6 in bin3 (for example), regardless of whether there is a value 0.4 in bin2, or 0.4 in bin4, or small values in all other bins? Second, please note that C_PB_DISCI values are not volume fractions -- they are proportions of the volume fraction of that secondary phase. The sum of the full set of C_PB_DISCI values should always be 1.0.

Good luck!
Ed

Thanks a lot. The issue is solved by compiling the UDF file in fluent 17, but still I have problem in fluent 15. I get this message:
"'nmake' is not recognized as an internal or external command", which probably related to some installation settings in fluent.
pooneh61 is offline   Reply With Quote

Reply


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
Can I change the variable in UDF via Fluent console or window without compiling? swtbkim FLUENT 0 July 12, 2017 23:15
A UDF for mixture outlet variable derived from two other input parameters? ebtedaei FLUENT 0 July 12, 2017 03:17
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
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09


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