Interpret-Real Gas UDF
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 */ }; |
Since line 15 is around the place where it says this:
Code:
/*This is a dummy function to allow us to use */ Take some time to get the compiler working. Interpreting functions in fluent has so many limitations, I think they should just remove the functionality... |
Thanks Pakk. That is something I was trying to avoid since you know how challenging is to make Fluent compile a code...
|
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.) |
All times are GMT -4. The time now is 14:20. |