CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

[GUIDE] Switching turbulence model to SpalartAllmaras

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 4 Post By gabrielfelix

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 1, 2021, 10:20
Default [GUIDE] Switching turbulence model to SpalartAllmaras
  #1
Member
 
Gabriel Felix
Join Date: May 2021
Location: Brazil
Posts: 35
Rep Power: 5
gabrielfelix is on a distinguished road
Hi folks

I'm simulating a propeller in steady-state compressible flow using rhoSimpleFoam and I was using the kEpsilon turbulence model with the same boundary conditions as the pimpleFoam marine propeller tutorial. I wanted to run my case with the Spalart-Allmaras turbulence model and I faced some problems to which I could not find a direct guide to overcome them. I saw that there are many posts concerning the same problems I had, and I decided to create this guide, now that I managed to succesfully run my case with SA model.

I believe this guide will work for both compressible or incompressible conditions. I'm not expert on this SA model, so the solutions I will come up here might not be the most adequate ones, but rather the ones I managed to run my case with.

1. Change turbulence model in turbulenceProperties file:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

simulationType  RAS;

RAS
{
    RASModel        SpalartAllmaras;

    turbulence      on;

    printCoeffs     on;
}


// ************************************************************************* //
2. Modify 0/nut and create 0/nuTilda file

The nut represents the turbulent kinematic viscosity boundary conditions and nuTilda is similar to nut, but is the variable that the SA model actually iterates.

The [1] NASA Turbulence Modelling Resource and the document [2] Changes and Settings for Standard Turbulence Model Implementation in OpenFOAM suggest using the following viscosity ratios:
- nuTilda/nu = 3
- nut/nutTilda = 0.07

So if you are running a simulation at sea level rho = 1.225 and mu = 1.8e-5. Hence, nu =~ 1.5e-5. Therefore, using the viscosity ratios above, you should use nuTilda = 4.5e-5 and nut = 3.15e-6.

I configured nut and nuTilda files according to [2] boundary tables.

In nut file you must change wall boundary type to nutUWallFunction. I you are using other turbulence models there will be other variables such as nutkWallFunction. If you dont do this there will be errors on execution.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "0";
    object      nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -1 0 0 0 0];

internalField   uniform 3.15e-6;

boundaryField
{
    #includeEtc "caseDicts/setConstraintTypes"

    inlet
    {
        type            calculated;
        value           uniform 3.15e-6;
    }

    outlet
    {
        type            zeroGradient;
    }

    wall
    {
        type            nutUWallFunction;
        value           uniform 0;
    }
}


// ************************************************************************* //
In nuTilda you must not have any type calculted boundary conditions to avoid the following error massage when executing solver:
Code:
You are probably trying to solve for a field with a default boundary condition
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "0";
    object      nuTilda;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -1 0 0 0 0];

internalField   uniform 4.5e-5;

boundaryField
{
    #includeEtc "caseDicts/setConstraintTypes"

    inlet
    {
        type            fixedValue;
        value           uniform 4.5e-5;
    }

    outlet
    {
        type            zeroGradient;
    }

    wall
    {
        type            fixedValue;
        value           uniform 0;
    }
}


// ************************************************************************* //
3. Add nuTilda and R variables to fvSolution and fvSchemes files

When configuring these files you dont need to remove other turbulence model variables such as k, epsilon and omega. You can also keep their 0/ files.

I don't know what the R variable means, but if you dont add it to the files you will get the following warning on solver execution:
Code:
Turbulence kinetic energy not defined for Spalart-Allmaras model. Returning zero field
According to what I researched in other threads, you should not worry about this warning, however is better if can get rid of it.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default         steadyState;
}

gradSchemes
{
    default         Gauss linear;
    grad(p)         Gauss linear;
    grad(U)         cellLimited Gauss linear 1;
	grad(k)         cellLimited Gauss linear 1;
	grad(omega)     cellLimited Gauss linear 1;
}

