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

Errors in defining a source term

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 10, 2014, 14:02
Default Errors in defining a source term
  #1
New Member
 
Michigan
Join Date: Jan 2013
Posts: 10
Rep Power: 12
lxlxlxt is an unknown quantity at this point
Hi all,

I'm having some trouble with a source term. I used the species transport and reaction model but since the model contains polymers, I don't know the accurate standard state enthalpy. So I set the standard state enthalpy to 0 and specified a reaction source term as follows:

/*UDF for energy source term of the reactions*/

#include "udf.h"
#define Aw 1385.;
#define Ew 3.266e+4;
#define AOH 1.7348;
#define EOH 4.04e+4;
#define Rg 8.314;
#define cw0 776.74;
#define coh0 3032.56;
#define cn0 4581.40;
#define delhyd 7.075e+4;
#define delwat 8.6e+4;
DEFINE_SOURCE(energy_source1,c,t,dS,eqn)
{
int j;
int k;
real convoh;
real convw;
real q;
real n;
real source;
Material *m = THREAD_MATERIAL(t);
char *name = "oh";
char *name1 = "h2o<l>";
j = mixture_specie_index(m,name);
k = mixture_specie_index(m,name1);
convoh=(0.424-C_YI(c,t,j))/0.424;/*the comversion of oh*/
convw=(0.0127-C_YI(c,t,k))/0.0127;/*the comversion of h2o<l>*/
q=AOH*exp(-EOH/Rg/C_T(c,t))*coh0*(1.-convoh)*(cn0-2.*cw0*convw-coh0*convoh);/*The coh0*dXoh/dt*/
n=Aw*exp(-Ew/Rg/C_T(c,t))*cw0*(1.-convw);/*The cw0*dXw/dt*/
source = delhyd*q+delwat*n;/*The cw0*dXw/dt*delwater+coh0*dXoh/dt*delhyd*/
dS[eqn]=0;
return source;
}

And I'm getting the errors when building the libudf:
..\..\src\energy_source1.c(30) : error C2143: syntax error : missing ')' before ';'
..\..\src\energy_source1.c(30) : error C2100: illegal indirection
..\..\src\energy_source1.c(30) : error C2143: syntax error : missing ';' before '/'
..\..\src\energy_source1.c(30) : error C2143: syntax error : missing ';' before '/'
..\..\src\energy_source1.c(30) : error C2100: illegal indirection
..\..\src\energy_source1.c(30) : error C2143: syntax error : missing ')' before ';'
..\..\src\energy_source1.c(30) : warning C4552: '*' : operator has no effect; expected operator with side-effect
..\..\src\energy_source1.c(30) : error C2100: illegal indirection
..\..\src\energy_source1.c(30) : warning C4552: '-' : operator has no effect; expected operator with side-effect
..\..\src\energy_source1.c(30) : error C2100: illegal indirection
..\..\src\energy_source1.c(30) : error C2143: syntax error : missing ';' before ')'
..\..\src\energy_source1.c(31) : error C2143: syntax error : missing ')' before ';'
..\..\src\energy_source1.c(31) : error C2100: illegal indirection
..\..\src\energy_source1.c(31) : error C2143: syntax error : missing ';' before '/'
..\..\src\energy_source1.c(31) : error C2143: syntax error : missing ';' before '/'
..\..\src\energy_source1.c(31) : error C2100: illegal indirection
..\..\src\energy_source1.c(32) : error C2100: illegal indirection
..\..\src\energy_source1.c(32) : warning C4552: '+' : operator has no effect; expected operator with side-effect
..\..\src\energy_source1.c(32) : error C2100: illegal indirection

Can anyone help me??
lxlxlxt is offline   Reply With Quote

Old   February 10, 2014, 14:19
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
The #defines that you start with are wrong.
Instead of
Code:
#define Aw 1385.;
you should use
Code:
#define Aw 1385.
so without the semicolon ( ; ) at the end. The same for all those definitions.

The (pre-)compiler will replace things literally. So when you wrote
Code:
q=AOH*exp(...
the pre-compiler sees "AOH", remembers that this should be replaced by "1.7348;", and the result is
Code:
q=1.7348;*exp(...
This is giving the errors.
lxlxlxt likes this.
pakk is offline   Reply With Quote

Old   February 10, 2014, 19:56
Default
  #3
New Member
 
Michigan
Join Date: Jan 2013
Posts: 10
Rep Power: 12
lxlxlxt is an unknown quantity at this point
Thank you so much for your reply pakk
lxlxlxt is offline   Reply With Quote

Reply

Tags
compiling, source term, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 13:58
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43


All times are GMT -4. The time now is 06:30.