CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF: Pointing Cell Pressure (http://www.cfd-online.com/Forums/fluent-udf/117114-udf-pointing-cell-pressure.html)

Jim87 May 2, 2013 09:26

UDF: Pointing Cell Pressure
 
While writing an UDf for compressible Polymers, I'm blocked by this Error:
line 43: Pres: undeclared variable

The manual informs that the pointer for Cell Pressure should be:

C_P(c,t) cell_t c, Thread *t pressure


I'm not able to find the mistake. Maybe someone with more experience could look at this few lines.


************************************************** *************************/

#include "udf.h"


DEFINE_PROPERTY(UDF_Cell_Density_Durethan,c,t)
{


/************************************************** **************************
Standard UDF Befehle
************************************************** ***************************/
/*Domain * d;
Thread * t;
cell_t c; oder face_t f;
Node *v;*/


/************************************************** *************
Aktuelle Temperatur an jeder Zelle aufrufen
************************************************** *************/

temp = C_T(c,t);



/************************************************** *************
Aktuellen Druck an jeder Zelle aufrufen
************************************************** *************/

Pres = C_P(c,t); // This is the definition of Cell-Pressure


/************************************************** *****************
Definition der Variablen // Parameters
************************************************** ******************/

double P1 = 19598.341796875
double P2 = 22733.578125
double P3 = 2.76653862
double P4 = 5604.6762695
double P5 = 5.1758676
double P6 = 0.06848801
double P7 = 0.0017973196

/************************************************** *************
spez. Volumen in Abhaengigkeit von Druck und Temperatur nach Schmidt
// Equation
************************************************** *************/

Rho = 1/SpezVolu;



spezVolu = p1 / (p2 + Pres) + (p3 * temp) / (p4 + Pres) + p5 * pow (( 2.718281828, (p6 * temp + p7 * Pres));

/*********************************
Ende der Define Property
**********************************/
}


Any hint would be much appreciated.

blackmask May 2, 2013 10:42

You need to declare a variable before you can use it.
Add a line to declare Pres in the begining of your UDF function, i.e.,
DEFINE_PROPERTY(UDF_Cell_Density_Durethan,c,t)
{

real Pres;
real temp;
...


You should also receive another error for the variable temp because it has not been declared, either.

Jim87 May 2, 2013 14:54

Hallo blackmask,

I corrected the mistake, but the error is the same.
It seems Irrelevant if I use double or real, the definition * = 0.0 or change the structure of the udf by placing the definition of temperature and pressure in front of the pointer.



************************************************** *************************/

#include "udf.h"

DEFINE_PROPERTY(UDF_Cell_Density_Durethan,c,t)
{


/************************************************** **************************
Standard UDF Befehle
************************************************** ***************************/
/*Domain * d;
Thread * t;
cell_t c; oder face_t f;
Node *v;*/

/************************************************** *************
Aktuelle Temperatur an jeder Zelle aufrufen
************************************************** *************/

temp = C_T(c,t);

/************************************************** *************
Aktuellen Druck an jeder Zelle aufrufen
************************************************** *************/

pressure = C_P(c,t);

/************************************************** *****************
Definition der Variablen
************************************************** ******************/
double pressure = 0.0;
double temp = 0.0;
double P1 = 19598.341796875;
double P2 = 22733.578125;
double P3 = 2.76653862;
double P4 = 5604.6762695;
double P5 = 5.1758676;
double P6 = 0.06848801;
double P7 = 0.0017973196;

/************************************************** *************
spez. Volumen in Abhaengigkeit von Druck und Temperatur nach Schmidt
************************************************** *************/

Rho = 1/SpezVolu;

spezVolu = p1 / (p2 + pressure) + (p3 * temp) / (p4 + pressure) + p5 * pow (( 2.718281828, (p6 * temp + p7 * pressure));

/*********************************
Ende der Define Property
**********************************/
}

blackmask May 2, 2013 22:35

Try this one. The comments are deleted for neatness. There is a reason that I put the two lines immediately after the open curly bracket ({) in my last post. You need to declare the variable first before use. You should use 'real' instead of 'double'. The 'real' is an alias for 'float' in single precision solver and 'double' in double precision solver.

#include "udf.h"

DEFINE_PROPERTY(UDF_Cell_Density_Durethan,c,t)
{
double pressure = 0.0;
double temp = 0.0;
double P1 = 19598.341796875;
double P2 = 22733.578125;
double P3 = 2.76653862;
double P4 = 5604.6762695;
double P5 = 5.1758676;
double P6 = 0.06848801;
double P7 = 0.0017973196;
double spezVolu;


temp = C_T(c,t);
pressure = C_P(c,t);
Rho = 1/SpezVolu;

spezVolu = p1 / (p2 + pressure) + (p3 * temp) / (p4 + pressure) + p5 * pow (( 2.718281828, (p6 * temp + p7 * pressure));

}

harsh_999 October 20, 2013 13:56

pressure and temp are calculated by C_P(c,t) and C_T(c,t) respectively
I think,we cant assign value 0.0
Simply this should work:
real pressure, temp;
Inform me whether u cud succeed....
Gud luck


All times are GMT -4. The time now is 16:50.