-
-
March 19, 2021 at 9:21 pm
vedama
SubscriberHello,nnI am trying to write a UDF to calculate turbulent viscosity based on Prandtl's mixing layer model (mu_t = a*delta) to use with the Spalart-Allmaras model. I performed the simulation using the default values first so I have a solution blueprint and then compiled the UDF, changed the Turbulent Viscosity in the Viscous dialog box to the udf value. However, I am now getting floating point exception in the first iteration itself. Could someone check my code, please? Not sure why I'm getting that error.nnI'm running a 2D second-order, pressure-based solver with Coupled scheme.n#include udf.hDEFINE_TURBULENT_VISCOSITY(mu_t1,c,t)n{ntreal a_const = 0.1;ntreal rho = C_R(c,t);ntreal dudy = C_DUDY(c,t);ntreal del = .000125;ntreal lm = a_const*del;ntreal mu_t = dudy*SQR(lm);ntntreturn mu_t;nn -
March 24, 2021 at 12:23 pm
KR
AdministratorHello,nHave you attempted to run the model without the UDF? Does it work?nAlso, I'd strongly recommend that you print the values of mu_t in your UDF. Use the Message statements. This will do two things: nIs the UDF working properly?nIs the magnitude of mu_t correct?nI don't see anything wrong with the UDF straightaway. I'm worried about the magnitude though (if it is too large or small depending on your initial conditions). nAlso, check your overall mesh quality and make sure that you have a good mesh.nKarthikn -
March 24, 2021 at 2:49 pm
vedama
SubscriberHi Karthik,nnThanks for your response. You were right, the magnitude is rather large. I scaled it down by 3 orders of magnitude and it seems to work fine now. I'm relatively new to the world of UDFs, if you don't mind answering, why does a large magnitude cause it to fail? Would it not just give you a (horribly) wrong answer? My understanding of floating point exceptions is that it tries to divide by zero. How or where is the zero popping up, if the mu_t is off by a large magnitude? Thanks for your help!n -
March 24, 2021 at 3:37 pm
YasserSelima
SubscriberThe way the solver works is by iterations ... having initial guess, and using it to calculate the residuals which is used to modify the guess ... by repeating this process, the values of the residuals keeps decreasing and the solution converges. However, if the initial guess is too far from the solution, the the 2nd guess might be further away ... and as iterations proceed, the values become too large and/or too small ... for example velocity = 1e+35 ... n
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.Â

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Difference between K-epsilon and K-omega Turbulence Model
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- Suppress Fluent to open with GUI while performing in journal file
- error: Received signal SIGSEGV
- Using GPU in FLUENT
-
8786
-
4658
-
3151
-
1680
-
1468
© 2023 Copyright ANSYS, Inc. All rights reserved.