# FLUENT V6 - Reading experimental/tabulated values of material properties or profiles

 FLUENT provides for a variety of methods for specifying material properties, including polynomial functions, piece-wise linear functions, etc. User-defined functions can also be used to specify material properties and variable profiles. However, using tabulated experimental data or complicated functions that can not be easily expressed analytically is difficult. The following user-defined function demonstrates how tabulated data can be read into FLUENT and used to specify a material property in a UDF. The example corresponds to specifying the viscosity as a function of temperature. The tabulated data should be in an ascii file (two column format) and the number of rows in the file is specified in the UDF. In this example, the data file is called "viscosity.dat" and there are 53 rows (pairs) of data. The viscosity will be linearly interpolated between the tabulated values. #include "udf.h" int NPts_mu = 53; /* number of entries in viscosity table */ /* Locate the place in the interpolation vector using bisection algorithm*/ int locate(float xx[], int n, float x) { int j = 0; int jm = 0; int jl = 0; int ju = n+1; int ascnd = 0; ascnd = (xx[n] >= xx); while (ju-jl > 1) { jm = (ju+jl) >> 1; if (x >= xx[jm] == ascnd) jl = jm; else ju = jm; } if (x == xx) j = 1; else if (x == xx[n]) j = n-1; else j = jl; return j; } float *temp_vec_mu,*visc_vec; #define FAST_LOOKUP TRUE /* use bisection algorithm for interpolation */ #define TABLE_MESSAGES TRUE #define DISPLAY_TABLES TRUE /* Obtaine mu given temperature */ float get_mu_from_T(float xdata) { int i = 0; int j = 0; float xL,xU,ydata; #if FAST_LOOKUP j = locate(temp_vec_mu,NPts_mu,xdata); xL = temp_vec_mu[j]; xU = temp_vec_mu[j+1]; ydata = visc_vec[j] + (xdata-xL)/(xU-xL)*( visc_vec[j+1] - visc_vec[j] ); #else for ( i=1; i=xL)&&(xdata<=xU) ) { ydata = visc_vec[i] + (xdata-xL)/(xU-xL)*( visc_vec[i+1] - visc_vec[i] ); break; } } #endif if ( xdata>temp_vec_mu[NPts_mu] ) { #if TABLE_MESSAGES Message("n temperature is above the bound of visc-array n"); #endif ydata = visc_vec[NPts_mu]; } if ( xdata

 No comments yet. Be the first to add a comment!