CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   user-defined function problem (https://www.cfd-online.com/Forums/fluent/87341-user-defined-function-problem.html)

wlt_1985 April 18, 2011 07:02

user-defined function problem
 
I wrote an user-defined function. I do not know whether is it correct or not since floating error appears each time I interpret it into my model. Please have a check for me. Thanks a lot.

#include "udf.h"

/* DENSITY - START */
DEFINE_PROPERTY(formic_acid_density, c, t)
{
real C; /* self-defined variable for convenience */
real D; /* self-defined variable for convenience */
real rho; /* calculated density in unit kg/m3 */
real T = C_T(c,t); /* temperature in unit kelvin, K */
const real A = 0.36821; /* dimensionless regression coeficient */
const real B = 0.24296; /* dimensionless regression coeficient */
const real n = 0.23663; /* dimensionless regression coeficient */
const real Tc = 580; /* critical temperature in unit kelvin, K */
C = 1-T/Tc; /* self-defined variable for convenience */
D = pow(C, n); /* self-defined variable for convenience */
rho = A*(pow(B, -D))*1000; /* calculated density in unit kg/m3 */
return rho;
}


All times are GMT -4. The time now is 13:48.