## Fluids

#### Fluent udf- multiphase; vof dependent viscosity

• Outy95
Subscriber
Hello all,

I want to write a udf to calculate the properties (mainly viscosity) as attached in the file and not use the regular linear interpolation at the interface in case of VOF method. Any help will be appreciated. I used DEFINE_PROPERTY macro and i had some issues with the parse error and other things.

I want to ask fluent to calculate the properties based on the equation attached and not on the linear method with VOF.

P = P1 + (P1-P2)*(VOF^C) instead of P = P1 + (P1-P2)*(VOF).
I'm looking to alter the calculations for viscosity, generally. Can you suggest how to proceed?
• DrAmine
Ansys Employee

Use the same viscosity information /formula for each phase so that the mixture viscosity is what you expect

• Outy95
Subscriber

Hi. Thank you for taking time to answer the question. Can you please elaborate it? Because for individual phase VOF would be either 1 or zero and essentially the formula would result in the same thing that I want to alter.

• DrAmine
Ansys Employee
You use the same function for viscosity for both phases. Let us assume the function is myvisc. The mixture viscosity will be then alpha1×myvisc+alpha2×myvisc.
• Outy95
Subscriber

Hello Amine,

I tried your suggestion but there seems to be a problem in UDF in employing the volume fraction for phase 1(primary phase). Let me elaborate.

Suppose viscosity for air is A and for liquid is L and "a" is the volume fraction of water and c is a constant.The desired equation for viscosity is:

V(mixture) = A + (L-A)*(a^c)

Now assuming the viscosity functions for air and liquid as suggested,

V(air) = A

V(liquid) = A +(L-A)*a^(c-1)

From the formula, V(mixture) = V(air)*(1-a) + V(water)*a = A*(1-a) +  A*a + (L-A)*(a^c) = A + (L-A)*a^c.

Okay, so part one is clear. Can you suggest how to incorporate the volume fraction of liquid into the DEFINE_PROPERTY UDF? Or is there another way for defining the vof? I mean C_VOF() would evaluate for each cell and then I have to loop the VOF in order to cover the entire domain, but the DEFINE_PROPERTY macro already seems to do the looping. Can you help me with setting up the UDF? I know Ansys staff isn't supposed to help in Udf but any ideas/clues would be appreciated.

• Rob
Ansys Employee

But if you're looking at multiphase the viscosity is linked to each PHASE. The phase volume fraction doesn't matter as the phase motion is calculated by Fluent. You also need to read up on the approach (and limitations) of the VOF model.

• DrAmine
Ansys Employee

No: I suggested to use the same expression for both phases: V(mixture) = A + (L-A)*(a^c)= Vair=Vliquid

• Outy95
Subscriber

Hello Amine,

As per your suggestion I used the same formula for both phases. Below is my udf:

#include "udf.h"

#include "math.h"

DEFINE_PROPERTY(Liquid_viscosity,c,t)

{

cell_t c;

real mu_L = 0;                     /*A is the value for C; Equation is PHI=PHI2+(PHI1-PHI2)*VOF^(1.5*(NU1/NU2)+0.75)*/

real mu_liquid = 0.0497;                 /*Put respective value*/

real mu_air = 0.00001789;                    /*Put respective value*/

real A = 4.967;                         /*Calculate A from A = 1.5*(Nu1/Nu2)+0.75*/

real vof = 0;

vof = C_VOF(c,pt[0]);

mu_L = mu_air + (mu_liquid - mu_air)*(pow(vof,A));

return mu_L;

}

When I interpret them, I do a message stating values of c definition shadows previous definition;

When I run the solution, it comes with an error:

fl process could not be started

• Outy95
Subscriber

Hi rwoolhou,

I'm running a special case for highly viscous fluids where the interface properties have to be calculated in the stated manner, not as a linear one. I'm sort of modifying VOF specially for the viscosity part.

• DrAmine
Ansys Employee
First of all I would compile. Second, UDF is wrong. Please check customization manual.
• Venky_94
Subscriber
Hey, were you able to sort out the issue? I need to use the exact same equation for the fluid property estimation in my work and in my case the viscosity of the primary fluid is non-Newtonian based on an asymptotic power law as well and is not a fixed value unlike in yours. So I was wondering if Fluent UDFs can handle that sort of manipulation or if I would have to go with OpenFOAM for this issue. Any help in this regard would be much appreciated.n
• Rob
Ansys Employee
We can do pretty much anything with UDFs or Expressions in the current releases. The fluid viscosities are easy, adding in terms for when you're near the interface may need more work. n
• Venky_94
Subscriber
Hey Rob, thanks for the response. I've explained my problem in specific detail in the below post. Could you please have a look at it and suggest a way?nhttps://forum.ansys.com/discussion/25526/udf-for-fluid-property-determination-in-vof#latestn