Fluids

UDF for fluid property determination in VOF

• Venky_94
Subscriber

Hello,

I want to write a UDF to calculate the fluid properties (density & viscosity) through a modified exponential equation as attached in the file and not use the regular linear interpolation at the interface in case of VOF method.

• Rob
Ansys Employee
It'll be a cell loop, and you may want to use a UDM to store the data. n
• Venky_94
Subscriber
I'm sorry I'm not quite familiar with UDFs yet. Do you want me to store the density and viscosity that I'm calculating using the modified method in a UDM? I'll look on how to accomplish that. But I have a couple of follow up questions though.nWhere would I hook the UDF or call it? How do I pass on the calculated values to the momentum equation?nAnd how would I ensure that the values I calculate are the ones being used while solving the momentum equation? (what is the link)nn
• YasserSelima
Subscriber
In the UDF manual, Look for multiphase looping macros. You will find an example Define_init ... This example loops over all cells in mixture domain. Use it as your starting point ... You will need to use Define_Adjust instead of define_init ... and You will use C_R macro for the density ... not sure about the viscosity. nIt needs hard work and probably weeks of debugging. Good Luck!n
• Rob
Ansys Employee
Break your problem down. Then work out what/when/how to complete each step.
• Venky_94
Subscriber
Hey Rob, I have an idea what I want to achieve in a step-by-step manner, but what I'm not sure of is the last part. I know that I can hook the phase viscosity using DEFINE_PROPERTY macro under material properties, how would I go about hooking the mixture property in this case??nHook a UDF (1) for the non-Newtonian viscosity for the primary fluid.nCreate another UDF (2) in which the area-averaged phase fraction is calculated and is used for the mixture fluid property determination using the modified exponential method.nCreate a source term UDF (3) for handling the interface curvature smoothening.nWhere to hook the second UDF (2)? n
• Rob
Ansys Employee
The averaging would be a function of volume fraction and phase viscosity, you'll just need to be careful with the definitions to link the correct property with the correct phase. That can be stored in a UDM. nIf you want to set a mixture viscosity you could use a UDM to determine the non-Newtonian viscosity, then use another UDM as above then use the DEFINE_PROPERTY for each phase. The VOF model will handle the free surface position. n
• Venky_94
Subscriber
• Venky_94
Subscriber
n I tried the below approach based on your suggestions to see if I could replicate the results of the solver's native VOF adaption, without any modification, using UDF to see if the approach is right. I tried out the simulation for just water and air.nI created property UDFs for both density and viscosity separately, as below, which I hooked onto both the fluids (air and water) and used the VOF of the primary phase.nrho = rho2 + ((rho1 - rho2)*C_VOF(c, pt);nmu = mu2 + ((mu1 - mu2)*C_VOF(c, pt);nMy residuals have a sawtooth profile to start with and as the flow time progresses the sawtooth profile is enlarging in magnitude (the oscillations are more) and after around 1e-4 seconds, I'm starting to get reversed flow on outlet and the number of faces with reversed flow seems to grow with time and the solution sharply diverges within a span of two time steps around 3e-4 seconds. I'm running with a time step of 1e-7 seconds and when I'm running a regular VOF case without the UDF there are no issues with the convergence.nCould you please suggest?n
• YasserSelima
Subscriber
rho and mu are calculated based on mass fraction, not volume fractionn
• Venky_94
Subscriber
nI know that rho and mu are based on mass fraction for mixtures. But my purpose here is to change the way in which the properties are being determined at the interface. I see that the properties at the interface depend on the phase fraction as below, which is what I'm trying to replicate using a UDF.nPlease correct me if I'm wrong in this aspect.n*SCREENSHOT REMOVED by DrAmine*n
• Rob
Ansys Employee
If it works without the UDF and fails with the UDF then I'd be looking at what the UDF is doing. I'd also see about hooking the UDF up to calculate the values only, and not apply them in the working VOF case. How do the flow and properties differ from the ones Fluent is using? n
• Venky_94
Subscriber
I'm definitely sure the issue is with the UDF somewhere, but I'm unable to quite put a finger on what exactly. Below is a picture of the expected variation in properties as compared to Fluent's native method. The UDF I've written right now is the original implementation of FLUENT's VOF, so I'm expecting an arithmetic weighted average as the green line below. nAnd here is an image of the property I'm obtaining through my UDF.nI'll try maybe storing the property values in a file along with the phase fraction to see if I can get any information on it. But any other suggestions would be great.nn
• DrAmine
Ansys Employee
Are you trying to modify the density? What is the purpose of changing one of the primitive variables? What do you want to do?nBy the way: better to use the same function for both phases so that the phase weighted average is the density you wan to have!n
• Venky_94
Subscriber
Hi Array ,nThe purpose is to better study the interfacial property in highly viscous fluids. I'm only using water to begin with. The significance and effectiveness of the function in determining interface property is best explained in the first picture involving a comparison. And to answer the question, yes, I'm trying to modify the way density and viscosity at the interface are determined in VOF solver.nAnd for the second part of your answer, if you could take a look at my below response, I am using the same function for both phases (water and air). I've shared the functions I'm using for density and viscosity. Any suggestions on how to avoid the issues I'm facing?n ,nThe purpose is to better study the interfacial property in highly viscous fluids. I'm only using water to begin with. The significance and effectiveness of the function in determining interface property is best explained in the first picture involving a comparison. And to answer the question, yes, I'm trying to modify the way density and viscosity at the interface are determined in VOF solver.nAnd for the second part of your answer, if you could take a look at my below response, I am using the same function for both phases (water and air). I've shared the functions I'm using for density and viscosity. Any suggestions on how to avoid the issues I'm facing?nn
• Venky_94
Subscriber
Hey Array ,nI tried out suggestion and created a Adjust UDF to store the values of density and viscosity along with the phase fraction of both the native method and the values calculated by my UDF function in separate files and compared them.nThe values of density are exactly the same in both cases for the same value of phase fraction, and the viscosity is almost similar but varies by around +/- 0.0005%, which is too small to make a difference I think. So I'm not sure exactly why this approach isn't working. Please suggest.n
• DrAmine
Ansys Employee
Are you plotting node values along the axis? What is your resolution along the line?n
• Venky_94
Subscriber
I did not need to plot the values. I obtained the density and viscosity values for all cells with phase fraction between 0 & 1. And since there were only 40 or so cells, I directly compared the values. n