CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Compile density udf file based on Peng robinson. (https://www.cfd-online.com/Forums/fluent-udf/187530-compile-density-udf-file-based-peng-robinson.html)

winny May 9, 2017 05:24

Compile density udf file based on Peng robinson.
 
I try interpolated udf file in the ansys fluent15.0. However, I do not understatnd what is error for my flie. Please help me

#include"udf.h"
#define RGASU UNIVERSAL_GAS_CONSTANT
#define PI 3.141592654
#define MWT 42.081
#define PCRIT 4.665e6
#define TCRIT 365.6
#define ZCRIT 0.289
#define VCRIT 4.47708e-3
#define temp
/*static variables associated with Resdlich-Kwong Model*/
double rgas, a0, b0, c0, bb;
 
void RKEO_Setup(Domain *domain, cxboolean vapor_phase, char*filename, int(*messagefunc)(char*format,...),
void (*errorfunc)(char*format,...))
{
rgas = RGASU/MWT;
a0 = 0.45724*pow(rgas,2)*pow(TCRIT,2)/PCRIT;
b0 = 0.07779*rgas*TCRIT/PCRIT;
c0 = rgas*TCRIT/(PCRIT+a0/(VCRIT*(VCRIT+b0)))+b0-VCRIT;
bb = b0-c0;
}
double RKEOS_spvol (double temp, double press)
{
double a1,a2,a3;
double vv,vv1,vv2,vv3;
double qq,qq3,sqq,rr,tt,dd;
double afun
afun = a0*pow((1+((0.37464+(1.5422*0.14)-(0.26992*0.14*0.14))*(1-(sqrt(temp/365.5))))),2);
a1 = c0-rgas*temp/press;
a2 = -(bb*b0+rgas*temp*b0/press-afun/press);
a3 = -afun*bb/press;
/*Solve cubic equation for specific volume*/
qq = (a1*a1-3.*a2)/9.;
rr = (2*a1*a1*a1-9.*a1*a2+27.*a3)/54.;
qq3 = pow(qq,3);
dd = qq3-pow(rr,2);
/*Id dd < 0, then we have one real root*/
/*Id dd >= 0, then we have three roots-> choose largest root*/
if (dd<0.)
{
tt = pow(sqrt(-dd)+fabs(rr),0.333333);
vv = (tt+qq/tt)-a1/3.;
}
else
{
tt = acos(rr/sqrt(qq3));
sqq = sqrt(qq);
vv1 = -2.*sqq*cos(tt/3.)-a1/3.;
vv2 = -2.*sqq*cos((tt+2.*PI)/3.)-a1/3;
vv3 = -2.*sqq*cos((tt+4.*PI)/3.)-a1/3;
vv = (vv1 > vv2) ? vv1 : vv2;
vv = (vv > vv3) ? vv : vv3;
}
return vv;
}
double RKEOS_density(cxboolean vapor_phase, double temp, double press, double yi[])
{
return 1./RKEOs_spvol(temp, press);/*(kg/m3)*/


All times are GMT -4. The time now is 14:57.