CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Parallel User Defined Real Gas Model (http://www.cfd-online.com/Forums/fluent/80823-parallel-user-defined-real-gas-model.html)

aeroman October 7, 2010 14:11

Parallel User Defined Real Gas Model
 
I am trying to implement the Abel-Nobel 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 multi-processor 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 Real-Ideal 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/(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);
}
double IDEAL_enthalpy_p(double Temp, double density, double P, double yi[])
{
/* derivative of enthalpy wrt. pressure at constant T */
/* general form dh/dp|T = (1/rho)*[ 1 + (T/rho)*drho/dT|p] */
/* 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 */
};
/************************************************** ************/

aeroman October 19, 2010 22:41

Figured it out
 
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.

sreerao October 20, 2010 06:09

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

aeroman October 21, 2010 15:04

Thanks for the reply
 
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.

fafa_blues July 1, 2015 06:09

Quote:

Originally Posted by aeroman (Post 280223)
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.

hi
i have a question about running my UDRGM i appreciate for helping me
i compile and load my code successfully in parallel (8 processors) version of fluent 6.3

Loading Real-EQUILIBRIUM_GAS Library:
Setting material "air" to a real-gas...
Loading Real-EQUILIBRIUM_GAS Library:
Loading Real-EQUILIBRIUM_GAS Library:
Loading Real-EQUILIBRIUM_GAS Library:
Loading Real-EQUILIBRIUM_GAS Library:
Loading Real-EQUILIBRIUM_GAS Library:
Loading Real-EQUILIBRIUM_GAS Library:
Loading Real-EQUILIBRIUM_GAS Library:
Loading Real-EQUILIBRIUM_GAS Library:

but when i want to use it (start iteretion) some error apears :

unable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
unable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
unable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
unable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
unable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
unable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
unable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
999999 (..\..\src\mpsystem.c@1123): mpt_read: failed: errno = 10054
999999: mpt_read: error: read failed trying to read 4 bytesunable to read the cmd header on the pmi context, generic socket failure, error stack:
MPIDU_Sock_wait(2533): The specified network name is no longer available. (errno 64).
: No such file or directory
received suspend command for a pmi context that doesn't exist: unmatched id = 7
received suspend command for a pmi context that doesn't exist: unmatched id = 6
received suspend command for a pmi context that doesn't exist: unmatched id = 5
received suspend command for a pmi context that doesn't exist: unmatched id = 3
job aborted:
rank: node: exit code[: error message]
0: msc9.aero.edu: -1073741819: process 0 exited without calling finalize
1: msc9.aero.edu: -1073741819: process 1 exited without calling finalize
2: msc9.aero.edu: -1073741819: process 2 exited without calling finalize
3: msc9.aero.edu: -1073741819: process 3 exited without calling finalize
4: msc9.aero.edu: -1073741819: process 4 exited without calling finalize
5: msc9.aero.edu: -1073741819: process 5 exited without calling finalize
6: msc9.aero.edu: -1073741819: process 6 exited without calling finalize
7: msc9.aero.edu: -1073741819: process 7 exited without calling finalize
received suspend command for a pmi context that doesn't exist: unmatched id = 2
received suspend command for a pmi context that doesn't exist: unmatched id = 1
received suspend command for a pmi context that doesn't exist: unmatched id = 0
The Parallel FLUENT process could not be started.

I don't know that is wrong, could you please help


All times are GMT -4. The time now is 08:33.