CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Spalart Allmaras Solver Implementation

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 21, 2020, 12:50
Default Spalart Allmaras Solver Implementation
  #1
New Member
 
bharadwaz
Join Date: Nov 2018
Location: India
Posts: 19
Rep Power: 7
bharadwaz is on a distinguished road
Hi all,
I am trying to add FVM spalart allmaras model to my solver. I am not sure about my descretization of terms as i am getting incorrect results. Can someone help me in this. Also which terms are to be considered implicit and explicit including coefficients calculation.

Thanks in advance.

PS: I am solving for incompressible flat plate case and tring to validate nasa results.
bharadwaz is offline   Reply With Quote

Old   September 22, 2020, 07:56
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
The Ph.D. thesis of Gianluca Iaccarino has a section on the discretizazion of the SA model.

The only fancy part is one of the diffusion terms, which requires some rearrangements to be stably discretized.

The original SA paper, if I recall well, also mentions how to treat the source terms

However, not sure if these are going to help with uncorrect results
sbaffini is offline   Reply With Quote

Old   September 22, 2020, 09:00
Default
  #3
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
I would not, in general, advise to do so, but you can also give a look at OpenFOAM (which requires being able to read it), as last time I checked it seemed roughly correct in its major aspects of the implementation.

PS I have a working SA solver whose main details could be shared, but I won't have access to a pc for few days, so you better delve into it by yourself
sbaffini is offline   Reply With Quote

Old   September 22, 2020, 12:20
Default
  #4
New Member
 
bharadwaz
Join Date: Nov 2018
Location: India
Posts: 19
Rep Power: 7
bharadwaz is on a distinguished road
Thanks for taking your time. I have followed OF already, however exact descretization is not mentioned. Also rearragment means possibly this i guess, attaching image. I also had a small doubt after converting it to FVM both cb2 terms can cancel out for diffusion part although i didn't cancel it. Can you explain how did you descretize this diffusion part in detail.

Any advice/suggestions are always welcome.

I am not able to find above mentioned thesis, can you provide link or pdf.

Thanks.
Attached Images
File Type: png Spalart_modified.png (60.9 KB, 66 views)
bharadwaz is offline   Reply With Quote

Old   September 23, 2020, 03:47
Default
  #5
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Yes, that's the arrangement

Couldn't upload the full thesis (it's too large), but these two files have everything you need about SA.

Still, I would suggest reading the original SA paper as well (or some of those that came out in the same period), because it explicitly explains how to treat the source terms
Attached Files
File Type: pdf gi_thesis_sa_1.pdf (69.9 KB, 55 views)
File Type: pdf gi_thesis_sa_2.pdf (71.1 KB, 46 views)
ssh123 and hasini like this.
sbaffini is offline   Reply With Quote

Old   September 23, 2020, 04:02
Default
  #6
New Member
 
bharadwaz
Join Date: Nov 2018
Location: India
Posts: 19
Rep Power: 7
bharadwaz is on a distinguished road
Thanks alot sbaffini, I will go through the material.
bharadwaz is offline   Reply With Quote

Old   September 23, 2020, 12:49
Default
  #7
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Note that cb2 terms won't cancel each other because the one on the conservative term has to be evaluated on the face between the two cells sharing the flux, while the one in the non-conservative term has a (nu+nutilda) coefficient which is evaluated on the cell where the flux is given (so it is different between the two cells sharing the face and the flux is not conservative)

EDIT: please DON'T look at how openfoam does it because, as in most things, it has an uninformed, naive, pedestrian implementation using the original equation form and treating the term explicitly, which is not what you should do. I should have looked at it before suggesting to consider it. My bad
arjun and hasini like this.
sbaffini is offline   Reply With Quote

Old   September 23, 2020, 14:24
Default
  #8
New Member
 
bharadwaz
Join Date: Nov 2018
Location: India
Posts: 19
Rep Power: 7
bharadwaz is on a distinguished road
Thanks alot for explaining.
Do you mean the diffusion expansion is as follows
(1+cb2)/sigma*(nu+nuTilda_old)*grad(nuTilda)*sf - cb2/sigma*(nu+nuTilda)*grad(nuTilda_old)*sf

