# How to model the mixing of two gases

 Register Blogs Members List Search Today's Posts Mark Forums Read

 July 23, 2019, 16:54 How to model the mixing of two gases #1 Senior Member   Join Date: Mar 2018 Posts: 115 Rep Power: 8 Hello, I have two containers, the first container contains gas 1 and the second contains gas2. the two containers are separated by a thin membrane. at t = 0 this thin membrane is removed and the two gases start to mix. Could you please give me some hints on how to model this process? Which solver should I use? Any similar examples or tutorials? Thank you

 July 24, 2019, 01:38 #2 New Member   Join Date: Apr 2014 Posts: 24 Rep Power: 12 Hey, the easiest way would be to add a new equation for a scalar transport to model diffusion process. Which solver you use is your choice. I would recommend to start with the pimpleFoam. For the equation have look on: HTML Code: `https://en.wikipedia.org/wiki/Convection–diffusion_equation` Regards Tobi

 July 24, 2019, 07:27 #3 Senior Member   Join Date: Mar 2018 Posts: 115 Rep Power: 8 The transport equation AFAIK is for a single fluid. My question was about the mixing of two gases as shown in the figure.

 July 24, 2019, 07:53 #4 New Member   Join Date: Apr 2014 Posts: 24 Rep Power: 12 Understood that... With the scalar you can imitade a second gas species. scalar = 0 --> species 01 scalar = 1 --> species 02 0< scalar < 1 --> mixing of the gases. You can define density, viscosity and so on depending on the scalar (species). And you can also definde diffusion depending on the diffusivity of the species. Worked for me in a lot of cases and you don't have to set up a second set of navier-stokes-equations and doing the coupling...

 July 24, 2019, 10:09 #5 Senior Member   Join Date: Mar 2018 Posts: 115 Rep Power: 8 Unfortunately, your post is completely not clear for me. If you know really how to set up a case why you don't simply just give the steps. I am looking for OpenFOAM solvers that already exist to model this process not to create my own solver. PS: I am not looking for programming a new solver. I am looking for any OF solver that could solve my problem (What about multiphase solvers). --- Any answers?! Last edited by wyldckat; July 27, 2019 at 08:51. Reason: merged posts a day apart

 July 25, 2019, 18:55 #6 Retired Super Moderator   Bruno Santos Join Date: Mar 2009 Location: Lisbon, Portugal Posts: 10,978 Blog Entries: 45 Rep Power: 128 Quick answer: rhoReactingFoam if you only want different pressures or densities for each gas; rhoReactingBuoyantFoam if you want to use gravity to influence the flow/gases... in both, you can turn off the combustion modelling, so that they don't react... anon_q likes this. __________________ OpenFOAM: FAQ | Getting started Forum: How to get help, to post code/output and forum guide Read this before sending me PM

July 25, 2019, 21:45
#7
Senior Member

Join Date: Mar 2018
Posts: 115
Rep Power: 8
Quote:
 Originally Posted by wyldckat Quick answer: rhoReactingFoam if you only want different pressures or densities for each gas; rhoReactingBuoyantFoam if you want to use gravity to influence the flow/gases... in both, you can turn off the combustion modelling, so that they don't react...

July 25, 2019, 22:41
#8
Senior Member

Ruiyan Chen
Join Date: Jul 2016
Location: Hangzhou, China
Posts: 162
Rep Power: 10
Quote:
 Originally Posted by Evren Linda Unfortunately, your post is completely not clear for me. If you know really how to set up a case why you don't simply just give the steps. I am looking for OpenFOAM solvers that already exist to model this process not to create my own solver. PS: I am not looking for programming a new solver. I am looking for any OF solver that could solve my problem (What about multiphase solvers).
Why don't you take some time and check the descriptions of the various solvers in OpenFOAM (https://cfd.direct/openfoam/user-gui...x13-960003.5)? Nobody here will or has the obligations to just give you the steps because each case is different, and I personally think it's much better that you first do some research on your part, then come back with more specific problems.

In terms of your question, have you checked the so-called Volume-of-Fluid (VOF) approach, and the corresponding solvers in OpenFOAM?

July 27, 2019, 09:01
#9
Retired Super Moderator

Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,978
Blog Entries: 45
Rep Power: 128
Quote:
 Originally Posted by cryabroad Why don't you take some time and check the descriptions of the various solvers in OpenFOAM (https://cfd.direct/openfoam/user-gui...x13-960003.5)?
Sorry, but did you read that page?
Quote:
 reactingFoamSolver for combustion with chemical reactions. rhoReactingBuoyantFoamSolver for combustion with chemical reactions using a density based thermodynamics package with enhanced buoyancy treatment. rhoReactingFoamSolver for combustion with chemical reactions using density based thermodynamics package.
