TAGGED: multiphase, surface-tension, udf, vof
-
-
March 11, 2021 at 4:32 pm
Venky_94
SubscriberHello,
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.
March 11, 2021 at 6:06 pmRob
Forum ModeratorIt'll be a cell loop, and you may want to use a UDM to store the data. nMarch 11, 2021 at 6:19 pmVenky_94
SubscriberI'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)nnMarch 12, 2021 at 5:00 amYasserSelima
SubscriberIn 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!nMarch 12, 2021 at 3:29 pmRob
Forum ModeratorBreak your problem down. Then work out what/when/how to complete each step.March 12, 2021 at 5:31 pmVenky_94
SubscriberHey 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)? nMarch 15, 2021 at 3:38 pmRob
Forum ModeratorThe 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. nMarch 19, 2021 at 10:25 pmVenky_94
SubscriberThanks, I was able to figure out a way to implement that based on your suggestion. I've written a UDF for calculating the non-Newtonian viscosity and storing it in a UDM using a DEFINE_ADJUST macro. But I'm getting errors of uninitialized local variable 't' used and uninitialized local variable 'c' used. I understand it is because the thread pointer is unknown but I'm not sure how to access the thread of the particular phase.nThe code worked well when defined using DEFINE_PROPERTY macro directly under material properties. I need the thread that would be passed by the solver to UDF in case of a DEFINE_PROPERTY macro under pt, here in order to do the same calculation. How would I go about that?./******************************************************************************nUDM for storing the non-Newtonian fluid viscosity calculated using APL modeln*******************************************************************************/n#include udf.hnDEFINE_ADJUST(non_newtonian_viscosity_udm, domain)n{nThread *t, *pt;nThread *mixture_thread = THREAD_SUPER_THREAD(t);npt = THREAD_SUB_THREAD(mixture_thread, 0);ncell_t c;ndomain = Get_Domain(2);tt/*Defines the primary phase which is the non-Newtonian fluid */nn/* Declare the coefficients for APL model to calculate non-Newtonian viscosity */nreal mu_0 = 15.9350;nreal k = 19.5531;nreal n = 0.2891;nreal p = -1.00;nreal shear_rate;nn/* Calculate the viscosity and store in UDM */nshear_rate = C_STRAIN_RATE_MAG(c,pt);nC_UDMI(c,pt,0) = pow((pow(mu_0,p) + pow((k*pow(shear_rate, (n-1))),p)),pow(p,-1));n}nApril 16, 2021 at 5:15 pmVenky_94
Subscribern 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?nApril 17, 2021 at 2:20 amYasserSelima
Subscriberrho and mu are calculated based on mass fraction, not volume fractionnApril 18, 2021 at 1:43 amVenky_94
SubscribernI 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*nApril 19, 2021 at 8:51 amRob
Forum ModeratorIf 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? nApril 19, 2021 at 1:06 pmVenky_94
SubscriberI'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. n
And here is an image of the property I'm obtaining through my UDF.n
I'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
April 19, 2021 at 3:15 pmDrAmine
Ansys EmployeeAre 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!nApril 19, 2021 at 3:35 pmVenky_94
SubscriberHi 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?nnApril 19, 2021 at 10:58 pmVenky_94
SubscriberHey 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.nApril 20, 2021 at 9:43 amDrAmine
Ansys EmployeeAre you plotting node values along the axis? What is your resolution along the line?nApril 21, 2021 at 2:57 pmVenky_94
SubscriberI 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. nViewing 17 reply threads- The topic ‘UDF for fluid property determination in VOF’ is closed to new replies.
Innovation SpaceTrending discussionsTop Contributors-
5849
-
1906
-
1420
-
1305
-
1021
Top Rated Tags© 2026 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-
The Ansys Learning Forum is a public forum. You are prohibited from providing (i) information that is confidential to You, your employer, or any third party, (ii) Personal Data or individually identifiable health information, (iii) any information that is U.S. Government Classified, Controlled Unclassified Information, International Traffic in Arms Regulators (ITAR) or Export Administration Regulators (EAR) controlled or otherwise have been determined by the United States Government or by a foreign government to require protection against unauthorized disclosure for reasons of national security, or (iv) topics or information restricted by the People's Republic of China data protection and privacy laws.
