CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Viscosity UDF Gives different Results to fluent Model? (https://www.cfd-online.com/Forums/fluent-udf/216111-viscosity-udf-gives-different-results-fluent-model.html)

bloodflow March 28, 2019 07:52

Viscosity UDF Gives different Results to fluent Model?
 
Hi All.

I am examining many different viscosity models through UDF's in Fluent. I have written a UDF for the Carreau model even though it is in Fluent. When I run 2 identical simulations, one using my UDF for Carreau Viscosity, the other using Fluents inbuilt model, they give different results. This is implying my UDF's are not working as intended, and are likely wrong for the other models. Is there a reaosn why this UDF doesnt implement the Carreau model? (both models use the same values for max/min shear visco, lambda and n.)

Could this be because of the rounding errors in my code? Would it be more accurate to use "double" instead of "float"?




/* Carreau (p=2) Viscosity Model */

#include "udf.h"

float muinf=0.00345;
float mu0=0.056;
float lambda=3.313;
float p=2;
float n=0.3568;

DEFINE_PROPERTY(cell_viscosity,c,t)
{
real diff;
real shear;
real prod;
real power;
real visco;
diff=(mu0-muinf);
prod=((lambda)*(C_STRAIN_RATE_MAG(c,t)));
shear=(1+(pow(prod,p)));
power=((n-1)/(p));
visco=((muinf)+(diff)*(pow(shear,power)));
return visco;
}

AlexanderZ March 28, 2019 20:11

Quote:

Would it be more accurate to use "double" instead of "float"?
why did you ask? try it. Change everything to real.

best regards


All times are GMT -4. The time now is 11:33.