|
[Sponsors] |
May 2, 2013, 10:26 |
UDF: Pointing Cell Pressure
|
#1 |
Member
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 15 |
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. |
|
May 2, 2013, 11:42 |
|
#2 |
Senior Member
|
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. |
|
May 2, 2013, 15:54 |
|
#3 |
Member
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 15 |
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 **********************************/ } |
|
May 2, 2013, 23:35 |
|
#4 |
Senior Member
|
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)); } |
|
October 20, 2013, 14:56 |
|
#5 |
New Member
Harshad
Join Date: May 2013
Location: mUMBAI
Posts: 13
Rep Power: 13 |
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 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Pressure modification using flux at outlet boundary (udf) | UnclePetors | Fluent UDF and Scheme Programming | 1 | January 1, 2013 10:47 |
Pulsatile pressure inlet with pressure outlet | a.lynchy | FLUENT | 3 | March 23, 2012 14:45 |
Does star cd takes reference pressure? | monica | Siemens | 1 | April 19, 2007 12:26 |
UDF to control Static Pressure (in cylinder) | James | FLUENT | 0 | July 20, 2004 08:54 |
Hydrostatic pressure in 2-phase flow modeling (CFX4.2) | HB &DS | CFX | 0 | January 9, 2000 14:19 |