Quote:

Originally Posted by
Antoine
;139313 I've finally found the causes of the problem. To initialize correctly the apparent viscosity, I used the current iteration number macro N_ITER, so when it is < 1 (computation is not launched) apparent viscosity is set to a fixed value. Also, in my previous udf, I defined -k because I'm used to see a minus sign before k in the definition of the shear stress. But the apparent viscosity is positive so the minus sign is a source of error because mu_app always took a negative value < visc_dyn_min... I've also modified some lines of the last version of the udf because they finally weren't necessary. Now the udf works fine, I tested the case of a simple power-law and I obtained errors below 0.5% compared to the fluent integrated power-law. Here is the tested last version of the user defined power-law. Even if I don't find problems anymore, you should test it before launching important computations.
#include "udf.h" DEFINE_PROPERTY(user_power_law,c,t) { real visc_dyn_min=0.0001; /*Define the minimum limit for the value of viscosity*/ real visc_dyn_max=10000; /*Define the maximum limit for the value of viscosity*/ real index_n=0.9; /*Define the power law index*/ real k=1; /*Define the consistency index*/ real T0=0; /*Define the reference temperature T0*/ real T1=0; /*Define the fixed temperature T1*/ real temp=C_T(c,t); /*Define the access to the temperature calculated by Fluent through the temp variable*/ real mu_app; /*Define the variable for the apparent viscosity which will be returned to the solver*/ real mu_temp; /*Define a temporary variable to stock the user defined apparent viscosity*/ mu_temp=k*pow(C_STRAIN_RATE_MAG(c,t),index_n-1)*exp(T0/(temp-T1)); if (N_ITER<1) { mu_app=k; /*Initialize mu_app to the value of k*/ } else if ((N_ITER>=1)&& (mu_temp>visc_dyn_min)&& (mu_temp< visc_dyn_max)) } mu_app=mu_temp; /*Replace the value of mu_app by the calculated user-defined temporary viscosity when the computation has been launched*/ } else if ((N_ITER>=1)&&(mu_temp>=visc_dyn_max)) { mu_app=visc_dyn_max; } else if ((N_ITER>=1)&&(mu_temp<=visc_dyn_min)) { mu_app=visc_dyn_min; } return mu_app; /*Set the value of the user-defined viscosity in Fluent*/ } Best regards Antoine |