CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF for Density variation (https://www.cfd-online.com/Forums/fluent/39597-udf-density-variation.html)

Naresh February 11, 2006 17:35

UDF for Density variation
 
Dear Forum users,

I am facing a problem with an UDF that I have written. Basically I am trying to change the density based on the length. The model is a multiphase model(2 phase Eulerian), and is a vertical column of 30m height with a pressure outlet at the top. The code is as follows:

#include "udf.h" #include "metric.h"

FILE *fp;

DEFINE_PROPERTY(rho,c1,t1) { float density,rho=C_R(c1,t1); float temperature=1523.01; float x[ND_ND];

C_CENTROID(x,c1,t1);

if (x[1]<=4.64)

{temperature=1773+246.9136*(x[1]-1.4);

if (temperature<=2573 || temperature>=1773)

density = rho*1523.01/temperature;

} else if (x[1]>4.64 && x[1]<=35.64)

{temperature=2573-83.83648*(x[1]-4.64);

if (temperature<=2573 || temperature>=393)

density = rho*1523.01/temperature;

} else density=0.7;

return density; }

The problem is, when I try to use this UDF it diverges and eventually gives a floating point error(invalid number). All help in fixing this will be appreciated.

-Naresh


All times are GMT -4. The time now is 08:49.