Production = cb1*sTilda*nuTilda_old
Dissipation = cw1*fw*nuTilda_old*nuTilda / (d*d)

Xi = nuTilda_old/nu
sTilda = Omega + nuTilda_old*fv2 / (k*k*d*d)
r = nuTilda_old / (sTilda*k*k*d*d) ---> limiting to 10 for higher values

Correct me if i am wrong.
I guess other terms also am doing it wrong(production and dissipation). Could you please send links/relevant material to my mail

mail id : me18mtech01002@iith.ac.in
bharadwaz is offline   Reply With Quote

Old   September 24, 2020, 07:12
Default
  #9
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
I've sent you an email with material that should cover everything you need to discretize the SA model
sbaffini is offline   Reply With Quote

Old   May 25, 2021, 06:53
Default
  #10
New Member
 
Join Date: Mar 2011
Posts: 5
Rep Power: 15
Oliver is on a distinguished road
Hello bharadwaz, sbaffini,

I am trying to implement the S-A model in a 2D compressible FVM code, but like bharadwaz mentioned, I am uncertain of the discretization of terms, and the solver has severe stability issues.

Searching through the forum, I came across this thread, which seems to address the same issues I am facing.

Any help with the discretisation would be much appreciated.

To provide some additional details into what I have attempted so far:

- the implementation uses the "standard" SA equation for nuTilda >=0 and SA-neg equation for nuTilda < 0

- both SA and SA-neg equations have been written in conservation form following the approach indicated in "Allmaras, S. R., Johnson, F. T., and Spalart, P. R., "Modifications and Clarifications for the Implementation of the Spalart-Allmaras Turbulence Model," ICCFD7-1902"

- the grad(nuTilda)^2 term has been left "as is" so far

- source terms have been treated implicitly, but diffusion is still explicit (guessing this might be the main problem?)

Thanks in advance.
Oliver is offline   Reply With Quote

Old   May 25, 2021, 11:56
Default
  #11
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Dear Oliver, I have no experience with the negative SA formulation but, if I had to point at something I would certainly investigate the explicit diffusion. How do you advance the equations? Because you should still be able to determine a safe (pseudo) time step to work in explicit as well.
sbaffini is offline   Reply With Quote

Old   May 25, 2021, 15:45
Default
  #12
New Member
 
Join Date: Mar 2011
Posts: 5
Rep Power: 15
Oliver is on a distinguished road
The flow equations use a 4-stage Runge Kutta scheme. The turbulence equation is solved segregated, using a Newton-like treatment of the implicit source term:

(I/delta_t - dQ/dW) * delta_w = Res(W^n) + Q(W^n)
W^(n+1) = W^n + delta_W

with
Q being all the source terms, including the non-conservative diffusion term grad(niuTilda)^2 (which has not been linearized in my implementation)
W = Rho*niuTilda
delta_t is the same (local) time step determined for the flow equations
Oliver is offline   Reply With Quote

Old   May 26, 2021, 06:00
Default
  #13
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Ok, two things:

1) If you read previous posts in this thread you will notice that we discussed how to actually discretize the non-linear term, look in particular at the excerpts from the Iaccarino thesis. In practice, it is recast as two flux terms, only one being actually conservative (the other, basically, puts different things in the two adjacent cells). I think this is a major point in the SA implementation, even if purely explicit (see point 2)

2) Even if I just use it for tests, I actually have an explicit (multi-stage RK) implementation, explicit also for the source terms. As for you, I compute the local time steps from the main equations (coupled) and use them for all the remaining segregated equations (turbulence, scalars, etc.). For me it just works. Obviously, it becomes of paramount importance how you actually compute the time steps then. I suggest to use one of the methods presented in the book by Blazek and, if in doubt, pick a conservative/robust approach. More specifically, what I use is:

\Delta t = CFL \frac{V}{\sum_f{\left(\lambda_c + \lambda_v\right)_f A_f}}