Given that the original question was directed towards:
Quote:
 the two gases start to mix
... it's somewhat difficult to connect the dots between using a combustion solver for just mixing gases. And I write this because I've been there myself years ago.

That said, searching online for:
Code:
`openfoam mixing gases`
should have given a similar answer to mine.

Beyond this, VoF for mixing gases isn't all that great, unless the gases are barely mixable, given that VoF solvers in OpenFOAM usually go for «using a VOF (volume of fluid) phase-fraction based interface capturing approach».

July 28, 2019, 04:01
#10
Senior Member

Ruiyan Chen
Join Date: Jul 2016
Location: Hangzhou, China
Posts: 162
Rep Power: 10
Quote:
 Originally Posted by wyldckat Sorry, but did you read that page? Given that the original question was directed towards: ... it's somewhat difficult to connect the dots between using a combustion solver for just mixing gases. And I write this because I've been there myself years ago. That said, searching online for: Code: `openfoam mixing gases` should have given a similar answer to mine. Beyond this, VoF for mixing gases isn't all that great, unless the gases are barely mixable, given that VoF solvers in OpenFOAM usually go for «using a VOF (volume of fluid) phase-fraction based interface capturing approach».
I referred to that page simply because I think the descriptions there can really help a lot in clarifying the differences among OpenFOAM solvers, which helps to decide which solver to use. Given that the original question is how to model this process using existing solvers, I think the users' guide is the first thing to check.

I understand that VOF is not that great for mixing problems, and I understand that the combustion solvers (with reactions turned off) may be the better choice. All I'm trying to say is, because we don't know enough details about this mixing process (are the gases mixable? are they compressible? is this a microscale process? etc.), it is very hard to pick a corresponding solver.

 July 28, 2019, 08:03 #11 Retired Super Moderator   Bruno Santos Join Date: Mar 2009 Location: Lisbon, Portugal Posts: 10,978 Blog Entries: 45 Rep Power: 128 @cryabroad: Many thanks for the clarification! Your previous post wasn't this clear, but now it's a lot more understandable. Thanks again!

July 28, 2019, 22:02
#12
Senior Member

Ruiyan Chen
Join Date: Jul 2016
Location: Hangzhou, China
Posts: 162
Rep Power: 10
Quote:
 Originally Posted by wyldckat @cryabroad: Many thanks for the clarification! Your previous post wasn't this clear, but now it's a lot more understandable. Thanks again!
