
[Sponsors] 
October 7, 2010, 14:11 
Parallel User Defined Real Gas Model

#1 
New Member
Join Date: Jul 2009
Posts: 21
Rep Power: 7 
I am trying to implement the AbelNobel equation of state for a problem thus requiring me to write a UDRGM. I took the example for the Ideal Gas Equation of State from the fluent12.0 users Manuel (the version I'm using) and made some changes to it to suit my purposes.
In serial it works great! Problem is I need to run this problem on multiple processors. I've checked out the UDF manual for this but it seems to have left me even more lost than when I started. Having viewed quite a few posts on this site, I'm not sure if I even need to parallize this at all! However, it works fine in the GUI, and does not work at all when I submit the job for a multiprocessor run. For reference, here is the real gas code from the fluent Manuel. Any help would be greatly appreciated. /************************************************** ********************/ /* User Defined Real Gas Model : */ /* For Ideal Gas Equation of State */ /* */ /************************************************** ********************/ #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) #define TDatum 288.15 #define PDatum 1.01325e5 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 RealIdeal Library: %s\n", filename); } double IDEAL_density(double Temp, double press, double yi[]) { double r = press/(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) */ } 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/(cpRGAS)); /* m/s */ } double IDEAL_viscosity(double Temp, double density, double P, double yi[]) { double mu=1.7894e05; 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); } double IDEAL_enthalpy_p(double Temp, double density, double P, double yi[]) { /* derivative of enthalpy wrt. pressure at constant T */ /* general form dh/dpT = (1/rho)*[ 1 + (T/rho)*drho/dTp] */ /* but for ideal gas dh/dp = 0 */ return 0.0 ; } 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 */ }; /************************************************** ************/ 

October 19, 2010, 22:41 
Figured it out

#2 
New Member
Join Date: Jul 2009
Posts: 21
Rep Power: 7 
All,
This was simply a case of my not having my submit script save the .c file to the working folder. it was not necessary for this to be altered. Thought I'd post to this in case someone else was having a similar problem. 

October 20, 2010, 06:09 

#3 
New Member
sreenivasa rao gubba
Join Date: Sep 2010
Location: Leeds University, UK
Posts: 27
Rep Power: 6 
Hi Aeroman,
We had similar problems in parallel as well. We found a way for this by compiling the udf after reading the case and data files in your batch mode. You can use a journal file to define these commands and before starting calculations. Hope this work with you as well. Sree 

October 21, 2010, 15:04 
Thanks for the reply

#4 
New Member
Join Date: Jul 2009
Posts: 21
Rep Power: 7 
Hey Sree,
Yes, I didn't mention that part but I also used the journal file to compile and impliment it. Thanks again for the reply. 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
User fortran error when running CFX10 in parallel  CFDworker  CFX  2  October 26, 2007 16:01 
Gradient of a User defined Variable  Ramadas  CFX  2  August 21, 2007 09:19 
Real Gas Mixture With Reactions  Jake Cannon  Main CFD Forum  0  January 16, 2007 11:46 
User Defined Scalars  Returning Values  Carlos V.  FLUENT  0  April 19, 2006 18:18 
CFX 5.5  Roued  CFX  1  October 2, 2001 16:49 