Wrong Calculations in Compositional Model in a Special Case

359 views
Skip to first unread message

ahmadreza shojaee

unread,
Jan 23, 2024, 11:20:24 AMJan 23
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear All,

I am working with the compositional model in my PhD project. I am investigating compositional water-gas systems. I think I found a problem in MRST compositional when I was trying to compare MRST output with the GASWAT model in ECLIPSE in a Hydrogen-Water displacement simulation.

First, I defined the initial global mole fraction in the reservoir as Z_H2O = 1 and Z_H2 = 0. I observed a huge mismatch between MRST and ECL. I tried to find out why they did not have a same response for mass and saturation. I went to the details and I found that MRST is calculating mass of H2 in the system wrongly! After a certain period of injection, the amount of H2 in the system was much higher than the injected amount.
 
Then, I guess there may be a numerical error; so, I changed the initial global mole fraction to Z_H2O = 0.99 and Z_H2 = 0.01. In this case, there was a great match between ECL and MRST!  Again, I did another simulation with the initial amounts of Z_H2O = 0.999 and Z_H2 = 0.001; in this case, there is still mismatch between MRST and ECL and again MRST is calculating the mass of injected H2 wrongly while the error is much smaller than the first case.

In this case, do you have any idea how can we fix this problem?

Kind regards,
Ahmad

Olav Møyner

unread,
Jan 24, 2024, 3:16:48 AMJan 24
to ahmadreza shojaee, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Ahmad,

Can you share the examples and the reference output? It is difficult to say anything about your issue without having looked at the case in question. Are you sure that the simulations are equivalent in keywords and physical setup?

Note that the compositional equations are degenerate in the limit of missing components: A small component mole fraction is always enforced, but it is fairly small (I think 1e-10 by default).

Best regards,
Olav

From: sinte...@googlegroups.com <sinte...@googlegroups.com> on behalf of ahmadreza shojaee <ashoj...@gmail.com>
Sent: Tuesday, January 23, 2024 15:51
To: MRST-users: The Matlab Reservoir Simulation Toolbox User Group <sinte...@googlegroups.com>
Subject: [MRST Users] Wrong Calculations in Compositional Model in a Special Case
 
--
You received this message because you are subscribed to the Google Groups "MRST-users: The Matlab Reservoir Simulation Toolbox User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sintef-mrst...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sintef-mrst/eb09e677-495c-4959-b99f-8f56b4e408f4n%40googlegroups.com.

ahmadreza shojaee

unread,
Jan 24, 2024, 6:55:42 AMJan 24
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Olav,

Thanks for your response. Please take a look to the given code. The initial global mole fraction for water and H2 are 1 and 0 respectively. Please check the amount of H2 mass for example after 1 day of injection. Based on the well data, density, gas volume factor, and also ECL output, the amount of H2 in cell 1 should be about 25.6 kg; however, the calculated value in MRST is about 38.8 kg. Note that the injection rate is 300 m^3/day for H2.

Looking forward to hearing from you.

Kind regards,
Ahmad

H2_Water.DATA
H2_Injection_1D.m

Olav Møyner

unread,
Jan 24, 2024, 7:01:22 AMJan 24
to ahmadreza shojaee, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Ahmad,

Thank you for the files. Could you also supply the output from the commercial simulator? I do not have access to E300.

Best regards,
Olav

Sent: Wednesday, January 24, 2024 10:21

To: MRST-users: The Matlab Reservoir Simulation Toolbox User Group <sinte...@googlegroups.com>
Subject: Re: [MRST Users] Wrong Calculations in Compositional Model in a Special Case
 

ahmadreza shojaee

unread,
Jan 24, 2024, 9:01:12 AMJan 24
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Olav,

