Weakly compressible cases

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
finzeo
Posts: 55
Joined: Fri Sep 09, 2022 4:23 pm

Weakly compressible cases

Post by finzeo »

Hi all,

Studying the theory associated with code_saturne, I see here (https://www.code-saturne.org/cms/sites/ ... nomena.pdf) the treatment for weakly compressible cases. On page 4 it is indicated that, in the case where M<0.3 and the relative variation of the density is greater than 0.1, a modification of the algorithm used in code_saturne should be considered. Does this mean that code_saturne does not contemplate this situation? I am just dealing with a case in which M<0.3 and the relative variation of the density is of the order of 0.15 (vehicle aerodynamics).
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Weakly compressible cases

Post by Yvan Fournier »

Hello,

That best-practices card is quite ancient, and needs to be updated. The compressible algorithm has been improved since, so I do not know if this limitation still holds. The current code is probably good.

There is also a newer algorithm is the development version of code_saturne, described here, which might be better in your case:

@article{Amino:2022,
title={A time-staggered second order conservative time scheme for variable density flow},
author={Amino, H and Flageul, C and Benhamadouche, S and Tiselj, I and Carissimo, B and Ferrand, M},
journal={International Journal for Numerical Methods in Fluids},
publisher={Wiley Online Library},
year={2022}
}

I need to check how to activate that model.

Best regards,

Yvan
finzeo
Posts: 55
Joined: Fri Sep 09, 2022 4:23 pm

Re: Weakly compressible cases

Post by finzeo »

Yvan Fournier wrote: Sun Jul 30, 2023 11:55 pm Hello,

That best-practices card is quite ancient, and needs to be updated. The compressible algorithm has been improved since, so I do not know if this limitation still holds. The current code is probably good.

There is also a newer algorithm is the development version of code_saturne, described here, which might be better in your case:

@article{Amino:2022,
title={A time-staggered second order conservative time scheme for variable density flow},
author={Amino, H and Flageul, C and Benhamadouche, S and Tiselj, I and Carissimo, B and Ferrand, M},
journal={International Journal for Numerical Methods in Fluids},
publisher={Wiley Online Library},
year={2022}
}

I need to check how to activate that model.

Best regards,

Yvan
Hi Yvan,

Thanks. My question arises from the fact that I am using the base software without the compressible module for simulating external and isothermal airflow, particularly for vehicle aerodynamics, where the pressure varies by more than 10% in some specific places of the domain (near the vehicle). I think my appreciation that Ma<0.3 is correct and according to the ideal gas law, the density also varies by more than 10%. I am concerned that the current code may not be "suitable" for this specific case, considering that many people often simulate vehicle aerodynamics.
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Weakly compressible cases

Post by Yvan Fournier »

Hello,

It may be interesting to compare results with the compressible or incompressible algorithms.

In most cases, we consider variable density due to thermal dilatation, but although you could use the incompressible algorithm using a density which depends on the total pressure, this is not much tested, and might not be stable numerically (you may have "pressure waves" propagating due to interference between the density update and the incompressible flow algorithm). You can check how this behaves in your case, but activating the weakly compressible algorithm might be a safe bet.

Best regards,

Yvan
finzeo
Posts: 55
Joined: Fri Sep 09, 2022 4:23 pm

Re: Weakly compressible cases

Post by finzeo »

Yvan Fournier wrote: Tue Aug 01, 2023 11:22 pm Hello,

It may be interesting to compare results with the compressible or incompressible algorithms.

In most cases, we consider variable density due to thermal dilatation, but although you could use the incompressible algorithm using a density which depends on the total pressure, this is not much tested, and might not be stable numerically (you may have "pressure waves" propagating due to interference between the density update and the incompressible flow algorithm). You can check how this behaves in your case, but activating the weakly compressible algorithm might be a safe bet.

Best regards,

Yvan
Hi Yvan,

I was digging into the documentation and source code a bit before writing again. I'm a bit confused about the difference between the terms incompressible, weakly compressible, and compressible, as to whether they each correspond to different algorithms. It is also not clear to me how I should correctly activate each one in case of using them; looking at the code, I realize that the entries it takes into account are those of the GUI, in the sections "calculation features>flow models" and "numerical parameters>Algorithm to take into account the density variation in time".
finzeo
Posts: 55
Joined: Fri Sep 09, 2022 4:23 pm

Re: Weakly compressible cases

Post by finzeo »

finzeo wrote: Wed Aug 02, 2023 7:24 pm
Yvan Fournier wrote: Tue Aug 01, 2023 11:22 pm Hello,

It may be interesting to compare results with the compressible or incompressible algorithms.

In most cases, we consider variable density due to thermal dilatation, but although you could use the incompressible algorithm using a density which depends on the total pressure, this is not much tested, and might not be stable numerically (you may have "pressure waves" propagating due to interference between the density update and the incompressible flow algorithm). You can check how this behaves in your case, but activating the weakly compressible algorithm might be a safe bet.

Best regards,

Yvan
Hi Yvan,

I was digging into the documentation and source code a bit before writing again. I'm a bit confused about the difference between the terms incompressible, weakly compressible, and compressible, as to whether they each correspond to different algorithms. It is also not clear to me how I should correctly activate each one in case of using them; looking at the code, I realize that the entries it takes into account are those of the GUI, in the sections "calculation features>flow models" and "numerical parameters>Algorithm to take into account the density variation in time".
Hi Yvan,

To be specific: to correctly activate the algorithm for weakly compressible cases, should I choose "dilatable unsteady algorithm" in the numerical parameter settings, and "compressible, perfect gas with constant gamma" in flow models setup?
hamino
Posts: 2
Joined: Thu Aug 10, 2023 5:47 pm

Re: Weakly compressible cases

Post by hamino »

Hello,

If I understood well, you are simulating an isothermal flow with density variation due to the pressure variations you described above?

code_saturne (version 8.0) has different variable density algorithms.

The "dilatable unsteady algorithm" uses the hypothesis of a density variation based on scalars (temperature, mixture species mass fraction..). For instance, the EOS for an ideal gas would be written

It is an option for the incompressible code_saturne flow model.
However, by enabling some options in the SRC user files, you may activate a density dependence on the pressure as well.

Using the compressible code_saturne flow model can also be of interest.

Thus, for you case, you may try two setups :

- Directly using the compressible code_saturne flow model.

- Using the "dilatable unsteady algorithm" and enabling the account for local pressure variations in your equation of state.
To do so, you may find two user files to add to your /SRC folder.
Note that you should activate a thermal scalar (temperature here). If your simulation is isothermal, you can set all temperatures as the same constant for the initial and boundary conditions.

Best regards,
Hector
Attachments
cs_user_parameters.c
Set up the model choices
(4.7 KiB) Downloaded 50 times
cs_user_physical_properties.c
Define the equation of state for air (with pressure variation)
(3.54 KiB) Downloaded 47 times
hamino
Posts: 2
Joined: Thu Aug 10, 2023 5:47 pm

Re: Weakly compressible cases

Post by hamino »

Hello,

Note that in your case, in cs_user_parameters.c, the parameter ieos should be CS_EOS_IDEAL_GAS and not CS_EOS_GAS_MIX (which would be a mixture composed of different ideal gases).

Best regards,
Hector
Post Reply