CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How to make UDF for the spatial variation of viscosity? (https://www.cfd-online.com/Forums/fluent/220583-how-make-udf-spatial-variation-viscosity.html)

Nitesh_CMG_GUY September 12, 2019 13:46

How to make UDF for the spatial variation of viscosity?
 
Hi,

Need a small help. I am looking for a UDF for the spatial variation of viscosity. Viscosity is varying in two directions (say X and Z). I tried but when I am loading in the fluent. Simulation showing floating point exception error.

/************************************************** *******************
UDF that simulates spatially dependent viscosity property
************************************************** ********************/
#include "udf.h"
#define a 20105467790.5412
#define b 2.692576799425
#define c 5083.56137738767
#define d -84995.6051593393
#define e -2230225.26461472
#define f 852890049.062181
#define g 502636694.742164

DEFINE_PROPERTY(cell_viscosity, cell,thread)
{
real mu;
real y, z;
real ZB[ND_ND];
C_CENTROID(ZB,cell,thread);

y=ZB[1]; /* y cooridnate*/
z=ZB[2]; /* z cooridnate*/

mu=1.21 - 2.71*(a + b*(z-0.006) + c*pow(z-0.006,2.) + d*pow(z-0.006,3.) + e*pow(z-0.006,4.) + f*pow(z-0.006,5.) + g/(y+0.52347)) +
25.46*pow((a + b*(z-0.006) + c*pow(z-0.006,2.) + d*pow(z-0.006,3.) + e*pow(z-0.006,4.) + f*pow(z-0.006,5.) + g/(y+0.52347)),2.);
return mu;

}

Is there any problem in this UDF?


All times are GMT -4. The time now is 17:32.