Please find the attached. ''E300 output.mat'' file is the E300 simulator output; I used the read_ecl function to import date from binary files (https://uk.mathworks.com/matlabcentral/fileexchange/47607-read_ecl-m).
''E300-H2Mass.mat'' is the mass which is calculated with the below command:
H2_mass = ECL.MLSC2 * 200 * 2.016 %mass of H2 in kg = kmole of H2 / cell volume * cell volume * MW (kmole/kg) - here cell volume is 200 m^3 and MW = 2.016

Also you can compare the gas saturation results. There is a great mismatch. When I change the Z0 for H2 to 0.01, the results would be the same. The point is that if you check the mass of injected H2 based on well data, it is not the same with mass of H2 in states matrix.
 
Kind regards,
Ahmad
E300-H2Mass.mat
E300 output.mat

Olav Møyner

unread,
Jan 26, 2024, 4:28:11 AMJan 26
to ahmadreza shojaee, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Ahmad,

I can confirm the issue. I think it is most likely related to the phases present in the well cell. If no gas phase is present in that cell, it may pick the wrong density in the inflow discretization. I do not think there is an easy fix to this, but boundary conditions and source terms should give the expected result as their inflow equations are simpler.

Best regards,
Olav

Sent: Wednesday, January 24, 2024 13:38

Sam

unread,
Jan 26, 2024, 5:23:25 AMJan 26
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Olav,

Your input is always appreciated. Can you comment whether a) this is a special case (as the title says) and what made it behave the way it did so that we can keep it in mind when running our own simulation, or b) a general mishap in the compositional module? Thanks.

Olav Møyner

unread,
Feb 6, 2024, 5:03:30 AMFeb 6
to Sam, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Hi,

Apologies for the late reply.

This issue will happen if the well cells do not contain the injected gas. Generally the injection cell will fill with the injected mixture fairly quickly, so the approximation should not impact long running simulations. As an alternative, you can either use source terms for injection or use the jutul module to run accelerated compositional solvers that treat the compositional well source terms more rigorously.

Best regards,
Olav

From: sinte...@googlegroups.com <sinte...@googlegroups.com> on behalf of Sam <jon9...@gmail.com>
Sent: Friday, January 26, 2024 11:23

Alejandro Fernández

unread,
Feb 8, 2024, 7:53:17 AMFeb 8
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Hi Olav, Ahmadreza and Sam,

I think I am facing a related issue when simulating a Hydrogen-Water compositional problem. If you execute the minimal code I am sharing, you will get a water density of 833 kg/m^3 for a system that is initially fully saturated 
with water, at surface temperature and pressures:

mrstModule add compositional ad-core ad-props linearsolvers
%% Set up problem
gravity reset on
Lx = 1 ;
Ly = 1 ;
Lz = 1 ;
pdims = [Lx, Ly, Lz];
nx = 10 ;
ny = 10 ;
nz = 10 ;
dims = [nx, ny, nz];
dx = pdims(1)/nx; dy = pdims(2)/ny; dz = pdims(3)/nz;
G = cartGrid(dims, pdims);
G = computeGeometry(G);
K = 1;
phi = 0.2;
rock = makeRock(G, K, phi);
pv = poreVolume(G, rock);
%% Initial state
sat0 = [1, 0];
T =300*Kelvin;
mixture0 = [1, 0];
%% Mixture
names = {'Water', 'Hydrogen'};
mixture = TableCompositionalMixture({'Water','Hydrogen'});
ncomp = mixture.getNumberOfComponents();
display(mixture)
eos_peng_robinson = EquationOfStateModel(G, mixture, 'prcorr');
%% Initialize fluid
flowfluid = initSimpleADIFluid('phases', 'wg','rho', [1000, 0.08375], ...
'mu', [1,1]*centi*poise, ...
'n', [2,2], ...
'c', [0,1e-3]/barsa,'blackoil', false);
arg = {G, rock, flowfluid, ... % Standard arguments
mixture,... % Compositional mixture
'water', true, 'oil', false, 'gas', true,... % Water-Gas system
'liquidPhase', 'W', 'vaporPhase', 'G'}; % Water=liquid, gas=vapor
model = GenericNaturalVariablesModel(arg{:});
model.EOSModel = eos_peng_robinson ;
%% Initialize state
state0 = initCompositionalState( G, 101325, T, sat0, mixture0, model.EOSModel);
model = model.validateModel();
Densities = model.getProp(state0,'Density');

Do you have any idea about what is happening or what I might be missing?
Thanks a lot in advance.
Cheers,
Alejandro

