CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   parse error while interpreting udf (https://www.cfd-online.com/Forums/fluent-udf/46789-parse-error-while-interpreting-udf.html)

Kristin December 11, 2007 07:20

parse error while interpreting udf
 
Hello,

I need some help. I've been trying to interpret my udf calculating drag force. I'm running an Euler-Euler simulation of elongated granular bodies.

This is my first udf and I'm not entirely familiar with the language. I'm getting several parse error when interpreting, which I have noted in the udf as comments.

I've also tried compiling the udf but i only get error:Open_udf_library: The system cannot find the file specified. I have the udf in the same folder as the casefile and when creating the library the udf is copied into the src-folder in the library.

Can someone please try to interpret or compile my udf and help me.

This is my udf:

# include "udf.h" # include "mem.h"

# define DCYL 0.0002; # define L 0.010; # define N 10;

# define DREF 78e-6;

# define PI 3.141592653589; DEFINE_EXCHANGE_PROPERTY(drag_45, cell, mix_thread, s_col, f_col) {

Thread *thread_v, *thread_f;

real uxf;

real uyf;

real uzf;

real uxv;

real uyv;

real uzv;

real slip_v;

real rho_v;

real rho_f;

real mu_v;

double cos_alpha;

double sin_alpha;

double alfa;

double redn;

double redp;

double cdn;

double cf;

double cdfiber;

real k;

real void_v;

real void_f;

real fn;

real fp;

real fd;

alfa=45;

/* find the threads for the gas (primary) */

/* and solids (secondary phases) */

thread_v = THREAD_SUB_THREAD(mix_thread, f_col); /* liquid phase */

thread_f = THREAD_SUB_THREAD(mix_thread, s_col); /* fiber phase*/

/* find phase velocities and properties*/

uxf = C_U(cell, thread_f);

uyf = C_V(cell, thread_f);

uzf = C_W(cell, thread_f);

uxv = C_U(cell, thread_v);

uyv = C_V(cell, thread_v);

uzv = C_W(cell, thread_v);

slip_v = SQR((uxv-uxf)*(uxv-uxf) +(uyv-uyf)*(uyv-uyf)+(uzv-uzf)*(uzv-uzf));

if (slip_v < 1e-12)

{

slip_v = 1e-12;

}

else

{

}

rho_v = C_R(cell, thread_v);

rho_f = C_R(cell, thread_f);

mu_v = C_MU_L(cell, thread_v)

void_v = C_VOF(cell, thread_v); /* Vol frac water*//*parse error*/

void_f = 1-void_v;

cos_alpha= cos ( alfa);

sin_alpha= sin (alfa);

/*compute reynoldsnumber*/

redn=rho_v*slip_v*sin_alpha*DCYL/mu_v; /*normal to fiber*/ /*parse error*/

redp=rho_v*slip_v*cos_alpha*DCYL/mu_v; /*parallell to fiber*/ /*parse error*/

if (redn<1e-12)

{

redn=1e-12;

}

if (redp<1e-12)

{

redp=1e-12;

}

/* compute dragforce coeff in normal direction*/

cdn=6.96*(1/( pow ( redn, 0.440))* pow ( DCYL/DREF, 0.404)); /*parse error*/

cf=0.78*1/(pow (redp,0.61));

cdfiber=(8/3)*(cf*cos_alpha*cos_alpha*cos_alpha+(cdn/PI)sin_alpha*sin_alpha*sin_alpha); /*parse error*/

if (void_f<1e-12)

{

void_f=1e-12;

}

fn=1/2*rho_v*slip_v*slip_v*sin_alpha*sin_alpha*DCYL*L*c dn; /*parse error*/

fp=1/2*rho_v*slip_v*slip_v*cos_alpha*cos_alpha*PI*DCYL* L*cf;

fd=fp*cos_alpha+fn*sin_alpha;

np=4*void_f/(PI*DCYL*L);

K=fd*np/slip_v;

return K; }

Sincerely, Kristin

szz December 11, 2007 08:27

Re: parse error while interpreting udf
 
Hi,

your code contained several minor syntax errors which I corrected and commented below. Now it compiles just fine. Online-tutorials on the language C can help you with the basics.

Greetings szz

# include "udf.h" # include "mem.h"

