

August 14, 2023 at 8:05 pmAidan MurphySubscriber
I am having some difficulties regarding UserDefined Functions to adjust the builtin SpalartAllmaras turbulence model. I have created a UDF for the CatrisAupoix Compressibility corrections to the SpalartAllmaras model and was able to implement the corresponding source terms, however, the computational results with these corrections do not significantly alter the results as they should for the specific cases I am running. The results are changing very slightly so I believe I am altering the modified eddy viscosity variable within the SA model transport equation correctly, but not to the correct magnitude. Below I will provide more information about the specifics:
 I am focusing on the SAnoft2CatrisCon model which has no ft2 trip terms and does not have the conservative advection term (more details on the model for implementation that I have referenced is here: https://turbmodels.larc.nasa.gov/spalart.html#saCatris)
 This leads to the addition of only 2 source terms that takes the place of the S_nut variable in the SA transport equation in Fluent (NonAnsys documentation link removed  Rob)
 Source term 1 is implemented as follows:
 sigma is a constant and the contents inside of the partial with respect to x_j are implemented as a scalar where nu_tilde is called as C_NUT(c,t) (the SA model transport variable), and the gradient of rho is the reconstructive gradient called as C_R_RG(c,t), then that scalar's reconstructive gradient is implemented in the source term as C_UDSI_RG(c,t,0).
 Source term 2 is implemented as follows:
 The cases being used to examine the effects of the Catris modification for validation of the UDF are a hypersonic flat plate and a 36° compression corner in hypersonic flow (https://turbmodels.larc.nasa.gov/Other_exp_Data/SBLI_various_marvin/NASATM_2013_216604.pdf)
 Case 1: Holden Mach 11.1 Flat Plate
 Case 2: Holden Mach 11.3 36° Compression Corner
 Comparison is made to experimental results and computational results completed by Gnoffo (cited in the link above)
 The UDF can not be attached to this post but can be provided if needed
I can provide contour plots or any results that I have if needed, but since this is a specific question regarding the UDF implementation of modifications to a builtin turbulence model I will keep it brief. I know of other CFD codes that are used in academia that allow for the alteration of the builtin turbulence models using changes to the source code, but I am using ANSYS Fluent for other projects, so any help or assistance on this matter would be greatly appreciated.
 I am focusing on the SAnoft2CatrisCon model which has no ft2 trip terms and does not have the conservative advection term (more details on the model for implementation that I have referenced is here: https://turbmodels.larc.nasa.gov/spalart.html#saCatris)

August 25, 2023 at 11:45 amLuca B.Ansys Employee
Hi, UDF manipulation is fully described in the Fluent Customization Manual. I invite you to refer to it to undertand how to add and modify all the terms. There are specific Macro to customize this turbulence model.
Usually as Ansys Employee we do not support UDF testing and correction, so I cannot debug your code.
Luca

August 25, 2023 at 4:16 pmAidan MurphySubscriber
Luca,
In the last few months of developing and validating the UDF I have, I spent a majority of my time reading through the entire UDF manual to understand how to modify all the terms and use specific macros to customize the turbulence model. I know of other CFD codes that are opensource and allow for alteration of the builtin turbulence modeling using their source code, however, I would like to continue using Fluent. I know ANSYS employees typically can not help too much due to proprietary information, however, if you are able to assist in the theory of how I developed and implemented the UDF, that would be greatly appreciated.
Currently, the UDF I have is supposed to alter the SA transport variable (nu tilde), but the results for the hypersonic flat plate and compression corner cases I have run do not change between the SA model in fluent (which is actually the SAnoft2 according to the Fluent Theory Guide) and my UDF for the SAnoft2CatrisCon turbulence model. Below I will outline my method for coding the UDF and the implementation method and if you are able to note any discrepancies in the proper method of implementing the UDF it would be greatly appreciated.
The UDF is currently coded as follows:
 Define all necessary coefficients
 Define the userdefined source term and all the memory location variables needed
 I also include a definition that allows for the reconstructive gradient to be taken on userdefined scalars
 Execute on loading the naming of all scalars and memory locations
 Define the adjust function hook
 Inside this, I loop through the threads and cells
 Here is where I define the userdefined scalar which is the terms inside of the partial w.r.t. x_j from source 1 in the above post.
 Also within the adjust function hook is a function that enables the derivative and reconstructive gradient to be taken for userdefined scalars
 Define source terms
 The first source term is generated from the reconstructive gradient of the userdefined scalar
 The second source term is coded following the equation from the above post
 Both source terms are treated as explicit (I have a UDF revision with implicit treatment of the source terms and that did not change the results)
To implement this UDF I first allocate the proper amount of scalars and memory locations. I then enable the retention of the temporary solver memory using the TUI command: solve/set/advance/retaintemporarysolvermem. I then initialize and run a single iteration with the regular SA model without the UDF to allocate all the temporary solver mem variables (specifically to retain the SA transport variable and its reconstructive gradient C_NUT(c,t) and C_NUT_RG(c,t)). After this single iteration has run, I compile and load the UDF, then turn off the scalar equation in the controls section, ensure the specified flux of the scalar is 0 for all boundary conditions, input the adjust function hook, and enable 2 source terms under the fluid cell zone conditions for the modified turbulent viscosity. I then reinitialize and run the case until convergence.
When running this same case using the SA model in fluent and using my UDF, the convergence of the nut variable changes, leading me to believe that the UDF is implemented correctly and is changing the SA transport variable (nu tilde), however, for every validation case I have run, the results simply do not change for pressure, wall shear, heat flux, boundary layer profile, etc.
If you are able to provide any feedback on the methods that I am employing to implement and code the UDF, I would greatly appreciate it. If this is simply a problem that can not be answered due to proprietary information or not being able to assist in specifics, please let me know so that I can then switch CFD codes to one that offers this assistance and guidance on turbulence modeling.
Thank you,
Aidan


 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?
 Heat transfer coefficient
 Difference between Kepsilon and Komega Turbulence Model
 Getting graph and tabular data from result in workbench mechanical
 The solver failed with a nonzero exit code of : 2
 Suppress Fluent to open with GUI while performing in journal file
 Mesh Interfaces in ANSYS FLUENT
 Time Step Size and Courant Number
 error: Received signal SIGSEGV

7584

4434

2951

1422

1322
© 2023 Copyright ANSYS, Inc. All rights reserved.