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 ;
state0 = initCompositionalState( G, 101325, T, sat0, mixture0, model.EOSModel);
model = model.validateModel();
Densities = model.getProp(state0,'Density');