where V is the cell volume, the sum is over the cell faces with area Af and the lambdas are the eigenvalues of the convective (the max over the set of the coupled ones taken with absolute values) and viscous part (4/(rho D) times the maximum between mu and k/cp, with D being the distance between the cell centers adjacent to the face... I don't know anymore where the 4 comes from).

As you see, it is pretty much conservative, but then I'm sure that it has to work, at least for the main coupled equations. But then, it typically also works for the remaining equations.
sbaffini is offline   Reply With Quote

Old   May 28, 2021, 15:06
Default
  #14
New Member
 
bharadwaz
Join Date: Nov 2018
Location: India
Posts: 19
Rep Power: 7
bharadwaz is on a distinguished road
Quote:
Originally Posted by Oliver View Post
Hello bharadwaz, sbaffini,

I am trying to implement the S-A model in a 2D compressible FVM code, but like bharadwaz mentioned, I am uncertain of the discretization of terms, and the solver has severe stability issues.

Searching through the forum, I came across this thread, which seems to address the same issues I am facing.

Any help with the discretisation would be much appreciated.

To provide some additional details into what I have attempted so far:

- the implementation uses the "standard" SA equation for nuTilda >=0 and SA-neg equation for nuTilda < 0

- both SA and SA-neg equations have been written in conservation form following the approach indicated in "Allmaras, S. R., Johnson, F. T., and Spalart, P. R., "Modifications and Clarifications for the Implementation of the Spalart-Allmaras Turbulence Model," ICCFD7-1902"

- the grad(nuTilda)^2 term has been left "as is" so far

- source terms have been treated implicitly, but diffusion is still explicit (guessing this might be the main problem?)

Thanks in advance.
Hello Oliver, I discretized the grad(nuTilda)^2 as gradnuTildaX*gradnuTildaX + gradnuTildaY*gradnuTildaY.You can get the gradients using green gauss or simple difference like forward, backward or centre difference. In my case I have treated this term explicitly.
bharadwaz is offline   Reply With Quote

Old   May 28, 2021, 15:45
Default
  #15
New Member
 
Join Date: Mar 2011
Posts: 5
Rep Power: 15
Oliver is on a distinguished road
I have managed to get it to work, eventually.

I have treated the grad(NuTilda)^2 just like you indicated bharadwaz, and I have kept the implicit treatment of the source term, like I indicated in my previous posts.

The main issue was with the SA-neg equation. As soon as I fully switched to the classic SA model, the stability issues were solved. I am still not getting very accurate results, but I plan to improve the gradient calculation method, and especially how gradient values are estimated at the cell faces from the cell centre values.

I am surprised about the SA-neg behaviour, because references I went through indicated it should not pose more problems compared to the classic SA model.

Maybe I just misunderstood how SA and SA-neg should work together.

Thanks for the help.
Oliver is offline   Reply With Quote

Old   November 12, 2021, 08:38
Default
  #16
New Member
 
Join Date: Nov 2021
Posts: 8
Rep Power: 4
Jinn is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
Ok, two things:

1) If you read previous posts in this thread you will notice that we discussed how to actually discretize the non-linear term, look in particular at the excerpts from the Iaccarino thesis. In practice, it is recast as two flux terms, only one being actually conservative (the other, basically, puts different things in the two adjacent cells). I think this is a major point in the SA implementation, even if purely explicit (see point 2)

2) Even if I just use it for tests, I actually have an explicit (multi-stage RK) implementation, explicit also for the source terms. As for you, I compute the local time steps from the main equations (coupled) and use them for all the remaining segregated equations (turbulence, scalars, etc.). For me it just works. Obviously, it becomes of paramount importance how you actually compute the time steps then. I suggest to use one of the methods presented in the book by Blazek and, if in doubt, pick a conservative/robust approach. More specifically, what I use is:

\Delta t = CFL \frac{V}{\sum_f{\left(\lambda_c + \lambda_v\right)_f A_f}}

