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

Compile density udf file based on Peng robinson.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 9, 2017, 05:24
Post Compile density udf file based on Peng robinson.
  #1
New Member
 
withawin
Join Date: May 2017
Posts: 1
Rep Power: 0
winny is on a distinguished road
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)*/
winny is offline   Reply With Quote

Reply

Tags
density real gas


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
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 17:34
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 15:14
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 13:59
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23


All times are GMT -4. The time now is 04:52.