# define DCYL 0.0002 /* no semicolon in preprocessor declaration*/

# define L 0.010 # define N 10

# define DREF 78e-6

# define PI 3.141592653589

DEFINE_EXCHANGE_PROPERTY(drag_45, cell, mix_thread, s_col, f_col) {

Thread *thread_v, *thread_f;

real uxf;

real uyf;

real uzf;

real uxv;

real uyv;

real uzv;

real slip_v;

real rho_v;

real rho_f;

real mu_v;

real np; // added

real K; // added

double cos_alpha;

double sin_alpha;

double alfa;

double redn;

double redp;

double cdn;

double cf;

double cdfiber;

real k;

real void_v;

real void_f;

real fn;

real fp;

real fd;

alfa=45;

/* find the threads for the gas (primary) */

/* and solids (secondary phases) */

thread_v = THREAD_SUB_THREAD(mix_thread, f_col); /* liquid phase */

thread_f = THREAD_SUB_THREAD(mix_thread, s_col); /* fiber phase*/

/* find phase velocities and properties*/

uxf = C_U(cell, thread_f);

uyf = C_V(cell, thread_f);

uzf = C_W(cell, thread_f);

uxv = C_U(cell, thread_v);

uyv = C_V(cell, thread_v);

uzv = C_W(cell, thread_v);

slip_v = SQR((uxv-uxf)*(uxv-uxf) +(uyv-uyf)*(uyv-uyf)+(uzv-uzf)*(uzv-uzf));

if (slip_v < 1e-12)

{

slip_v = 1e-12;

}

else

{

}

rho_v = C_R(cell, thread_v);

rho_f = C_R(cell, thread_f);

mu_v = C_MU_L(cell, thread_v); // semicolon added

void_v = C_VOF(cell, thread_v); /* Vol frac water*//*parse error*/

void_f = 1-void_v;

cos_alpha= cos ( alfa);

sin_alpha= sin (alfa);

/*compute reynoldsnumber*/

redn=rho_v*slip_v*sin_alpha*DCYL/mu_v; /*normal to fiber*/ /*parse error*/

redp=rho_v*slip_v*cos_alpha*DCYL/mu_v; /*parallell to fiber*/ /*parse error*/

if (redn<1e-12)

{

redn=1e-12;

}

if (redp<1e-12)

{

redp=1e-12;

}

/* compute dragforce coeff in normal direction*/

cdn=6.96*(1/( pow ( redn, 0.440))* pow ( DCYL/DREF, 0.404)); /*parse error*/

cf=0.78*1/(pow (redp,0.61));

cdfiber=(8/3)*(cf*cos_alpha*cos_alpha*cos_alpha+(cdn/PI)*sin_alpha*sin_alpha*sin_alpha); /* times (*) added before sin */

if (void_f<1e-12)

{

void_f=1e-12;

}

fn=1/2*rho_v*slip_v*slip_v*sin_alpha*sin_alpha*DCYL*L*c dn; /*parse error*/

fp=1/2*rho_v*slip_v*slip_v*cos_alpha*cos_alpha*PI*DCYL* L*cf;

fd=fp*cos_alpha+fn*sin_alpha;

np=4*void_f/(PI*DCYL*L);

K=fd*np/slip_v;

return K; }


Kristin December 11, 2007 09:49

Re: parse error while interpreting udf
 
Thanks a million

kitrax March 15, 2012 06:43

Dear all, I am getting the same parse error when I try to interpret. The code is quite simple, and I keep getting it on the bottom line of code. I cant understand why, can someone please help.

Thanks, have attached the code below

/*UDF for adding sink term for H2 consumption based on current density */

#include "udf.h"

DEFINE_SOURCE(sink,c,t,dS,eqn)
{
real i = 0.4; /* Amps/m2 */
real F = 96485.0; /* Faradays constant (C/mol) */
real M_H2 = 2.0; /* Molecular weight of Hydrogen */
real sink;
real area = 0.001*0.001;
real volume = C_VOLUME(c,t);
/*Thread *t;
cell_t c;*/

//sink = -(((i/area)/volume)/(2.0*F))*M_H2;
sink = 0.0;
return sink
}


All times are GMT -4. The time now is 22:57.