## Fluids

#### How to write UDF for Dynamic viscosity??

• Devank12
Subscriber

I have one dynamic viscosity equation which is depend on fluid temperature and i want to apply that equation in a flow through a pipe. So how to  write the user defined function. .

• DrAmine
Ansys Employee

Search in the Fluent customization for the macro DEFINE_PROPERTY and create the expression for the viscosity,

• klu
Ansys Employee

• seeta gunti
Ansys Employee

Hello Devank,

You can refer Fluent Customization documentation under "Detailed Examples". In that, DEFINE_PROPERTY macro is explained with an example of a variable viscosity  profile to simulate the solidification. You can try the similar UDF with dynamic viscosity profile. Hope this help you.

• Devank12
Subscriber

#include "udf.h"

DEFINE_PROPERTY (cell_viscosity,c,t)

{

real mu;

mu =2.414*e-05* double pow(double 10, double 248/T-140);

return mu;

}

i have developed a UDF for dynamic viscosity . i dnot know which is correct. if any correction plz inform me

• Nownesh
Ansys Employee

Hello

In DEFINE_PROPERTY (cell_viscosity,c,t), and  real temp = C_T(cell, thread);... c,t and cell & thread names should be consistent.

• DrAmine
Ansys Employee

#include "udf.h"

DEFINE_PROPERTY(cell_viscosity,c,t)

{

real mu = 1e-5;

real fac = 1.0;

fac = 248.0/(C_T(c,t)-140.0);

mu =2.414*exp(-0.5)*pow(10.0,  fac);

C_UDMI(c,t,0) = mu;

return mu;

}

Please check the customization manal and attend a UDF Training.

• dsub5
Subscriber

hello everyone. i have to create udf for dynamic viscosity and thermal conductivity coefficient. but have no idea about codes.

here is the formulas. if anyone can help me, i wii be glad.

mu=(3.4*10^-7*T^2)-(2.3*10^-4*T)+(3.9*10^-2)

k=0.004961*T-0.8078

Subscriber

hello,

i am running the same udf you posted as i need the same values however after i interpret the udf and change the viscosity to user defined, when i try to initialise and calculate i get an error message saying "f1 process could not be started" and fluent automatically closes.

• DrAmine
Ansys Employee
Try to compile.
Subscriber

Hi Amine,

Is there anything i need to change in the code to compile? (I am still new to ansys)

Thanks

• DrAmine
Ansys Employee

You need to install a compiler. Check in the forum for several Compiler threads. In your case your using the UDF I Posted I guess. Please check if you have defined a User Memory in Fluent.

• Eirene2015
Subscriber

made me go through a whole day learning how to compile the UDFs, but the issue is the fact that his syntax is wrong.

C_UDMI(c,t,0) is not defined yet, so you cannot allocate values to it, thus the user receives a segmentation fault error!

This UDF does not require compilation. A simple interpret will work as long as the issue of C_UDMI(c,t,0) is omitted.

Do not wast time in compiling this code as I did!