Olav Møyner

unread,
Feb 8, 2024, 9:53:39 AMFeb 8
to Alejandro Fernández, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Hi Alejandro,

Is your question why the density of water is 833 and not around 1000 kg/m^3 for the water phase? The Peng Robinson equation of state needs to be adjusted through the binary interaction coefficients and maybe also the volume shifts to produce the right density for a given mixture. This is especially important for mixtures with H2O. I do not think we have an example with the H2-H2O binary system, but I think there are papers that have the coefficients figured out for some conditions.

Best regards,
Olav

From: sinte...@googlegroups.com <sinte...@googlegroups.com> on behalf of Alejandro Fernández <aleferna...@gmail.com>
Sent: Thursday, February 8, 2024 13:19

Alejandro Fernández

unread,
Feb 8, 2024, 11:30:34 AMFeb 8
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Hi Olav,

Thank you, yes, that was my question and your answer is very helpful. In fact I was missing setting binary interaction coefficients different than zero and so hence the inconsistency.
I will look into that, thanks again.
Cheers,
Alejandro

ahmadreza shojaee

unread,
Apr 30, 2024, 1:08:13 PMApr 30
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Olav,

I hope you are doing well. 
Did you resolve this issue in the new MRST release?

Kind regards,
Ahmad

Olav Møyner

unread,
Apr 30, 2024, 3:10:25 PMApr 30
to ahmadreza shojaee, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Ahmad,

Unfortunately this issue would require a significant amount of work on the well model. It was not done for this release.

One alternative you can try is the jutul module that runs the main simulation using an accelerator and gets the results back in a standard format. This is a lot faster than MRST's compositional solvers and the well model used there should not have this issue.

Best regards,
Olav

Sent: Tuesday, April 30, 2024 19:00

ahmadreza shojaee

unread,
May 1, 2024, 5:14:59 AMMay 1
to Olav Møyner, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Thanks Olav for your suggestion.
Actually, run time is an issue to me. However, I am not sure whether I can transfer my simulation into the jutul module or not. I am using a third party software after each time convergence in the SimulateScheduleAD function and do some calculations and update the states matrix. Is it possible to do the same thing using jutul module?

Kind regards,
Ahmad

Olav Møyner

unread,
May 2, 2024, 7:16:05 AMMay 2
to ahmadreza shojaee, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Hi Ahmad,

I think the answer is a qualified yes. You have two options, both with some potential issues:
  • Call "simulateScheduleJutul" for each time-step and let the read and write loop happen between each step. This is essentially seamless if you use "daemon mode" where a Julia session runs in the background and automatically processes results. Your update would have to concern the primary variables only (which will be the same restriction as simulateScheduleAD unless you have added custom logic. This will write the case (grid especially) to file many times more than what is strictly necessary. Depending on the time-step length this could be slower or faster than doing everything in MRST.
  • Read the case once in Julia (or set it up directly there) and call the simulate function and the external software from Julia. This will be fast to simulate, but Julia is different from Matlab, even if it is on the surface similar. JutulDarcy has a lot of MRST DNA, but some parts of the syntax will be different than setting up the case in MRST. If you already have a workflow for calling the third party software from MATLAB and this is missing from Julia that's also something that would require some effort...

Best regards,
Olav

From: ahmadreza shojaee <ashoj...@gmail.com>
Sent: Wednesday, May 1, 2024 0:01
To: Olav Møyner <Olav....@sintef.no>
Cc: MRST-users: The Matlab Reservoir Simulation Toolbox User Group <sinte...@googlegroups.com>

ahmadreza shojaee

unread,
May 2, 2024, 11:00:02 AMMay 2
to Olav Møyner, MRST-users: The Matlab Reservoir Simulation Toolbox User Group

ahmadreza shojaee

unread,
Jun 3, 2024, 11:10:29 AMJun 3
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Olav,

I hope you are doing well. Regarding this issue, I used a source term instead of a well, and the calculated results are not the same as ECLIPSE/GEM yet.
Do you have any idea about that?

Kind regards,

AhmadCapture.PNG

Reply all
Reply to author
Forward
0 new messages