Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

Implementation of the SA-Catris Model using a UDF

    • Aidan Murphy
      Subscriber

      I am having some difficulties regarding User-Defined Functions to adjust the built-in Spalart-Allmaras turbulence model. I have created a UDF for the Catris-Aupoix Compressibility corrections to the Spalart-Allmaras 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 SA-noft2-CatrisCon 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:
          • cb2 and sigma are constants, nu_tilde is called as C_NUT(c,t) (the SA model transport variable), rho is called as C_R(c,t), and the gradients are the reconstructive gradients called as C_NUT_RG(c,t) and C_R_RG(c,t).
      • 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 built-in 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 built-in 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.

    • Luca 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 

       

       

       

      • Aidan Murphy
        Subscriber

        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 open-source and allow for alteration of the built-in 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 SA-noft2 according to the Fluent Theory Guide) and my UDF for the SA-noft2-CatrisCon 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 user-defined source term and all the memory location variables needed
          • I also include a definition that allows for the reconstructive gradient to be taken on user-defined 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 user-defined 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 user-defined scalars
        • Define source terms
          • The first source term is generated from the reconstructive gradient of the user-defined 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/retain-temporary-solver-mem. 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

Viewing 1 reply thread
  • You must be logged in to reply to this topic.