Maybe I didn't express myself in a better way and that causes confusion. Bottom line is, I'm really interested in this problem (mainly because I'm just very into multiphase problems) and want to see how it goes. I'm not an expert in this particular problem, but I want to throw some ideas out there and see how real experts would like to deal with it.

July 29, 2019, 02:40
#13
New Member

Join Date: Apr 2014
Posts: 24
Rep Power: 12
Have to ask again... u want to model something like in the picture?
Attached Images
 mixingOfTwoGasspecies.png (108.5 KB, 117 views)

July 29, 2019, 10:04
#14
Senior Member

Join Date: Mar 2018
Posts: 115
Rep Power: 8
Quote:
 Originally Posted by TobiF Have to ask again... u want to model something like in the picture?
What you have shown can be easily simulated using for example laplacianFoam. It will be treated like a diffusion problem where the initial distribution of concentration will be a step function.

My question is I want to see some mixing like in real life examples.

 July 30, 2019, 00:04 #15 Senior Member   TWB Join Date: Mar 2009 Posts: 403 Rep Power: 19 Hi, I just saw this question and it seems to be similar in some ways to my question too: shock tube modelling with 2 gases As mentioned, I'm trying to model a shock tube which consists of the driver and driven area. The driver and driven area contains helium at high pressure and nitrogen at low pressure respectively. They are separated by a diaphragm, which will rupture at t=0. This is a high speed flow problem with speed reaching 4-5 mach no. So which solver should I use? I was previously using rhoCentralFoam but can I make it work with 2 gases, assuming no reaction? I read thru the forum and some suggested rhoReactingFoam or rhoPimpleFoam. cfdvenkatesh suggested : "You could use Species Transport model to simulate mixing of 2 different gases. If your application is not IC engine related, I would suggest to use General Species Transport. In the inlets you can specify the mass fractions for the gases you like." So which is the more appropriate solver to use? I am now setting up the case for rhoReactingFoam.. Thanks!

 November 9, 2020, 23:44 rhoReactingBuoyantFoam - buoyantReactingFoam #16 New Member   Join Date: Mar 2019 Posts: 3 Rep Power: 7 Hi, I understand this is an old thread, but my problem is similar and I thought I'd ask my question here before starting an entirely new one. I'm trying to tackle a similar problem of two gases mixing with thermally driven buoyancy, without a lot of success. rhoReactingBuoyantFoam, which has been superceeded by buoyantReactingFoam in the OpenFOAM dev version, does not appear to handle simulations with combustion turned off well. I am encountering temperature fluctuations in the flow field that are causing my Courant number to spike and the simulation to crash, despite adaptive timesteps, fvOption file limited velocity and temperature. There is no physical reason for temperatures to rise in my simulation given inlet velocities < 1.2m/s and temperatures <375K. ie, subsonic and low temp with no reactions. This has been observed before, here: Temperature increase for gaseous diffusion with rhoReactingBuoyantFoam? and here: having trouble using reactingFoam with reactions turned off With a solution presented to re-write the rhoReactingBuoyantFoam solver to "... enforcing the alphaEff -> muEff, ..." - Swagga5aur Unfortunately I lack the skill set required to compile the file kindly provided by Swagga5aur. I am also reluctant to modify a solver without understanding what impact the changes made to gain stability have on the solution, which I do not at this time. Is there an alternative solver that will model 2 gasses mixing with buoyancy effects robustly? As a more permanent solution, is it viable to "fix" the buoyantReactingFoam solver at the source to address the 'instability'*.

 June 15, 2022, 06:58 Follow Up #17 New Member   Join Date: Mar 2019 Posts: 3 Rep Power: 7 Apologies for once again resurrecting an old thread, but I was asked by a user if I found a solution to this problem and thought I'd post here so hopefully it's useful for others. Using buoyantReactingFoam is viable for non-reacting fluid mixing with thermally driven buoyancy effects. Turning combustion 'off' in file combustionProperties allows the solver to model the flow without considering chemical reactions, see below. It's been a while, but I believe my stability issue was caused by inappropriate fvSchemes. If your encountering similar issues I recommend setting Co << 1 in a bid to improve stability initially. If this does not resolve the solution stability, adjust the fvSchemes. My file is below. Code: ```// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // combustionModel none; // ************************************************************************* //``` Code: ```/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: dev \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvSchemes; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ddtSchemes { default Euler; } gradSchemes { default leastSquares; //Gauss linear; } divSchemes { default Gauss limitedLinear 1; //none; div(phi,U) Gauss limitedLinearV 1; div(phi,Yi_h) Gauss limitedLinear 1; //div(phi,Yi) Gauss limitedLinear01 1; div(phi,K) Gauss limitedLinear 1; div(phid,p) Gauss limitedLinear 0.8; div(phi,epsilon) Gauss linear upwind; //Gauss limitedLinear 1; div(phi,k) Gauss limitedLinear 1; div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear upwind; //Gauss linear; } laplacianSchemes { default Gauss linear corrected; } interpolationSchemes { default linear; } snGradSchemes { default corrected; } fluxRequired { p_rgh; } wallDist { method meshWave; } // ************************************************************************* //```

 December 14, 2023, 15:11 #18 New Member   Bruno B W Join Date: Aug 2023 Posts: 6 Rep Power: 3 Dear Fomers, i wonder which solver i should use to model an ethanol pool evaporation and mixing with air in a close enclosure, with a hot celing. Any directions would be very helpful. Thanks.

January 12, 2024, 05:51
#19
New Member

Carmelo Baronetto
Join Date: Dec 2023
Posts: 29
Rep Power: 2
Quote:
 Originally Posted by anon_q Hello, I have two containers, the first container contains gas 1 and the second contains gas2. the two containers are separated by a thin membrane. at t = 0 this thin membrane is removed and the two gases start to mix. Could you please give me some hints on how to model this process? Which solver should I use? Any similar examples or tutorials? Thank you
Good morining everyone,
I write in this old thread because I would like to simulate excatly this case.
I used reactingFoam, following these steps:
1) I tested a "real" shocktube problem, with N2 and O2 at different pressure and the the simulation was fine
2) I modified the initial conditions, setting uniform pressure (temperature uniform as in the previous case). However in this simulation, I see no mixing and the N2 and O2 remain unmixed.
I set the turbulance model "laminar", because the velocity field is zero everywhere, but I think the two gases must still mixing.

Does anyone have an idea why I got these results?
Thank you

 January 12, 2024, 09:03 #20 Senior Member   Join Date: Apr 2020 Location: UK Posts: 717 Rep Power: 14 Yes, there should still be molecular diffusion, even if there is no turbulence. Questions: 1. Have you run it for long enough? Molecular diffusion is slowwww compared to turbulent diffusion. Try calculating a diffusion time scale and compare your run time to that. 2. Are you sure there was absolutely "no" diffusion - if you adjust the scale, are there perhaps some very low concentrations of gas seeping across the line? If so, then this supports the previous question - run for longer and perhaps also refine the mesh at the boundary between the 2 gases.