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

Interpret-Real Gas UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 17, 2015, 17:46
Default Interpret-Real Gas UDF
  #1
Senior Member
 
navid
Join Date: Jan 2010
Posts: 110
Rep Power: 16
ndabir is on a distinguished road
Hi,

I am trying to use a real gas fluid in my simulations. Therefore, I am using exactly the same udf example in Fluent help to try to understand how it works. So I exactly copy the code from manual in a .c file. Then I try to interpret the udf file. But I am not able to interpret the file. Every time I try to interpret the code, an error is shown:

line 15: parse error

Do you guys know if I can interpret a udf for real gases? Or just compiling the code is the only option?
Below is the code I am trying to interpret:


#include "udf.h"
#include "stdio.h"
#include "ctype.h"
#include "stdarg.h"

#define MW 28.966 /* molec. wt. for single gas (Kg/Kmol) */
#define RGAS (UNIVERSAL_GAS_CONSTANT/MW)

static int (*usersMessage)(char *,...);
static void (*usersError)(char *,...);


DEFINE_ON_DEMAND(I_do_nothing)
{
/* This is a dummy function to allow us to use */
/* the Compiled UDFs utility */
}


void IDEAL_error(int err, char *f, char *msg)
{
if (err)
usersError("IDEAL_error (%d) from function: %s\n%s\n",err,f,msg);
}

void IDEAL_Setup(Domain *domain, cxboolean vapor_phase, char *filename,
int (*messagefunc)(char *format, ...),
void (*errorfunc)(char *format, ...))
{
/* Use this function for any initialization or model setups*/
usersMessage = messagefunc;
usersError = errorfunc;
usersMessage("\nLoading Real-Ideal Library: %s\n", filename);
}

double IDEAL_density(double Temp, double press, double yi[])
{
double r = (press-506625.0)/(RGAS*Temp); /* Density at Temp & press */

return r; /* (Kg/m^3) */
}

double IDEAL_specific_heat(double Temp, double density, double P, double yi[])
{
double cp=1006.43;

return cp; /* (J/Kg/K) */
}

double IDEAL_enthalpy(double Temp, double density, double P, double yi[])
{
double h=Temp*IDEAL_specific_heat(Temp, density, P, yi);

return h; /* (J/Kg) */
}

#define TDatum 288.15
#define PDatum 1.01325e5

double IDEAL_entropy(double Temp, double density, double P, double yi[])
{
double s=IDEAL_specific_heat(Temp,density,P,yi)*log(fabs( Temp/TDatum))+
RGAS*log(fabs(PDatum/P));
return s; /* (J/Kg/K) */
}


double IDEAL_mw(double yi[])
{
return MW; /* (Kg/Kmol) */
}

double IDEAL_speed_of_sound(double Temp, double density, double P, double yi[])
{
double cp=IDEAL_specific_heat(Temp,density,P,yi);

return sqrt(Temp*cp*RGAS/(cp-RGAS)); /* m/s */
}

double IDEAL_viscosity(double Temp, double density, double P, double yi[])
{
double mu=1.7894e-05;

return mu; /* (Kg/m/s) */
}

double IDEAL_thermal_conductivity(double Temp, double density, double P,
double yi[])
{
double ktc=0.0242;

return ktc; /* W/m/K */
}

double IDEAL_rho_t(double Temp, double density, double P, double yi[])
{
/* derivative of rho wrt. Temp at constant p */
double rho_t=-density/Temp;

return rho_t; /* (Kg/m^3/K) */
}

double IDEAL_rho_p(double Temp, double density, double P, double yi[])
{
/* derivative of rho wrt. pressure at constant T */
double rho_p=1.0/(RGAS*Temp);

return rho_p; /* (Kg/m^3/Pa) */
}

double IDEAL_enthalpy_t(double Temp, double density, double P, double yi[])
{
/* derivative of enthalpy wrt. Temp at constant p */
return IDEAL_specific_heat(Temp, density, P, yi);
}


UDF_EXPORT RGAS_Functions RealGasFunctionList =
{
IDEAL_Setup, /* initialize */
IDEAL_density, /* density */
IDEAL_enthalpy, /* enthalpy */
IDEAL_entropy, /* entropy */
IDEAL_specific_heat, /* specific_heat */
IDEAL_mw, /* molecular_weight */
IDEAL_speed_of_sound, /* speed_of_sound */
IDEAL_viscosity, /* viscosity */
IDEAL_thermal_conductivity, /* thermal_conductivity */
IDEAL_rho_t, /* drho/dT |const p */
IDEAL_rho_p, /* drho/dp |const T */
IDEAL_enthalpy_t, /* dh/dT |const p */
IDEAL_enthalpy_p /* dh/dp |const T */
};
ndabir is offline   Reply With Quote

Old   November 18, 2015, 04:38
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Since line 15 is around the place where it says this:
Code:
/*This is a dummy function to allow us to use */
/* the Compiled UDFs utility */
I would guess that this indeed needs to be compiled to work.

Take some time to get the compiler working. Interpreting functions in fluent has so many limitations, I think they should just remove the functionality...
pakk is offline   Reply With Quote

Old   November 18, 2015, 08:22
Default
  #3
Senior Member
 
navid
Join Date: Jan 2010
Posts: 110
Rep Power: 16
ndabir is on a distinguished road
Thanks Pakk. That is something I was trying to avoid since you know how challenging is to make Fluent compile a code...
ndabir is offline   Reply With Quote

Old   November 18, 2015, 08:29
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
In fact I don't recognize that it is difficult to compile a code. Maybe I was lucky, but on my pc after everything was installed, it directly worked.

(I am not saying you are wrong; I have seen many questions about how to make compiling work, so clearly other people do have that experience.)
pakk 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
HELP----Surface Reaction UDF Ashi Fluent UDF and Scheme Programming 1 May 19, 2020 22:13
mass flow in is not equal to mass flow out saii CFX 12 March 19, 2018 06:21
Problems in air flow udf - divergence PJT Fluent UDF and Scheme Programming 0 May 28, 2013 11:01
UDF issue MASOUD Fluent UDF and Scheme Programming 14 December 6, 2012 14:39
solution not converging with UDF. Please help!! shunahshep FLUENT 2 March 8, 2005 19:45


All times are GMT -4. The time now is 00:23.