-
-
March 19, 2019 at 12:16 pm
BeginerModel
SubscriberHi All,
I am trying to write a UDF for the Carreau-Yasuda viscosity model according to the following equation.
Everything in the equation is a parameter which I can define apart from the shear rate term. I believe in fluent I can call this value using;
C_STRAIN_RATE_MAG(c,t), but when I try and raise this to a power as in the equation, I get an error saying "invalid binary expression, double ^ float), implying that the magnitude isn't an integer? Any help is appreciated, and my UDF is below.
/* Carreau-Yasuda Viscosity Model */
#include "udf.h"
float mu_inf=0.00345;
float mu_zero=0.16;
float lambda=8.2;
float p=0.64;
float n=0.2128;
DEFINE_PROPERTY(cell_viscosity,c,t)
{
real mu_lam;
real rate;
rate=(C_STRAIN_RATE_MAG(c,t));
mu_lam=mu_inf+((mu_zero-mu_inf)*(1+(lambda*rate)^(p)))^((n-1)/p);
}
Â
-
March 19, 2019 at 2:54 pm
DrAmine
Ansys EmployeeWrong sytanx: Look into the Ffuent Customization.
Use pow function for power and use real as variable type.
-
March 20, 2019 at 9:31 am
Rob
Forum ModeratorYou need to make rate a real too: I just put the macro into the equation when I wrote the code a few years back for blood flow modelling.Â
-
September 27, 2019 at 10:53 am
Eirene2015
SubscriberAfter one day of digging in UDFs, i wrote and validated the following function.Â
No need to compile it and go through the whole miserable process of compiling UDFs in Ansys Fluent, just interpret it and use it,Â
Note that if you are initialising with zero velocity in the whole domain, then the shear rate at t=0 is equal to zero, which makes the formulation pow( 0 , p) diverge the simulation. Simply use a small value for a component of velocity to overcome this issue
Â
Â
/* Carreau-Yasuda Viscosity Model */
#include "udf.h"
Â
DEFINE_PROPERTY(cell_viscosity,c,t)
{
real mu_inf=0.00345;
real mu_zero=0.16;
real lambda=8.2;
real p=0.64;
Â
real n=0.2128;
real mu_lam;
real rate=(C_STRAIN_RATE_MAG(c,t));
mu_lam=mu_inf + (mu_zero-mu_inf) * pow(1.0 + pow( lambda*rate , p ) , (n-1)/p );
Â
return mu_lam;
}
Â
Â
-
- The topic ‘UDF for Carreau-Yasuda Viscosity model’ is closed to new replies.
-
6570
-
1906
-
1463
-
1311
-
1022
© 2026 Copyright ANSYS, Inc. All rights reserved.