where V is the cell volume, the sum is over the cell faces with area Af and the lambdas are the eigenvalues of the convective (the max over the set of the coupled ones taken with absolute values) and viscous part (4/(rho D) times the maximum between mu and k/cp, with D being the distance between the cell centers adjacent to the face... I don't know anymore where the 4 comes from).

As you see, it is pretty much conservative, but then I'm sure that it has to work, at least for the main coupled equations. But then, it typically also works for the remaining equations.
Hello sbaffini:
I am trying to add the spalart allmaras model to my 3D Navier Stokes Solver but it has trouble converging. For the very first advance step I get negative nut. Then I limit nut to be no smaller than the machine zero, but it then always approachs the machine zero, meaning negative nut for every step. I have no idea what the order of magnitude of the convective term, diffusion terms and the source term SHOULD be, and I come for help. I have examined the code for a week but still fails, so I also wonder where should I attention in particular?

PS:The S_tilda term especailly confuses me with its signs. Since fv1<1, fv2 is negative for a Chi=3 initial conditon, and omega in initial stream is negligible, S_tilda goes negative. Although we would later limit S_tilda to no smaller than 0.3*Omega,I found that for larger Chi(In real flows nut is much larger than nu), S_tilda is always negative according to its expression, that doesn't make sense. Or Am I wrong about the above statement? Plesae Correct me.

I use the standard version of the SA model provided on https://turbmodels.larc.nasa.gov/spalart.html and the validation case is Onera M6. The farfield BC is set as nut= 3* nu. For now I am testing explicit RK schemes, and the local time step is in accordance with the main equations, as you mentioned above. The convective term is treated with first order upwind scheme and diffusion term with central scheme.

Much Thanks!!!
Jinn is offline   Reply With Quote

Old   November 12, 2021, 09:21
Default
  #17
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
It is difficult to give a hint out of blue.

So, excuse me if I straightly get into pedantic mode, but let me suggest you a way to debug this sort of issues. First of all, test that convection, diffusion and time advancement just work as expected, without source terms. I assume this to be the case.

Then, if everything is correct, put every piece of your source term into a variable to be plotted separately.

Let me assume that ft2 is 0 (in any case, I don't use it, so I couldn't help here), this means that you have just production, destruction and the non linear term to plot. Now, if nu_tilda >0, so must be all the 3 of them.

Let's first consider the non linear term. I wrote in posts above how it is commonly treated in a robust way. So, I assume that you are doing so as well.

This leaves out just production and destruction, that ultimately depend from S_tilda. Also, destruction, depends from S_tilda in such a way that it should never become negative. This leaves out production, thus indeed S_tilda.

Then, first question: I actually use the 2012 correction to it, which is not just limiting. Have you tried it? It is the modification mentioned in Note 1c of the Standard model on the NASA/LARC site.
sbaffini is offline   Reply With Quote

Old   November 12, 2021, 11:40
Default
  #18
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,175
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Also, when I want to understand how some term is supposed to behave, I take a plot of it in matlab (or whatever you are comfortable with) using a regular grid embracing all the parameters appearing in the term.
sbaffini is offline   Reply With Quote

Old   November 12, 2021, 21:17
Default
  #19
New Member
 
Join Date: Nov 2021
Posts: 8
Rep Power: 4
Jinn is on a distinguished road
It's so kind of you to offer the debug advice. That makes things more clear and I would follow and try. Also I will try the 2012 corrected version. Thanks again!
Jinn is offline   Reply With Quote

Old   May 24, 2024, 10:23
Default
  #20
New Member
 
Join Date: Mar 2024
Posts: 1
Rep Power: 0
baarn is on a distinguished road
Hello, I am also dealing with the implementation of the SA model. Can you share with me the thesis you are talking about ?

Thanks !

Quote:
Originally Posted by sbaffini View Post
Yes, that's the arrangement

Couldn't upload the full thesis (it's too large), but these two files have everything you need about SA.

Still, I would suggest reading the original SA paper as well (or some of those that came out in the same period), because it explicitly explains how to treat the source terms
baarn is offline   Reply With Quote

Reply


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
request for a spalart allmaras code in channel Abolfazl_cfd Main CFD Forum 0 April 6, 2019 21:02
Hybrid discretisation - blend factor gcoopermax CFX 5 September 23, 2016 08:05
CFX Spalart Allmaras turbulence models aweizazuji CFX 9 September 24, 2013 10:53
Puzzled by multi-block solver implementation...... Chen Zhi Main CFD Forum 3 February 14, 2010 20:10
Spalart Allmaras model Muhammad Shakaib Main CFD Forum 1 August 3, 2006 08:57


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