divSchemes
{
    default         none;

    div(phi,U)      bounded Gauss linearUpwind limited;

    turbulence      bounded Gauss upwind;
    energy          bounded Gauss linearUpwind limited;

    div(phi,k)      $turbulence;
    div(phi,omega)  $turbulence;
	div(phi,epsilon)  $turbulence;

    div(phi,e)      $energy;
    div(phi,K)      $energy;
    div(phi,Ekp)    $energy;

    div(phid,p)     Gauss upwind;
    div((phi|interpolate(rho)),p)  bounded Gauss upwind;
	
	div(phi,nuTilda) bounded Gauss linearUpwind grad(nuTilda);
    div(((rho*nuEff)*dev2(T(grad(U)))))    Gauss linear;
	
	div(phi,R) bounded Gauss upwind;
	div(R) Gauss linear;
}

laplacianSchemes
{
    default         Gauss linear limited corrected 0.33;
}

interpolationSchemes
{
    default         linear;
}

snGradSchemes
{
    default         limited corrected 0.33;
}

wallDist
{
    method meshWave;
}


// ************************************************************************* //
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    "pcorr.*"
    {
        solver          GAMG;
        tolerance       1e-2;
        relTol          0;
        smoother        DICGaussSeidel;
        cacheAgglomeration no;
        maxIter         50;
    }

    p
    {
        $pcorr;
        tolerance       1e-5;
        relTol          0.01;
    }

    pFinal
    {
        $p;
        tolerance       1e-6;
        relTol          0;
    }

    "(U|k|epsilon|e|nuTilda)"
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance       1e-6;
        relTol          0.1;
    }

    "(U|k|epsilon|e|nuTilda)Final"
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance       1e-6;
        relTol          0;
    }
	
	R
	{
		solver PBiCG;
		preconditioner DILU;
		tolerance 1e-20;
		relTol 0;
	}
}

SIMPLE
{
    //correctPhi          no;
    //nOuterCorrectors    2;
    //nCorrectors         1;
    nNonOrthogonalCorrectors 1;
	
	// Set up residual controls. Simulation stops when residual target is reached
	residualControl
	{
		p					1e-6;
		//U					1e-4;
		//"(k|epsilon)"		1e-4;
	}
}

potentialFlow
{
    nNonOrthogonalCorrectors 1;
}

relaxationFactors
{
	fields
	{
		p 0.3 ;
		rho 0.01 ;
	}
	equations
	{
		U 0.7 ;
		e 0.7 ;
		k 0.7 ;
		omega 0.7 ;
		nuTilda 0.7 ;
		R 0.7;
	}
}

cache
{
    grad(U);
}


// ************************************************************************* //
4. Define nu value in transportProperties files

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

transportModel  Newtonian;

rho             1.225;

nu              1.5e-05;

// ************************************************************************* //

Last edited by gabrielfelix; September 2, 2021 at 07:27.
gabrielfelix is offline   Reply With Quote

Old   March 24, 2022, 20:19
Default
  #2
Senior Member
 
Join Date: Mar 2010
Posts: 173
Rep Power: 17
Jonathan is on a distinguished road
Very clear and very good. Thanks for documenting / sharing
Jonathan is offline   Reply With Quote

Reply

Tags
configuration, sa model, set up, spallart allmaras, turbulence model


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong multiphase flow at rotating interface Sanyo CFX 14 February 7, 2017 17:19
Question about matching of solver and turbulence model louistse OpenFOAM Running, Solving & CFD 1 February 1, 2017 21:36
Overflow Error in Multiphase Modelling with Two Continuous Fluids ashtonJ CFX 6 August 11, 2014 14:32
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44
Wrong calculation of nut in the kOmegaSST turbulence model FelixL OpenFOAM Bugs 27 March 27, 2012 09:02


All times are GMT -4. The time now is 18:21.