Hi Dmitry,

thank you for your report, this is very valuable!


It would be even more valuable and highly appreciated if you decide to add your 
model to DuMux. As far as I can see, this would in essence add the Michelsen 
test and your flash calculation. And the completeFluidState method would branch 
depending on whether the traditional "PVS" or the new "flash" model is used. 
Right? Or do you see potential complications?


I consider your statement

"The primary variables. Those must be the pressure and n-1 (overall) mole 
fractions. I do not think that it is possible at all to implement a two-phase 
compositional model with the usual primary variables of the 2pnc model"

very bold. The 2pnc PVS model is standard which has been used successfully not 
only in DuMux to simulate two-phase compositional flow for many years.


Nevertheless, I certainly acknowledge the fact that a flash-based model might 
be superior for particular applications. With the drawback on computational 
performance due to the more expensive flash calculations for one Newton step.


In total, I would heartily encourage you to contribute your model!


Kind regards

Bernd


--
_________________________________________________________________

Bernd Flemisch
IWS, Universität Stuttgart               phone: +49 711 685 69162
Pfaffenwaldring 61              email: be...@iws.uni-stuttgart.de
D-70569 Stuttgart           url: 
www.iws.uni-stuttgart.de/en/lh2/<http://www.iws.uni-stuttgart.de/en/lh2/>
_________________________________________________________________
________________________________
Von: DuMux <dumux-boun...@listserv.uni-stuttgart.de> im Auftrag von Dmitry 
Pavlov <dmitry.pav...@outlook.com>
Gesendet: Donnerstag, 17. März 2022 23:20:09
An: dumux@listserv.uni-stuttgart.de
Betreff: [DuMux] Oil-gas compositional simulation in DuMux


Hello,

This is for anybody who will be wondering someday whether the two-phase oil-gas 
compositional model is doable in DuMux. The short answer is yes.

The numerical algorithms required for such a model are described in many 
sources (e.g. [1]) and implemented in ECLIPSE and a lot of other programs, 
including the open-source MRST [2].


Now, what is required for implementing the two-phase compositional model in 
DuMux:

1. The primary variables. Those must be the pressure and n-1 (overall) mole 
fractions. I do not think that it is possible at all to implement a two-phase 
compositional model with the usual primary variables of the 2pnc model [3] 
(pressure, saturation, n-2 mole fractions). But the good news is that DuMux, 
for the most part, does not care about what is stored in the primary variables. 
So it is possible to just treat 2pnc's primary variables as the pressure and 
n-1 (overall) mole fractions. The only thing that must be redesigned for that 
to work is VolumeVariables and, in particular, completeFluidState() method that 
builds the FluidState from the primary variables.

2. In order to build the FluidState from the primary variables, one needs two 
algorithms: the Michelsen stability test (it decides whether we have one-phase 
or two-phase composition with this pressure and temperature) and the two-phase 
flash algorithm (it calculates the mole fractions for each phase from overall 
mole fractions). Those algorithms are not present in DuMux. DuMux has 
constraint solvers called MiscibleMultiPhaseComposition and NcpFlash, but they 
will not work for this kind of problem. Only the "classic" flash algorithm 
works. One has to implement the Michelsen test and flash in the aforementioned 
completeFluidState() replacement. These algorithms, in turn, require an 
implementation of equation of state (EOS), usually Peng-Robinson (PR).

3. Good news: DuMux has a completely suitable implementation PR EOS! One 
pitfall is that the default behavior of PR in DuMux is "too correct" in its 
handling of single-root case, which causes Michelsen test to fail. A flag 
"handleUnphysicalPhase" was added to computeMolarVolume() method to allow to 
simplify the calculation and make it suitable for Michelsen test.

4. Switching of primary variables. Actually, no, this one is not needed at all. 
The built-in TwoPNCPrimaryVariableSwitch is not suitable for this problem; it 
is possible to implement a custom PrimaryVariableSwitch which would be based of 
the Michelsen test, but it creates more problems than it solves. To be 
specific, it reduces performance and worsens Newton convergence and gives 
nothing in return. Phase presence in FluidState is updated in 
completeFluidState() and it is fine.


One must be cautious about the performance because DuMux tends to call the 
computationally expensive completeFluidState() more often than it is needed to 
do the job [5]. At least EnableGridVolumeVariablesCache and 
EnableGridFluxVariablesCache should be turned on to avoid unnecessary 
recalculations. Also, PrimaryVariableSwitch should be disabled, as said above. 
Finally, if the box method is used, DuMux calls completeFluidState() on every 
scv connected to every node, which on a 2D grid is 4x the number of nodes, 
while in principle, it is possible to complete the task by making 1x the number 
of nodes calls. Maybe a rewrite of GridVolumeVariables will help to achieve 
that. For now, oil-gas simulation in DuMux is inferior to MRST in performance. 
While MRST works on a much slower engine (Matlab), it does not waste time on 4x 
recalculations, and also uses automatic differentiation, while DuMux uses slow 
numerical differentiation. One the other hand, DuMux, unlike MRST, can be 
parallelized via both MPI and threads [6].


This is it, thank you for attention.


Regards,

Dmitry



[1] https://store.spe.org/Phase-Behavior-P46.aspx
[2] 
https://www.sintef.no/contentassets/2551f5f85547478590ceca14bc13ad51/compositional.html
[3] https://dumux.org/docs/doxygen/master/a18414.html
[4] 
https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/merge_requests/2831
[5] https://listserv.uni-stuttgart.de/pipermail/dumux/2021q4/002811.html
[6] 
https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/merge_requests/2640
_______________________________________________
DuMux mailing list
DuMux@listserv.uni-stuttgart.de
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux

Reply via email to