Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
/*
|
|
|
|
Copyright 2014 SINTEF ICT, Applied Mathematics.
|
2015-02-20 02:26:03 -06:00
|
|
|
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
|
|
|
|
Copyright 2015 NTNU
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPM_INITSTATEEQUIL_HEADER_INCLUDED
|
|
|
|
#define OPM_INITSTATEEQUIL_HEADER_INCLUDED
|
|
|
|
|
2015-02-20 02:26:03 -06:00
|
|
|
#include <opm/core/grid/GridHelpers.hpp>
|
2014-02-24 09:09:04 -06:00
|
|
|
#include <opm/core/simulator/EquilibrationHelpers.hpp>
|
2014-02-27 03:40:14 -06:00
|
|
|
#include <opm/core/simulator/BlackoilState.hpp>
|
2016-09-28 09:38:40 -05:00
|
|
|
#include <opm/core/props/BlackoilPropertiesFromDeck.hpp>
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
#include <opm/core/props/BlackoilPhases.hpp>
|
2014-02-24 08:19:04 -06:00
|
|
|
#include <opm/core/utility/RegionMapping.hpp>
|
2016-10-10 10:23:03 -05:00
|
|
|
#include <opm/parser/eclipse/Units/Units.hpp>
|
2014-06-26 07:46:57 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2016-01-20 07:12:04 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
|
2016-02-29 08:41:08 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
2016-02-26 04:49:40 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
2016-01-20 07:12:04 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Tables/RsvdTable.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Tables/RvvdTable.hpp>
|
2016-06-15 02:40:38 -05:00
|
|
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cassert>
|
2014-01-17 13:07:51 -06:00
|
|
|
#include <utility>
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
#include <vector>
|
|
|
|
|
2014-01-19 18:25:33 -06:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Facilities for an ECLIPSE-style equilibration-based
|
|
|
|
* initialisation scheme (keyword 'EQUIL').
|
|
|
|
*/
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
struct UnstructuredGrid;
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
2014-02-27 03:40:14 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute initial state by an equilibration procedure.
|
|
|
|
*
|
|
|
|
* The following state fields are modified:
|
|
|
|
* pressure(),
|
|
|
|
* saturation(),
|
|
|
|
* surfacevol(),
|
|
|
|
* gasoilratio(),
|
|
|
|
* rv().
|
|
|
|
*
|
|
|
|
* \param[in] grid Grid.
|
|
|
|
* \param[in] props Property object, pvt and capillary properties are used.
|
|
|
|
* \param[in] deck Simulation deck, used to obtain EQUIL and related data.
|
|
|
|
* \param[in] gravity Acceleration of gravity, assumed to be in Z direction.
|
2016-12-22 09:01:39 -06:00
|
|
|
* \param[in] applySwatInit Make it possible to not apply SWATINIT even if it
|
|
|
|
* is present in the deck
|
2014-02-27 03:40:14 -06:00
|
|
|
*/
|
2015-02-20 02:26:03 -06:00
|
|
|
template<class Grid>
|
|
|
|
void initStateEquil(const Grid& grid,
|
2014-03-28 11:35:43 -05:00
|
|
|
const BlackoilPropertiesInterface& props,
|
2016-10-13 09:03:35 -05:00
|
|
|
const Opm::Deck& deck,
|
|
|
|
const Opm::EclipseState& eclipseState,
|
2014-03-28 11:35:43 -05:00
|
|
|
const double gravity,
|
2016-12-22 09:01:39 -06:00
|
|
|
BlackoilState& state,
|
|
|
|
bool applySwatInit = true);
|
2014-02-27 03:40:14 -06:00
|
|
|
|
|
|
|
|
2014-01-19 18:25:33 -06:00
|
|
|
/**
|
|
|
|
* Types and routines that collectively implement a basic
|
|
|
|
* ECLIPSE-style equilibration-based initialisation scheme.
|
|
|
|
*
|
|
|
|
* This namespace is intentionally nested to avoid name clashes
|
|
|
|
* with other parts of OPM.
|
|
|
|
*/
|
2016-02-29 08:41:08 -06:00
|
|
|
namespace EQUIL {
|
2014-02-19 06:42:07 -06:00
|
|
|
|
2014-01-19 18:25:33 -06:00
|
|
|
/**
|
|
|
|
* Compute initial phase pressures by means of equilibration.
|
|
|
|
*
|
|
|
|
* This function uses the information contained in an
|
|
|
|
* equilibration record (i.e., depths and pressurs) as well as
|
|
|
|
* a density calculator and related data to vertically
|
|
|
|
* integrate the phase pressure ODE
|
|
|
|
* \f[
|
|
|
|
* \frac{\mathrm{d}p_{\alpha}}{\mathrm{d}z} =
|
|
|
|
* \rho_{\alpha}(z,p_{\alpha})\cdot g
|
|
|
|
* \f]
|
|
|
|
* in which \f$\rho_{\alpha}$ denotes the fluid density of
|
|
|
|
* fluid phase \f$\alpha\f$, \f$p_{\alpha}\f$ is the
|
|
|
|
* corresponding phase pressure, \f$z\f$ is the depth and
|
|
|
|
* \f$g\f$ is the acceleration due to gravity (assumed
|
|
|
|
* directed downwords, in the positive \f$z\f$ direction).
|
|
|
|
*
|
|
|
|
* \tparam Region Type of an equilibration region information
|
|
|
|
* base. Typically an instance of the EquilReg
|
|
|
|
* class template.
|
|
|
|
*
|
|
|
|
* \tparam CellRange Type of cell range that demarcates the
|
|
|
|
* cells pertaining to the current
|
2014-01-20 03:33:42 -06:00
|
|
|
* equilibration region. Must implement
|
|
|
|
* methods begin() and end() to bound the range
|
|
|
|
* as well as provide an inner type,
|
|
|
|
* const_iterator, to traverse the range.
|
2014-01-19 18:25:33 -06:00
|
|
|
*
|
|
|
|
* \param[in] G Grid.
|
|
|
|
* \param[in] reg Current equilibration region.
|
|
|
|
* \param[in] cells Range that spans the cells of the current
|
|
|
|
* equilibration region.
|
|
|
|
* \param[in] grav Acceleration of gravity.
|
|
|
|
*
|
|
|
|
* \return Phase pressures, one vector for each active phase,
|
|
|
|
* of pressure values in each cell in the current
|
|
|
|
* equilibration region.
|
|
|
|
*/
|
2015-02-20 02:26:03 -06:00
|
|
|
template <class Grid, class Region, class CellRange>
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
std::vector< std::vector<double> >
|
2015-02-20 02:26:03 -06:00
|
|
|
phasePressures(const Grid& G,
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
const Region& reg,
|
2014-01-17 10:43:27 -06:00
|
|
|
const CellRange& cells,
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
const double grav = unit::gravity);
|
2014-01-23 03:16:49 -06:00
|
|
|
|
2014-02-19 06:42:07 -06:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute initial phase saturations by means of equilibration.
|
|
|
|
*
|
|
|
|
* \tparam Region Type of an equilibration region information
|
|
|
|
* base. Typically an instance of the EquilReg
|
|
|
|
* class template.
|
|
|
|
*
|
|
|
|
* \tparam CellRange Type of cell range that demarcates the
|
|
|
|
* cells pertaining to the current
|
|
|
|
* equilibration region. Must implement
|
|
|
|
* methods begin() and end() to bound the range
|
|
|
|
* as well as provide an inner type,
|
|
|
|
* const_iterator, to traverse the range.
|
|
|
|
*
|
|
|
|
* \param[in] reg Current equilibration region.
|
|
|
|
* \param[in] cells Range that spans the cells of the current
|
|
|
|
* equilibration region.
|
|
|
|
* \param[in] props Property object, needed for capillary functions.
|
|
|
|
* \param[in] phase_pressures Phase pressures, one vector for each active phase,
|
|
|
|
* of pressure values in each cell in the current
|
|
|
|
* equilibration region.
|
|
|
|
* \return Phase saturations, one vector for each phase, each containing
|
|
|
|
* one saturation value per cell in the region.
|
|
|
|
*/
|
2015-02-20 02:26:03 -06:00
|
|
|
template <class Grid, class Region, class CellRange>
|
2014-02-19 06:42:07 -06:00
|
|
|
std::vector< std::vector<double> >
|
2015-02-20 02:26:03 -06:00
|
|
|
phaseSaturations(const Grid& grid,
|
|
|
|
const Region& reg,
|
2014-02-19 06:42:07 -06:00
|
|
|
const CellRange& cells,
|
2016-09-28 09:38:40 -05:00
|
|
|
BlackoilPropertiesFromDeck& props,
|
2014-06-10 07:02:22 -05:00
|
|
|
const std::vector<double> swat_init,
|
|
|
|
std::vector< std::vector<double> >& phase_pressures);
|
2014-02-19 06:42:07 -06:00
|
|
|
|
|
|
|
|
2014-02-27 03:39:18 -06:00
|
|
|
|
2014-02-27 06:14:48 -06:00
|
|
|
/**
|
|
|
|
* Compute initial Rs values.
|
|
|
|
*
|
|
|
|
* \tparam CellRangeType Type of cell range that demarcates the
|
|
|
|
* cells pertaining to the current
|
|
|
|
* equilibration region. Must implement
|
|
|
|
* methods begin() and end() to bound the range
|
|
|
|
* as well as provide an inner type,
|
|
|
|
* const_iterator, to traverse the range.
|
|
|
|
*
|
|
|
|
* \param[in] grid Grid.
|
|
|
|
* \param[in] cells Range that spans the cells of the current
|
|
|
|
* equilibration region.
|
|
|
|
* \param[in] oil_pressure Oil pressure for each cell in range.
|
2014-11-20 05:15:01 -06:00
|
|
|
* \param[in] temperature Temperature for each cell in range.
|
2014-02-27 06:14:48 -06:00
|
|
|
* \param[in] rs_func Rs as function of pressure and depth.
|
|
|
|
* \return Rs values, one for each cell in the 'cells' range.
|
|
|
|
*/
|
2015-02-20 02:26:03 -06:00
|
|
|
template <class Grid, class CellRangeType>
|
|
|
|
std::vector<double> computeRs(const Grid& grid,
|
2014-02-27 06:14:48 -06:00
|
|
|
const CellRangeType& cells,
|
|
|
|
const std::vector<double> oil_pressure,
|
2014-11-20 05:15:01 -06:00
|
|
|
const std::vector<double>& temperature,
|
2014-03-26 08:08:39 -05:00
|
|
|
const Miscibility::RsFunction& rs_func,
|
|
|
|
const std::vector<double> gas_saturation);
|
2014-02-27 03:39:18 -06:00
|
|
|
|
2014-01-23 03:16:49 -06:00
|
|
|
namespace DeckDependent {
|
2014-03-28 11:35:43 -05:00
|
|
|
inline
|
|
|
|
std::vector<EquilRecord>
|
2016-02-29 08:41:08 -06:00
|
|
|
getEquil(const Opm::EclipseState& state)
|
2014-03-28 11:35:43 -05:00
|
|
|
{
|
2016-08-08 03:02:53 -05:00
|
|
|
const auto& init = state.getInitConfig();
|
2014-02-27 03:39:18 -06:00
|
|
|
|
2016-02-29 08:41:08 -06:00
|
|
|
if( !init.hasEquil() ) {
|
|
|
|
OPM_THROW(std::domain_error, "Deck does not provide equilibration data.");
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
2016-02-29 08:41:08 -06:00
|
|
|
|
|
|
|
const auto& equil = init.getEquil();
|
|
|
|
return { equil.begin(), equil.end() };
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
2014-02-27 03:39:18 -06:00
|
|
|
|
2015-02-20 02:26:03 -06:00
|
|
|
template<class Grid>
|
2014-03-28 11:35:43 -05:00
|
|
|
inline
|
|
|
|
std::vector<int>
|
2016-10-13 09:03:35 -05:00
|
|
|
equilnum(const Opm::Deck& deck,
|
|
|
|
const Opm::EclipseState& eclipseState,
|
2015-02-20 02:26:03 -06:00
|
|
|
const Grid& G )
|
2014-03-28 11:35:43 -05:00
|
|
|
{
|
|
|
|
std::vector<int> eqlnum;
|
2016-10-13 09:03:35 -05:00
|
|
|
if (deck.hasKeyword("EQLNUM")) {
|
2015-02-20 02:26:03 -06:00
|
|
|
const int nc = UgGridHelpers::numCells(G);
|
|
|
|
eqlnum.resize(nc);
|
2014-05-06 05:47:24 -05:00
|
|
|
const std::vector<int>& e =
|
2016-10-13 09:03:35 -05:00
|
|
|
eclipseState.get3DProperties().getIntGridProperty("EQLNUM").getData();
|
2015-02-20 02:26:03 -06:00
|
|
|
const int* gc = UgGridHelpers::globalCell(G);
|
|
|
|
for (int cell = 0; cell < nc; ++cell) {
|
2014-05-06 05:47:24 -05:00
|
|
|
const int deck_pos = (gc == NULL) ? cell : gc[cell];
|
|
|
|
eqlnum[cell] = e[deck_pos] - 1;
|
2014-05-05 04:23:43 -05:00
|
|
|
}
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// No explicit equilibration region.
|
2014-03-31 09:16:45 -05:00
|
|
|
// All cells in region zero.
|
2015-02-20 02:26:03 -06:00
|
|
|
eqlnum.assign(UgGridHelpers::numCells(G), 0);
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return eqlnum;
|
|
|
|
}
|
2014-02-27 03:39:18 -06:00
|
|
|
|
|
|
|
|
2014-04-17 05:04:31 -05:00
|
|
|
class InitialStateComputer {
|
2014-03-28 11:35:43 -05:00
|
|
|
public:
|
2015-02-20 02:26:03 -06:00
|
|
|
template<class Grid>
|
2014-06-10 07:02:22 -05:00
|
|
|
InitialStateComputer(BlackoilPropertiesInterface& props,
|
2016-10-13 09:03:35 -05:00
|
|
|
const Opm::Deck& deck,
|
|
|
|
const Opm::EclipseState& eclipseState,
|
2015-02-20 02:26:03 -06:00
|
|
|
const Grid& G ,
|
2016-12-22 09:01:39 -06:00
|
|
|
const double grav = unit::gravity,
|
|
|
|
const std::vector<double>& swat_init = {}
|
|
|
|
)
|
2014-03-28 11:35:43 -05:00
|
|
|
: pp_(props.numPhases(),
|
2015-02-20 02:26:03 -06:00
|
|
|
std::vector<double>(UgGridHelpers::numCells(G))),
|
2014-03-28 11:35:43 -05:00
|
|
|
sat_(props.numPhases(),
|
2015-02-20 02:26:03 -06:00
|
|
|
std::vector<double>(UgGridHelpers::numCells(G))),
|
|
|
|
rs_(UgGridHelpers::numCells(G)),
|
2016-12-22 09:01:39 -06:00
|
|
|
rv_(UgGridHelpers::numCells(G)),
|
|
|
|
swat_init_(swat_init)
|
|
|
|
|
2014-03-28 11:35:43 -05:00
|
|
|
{
|
|
|
|
// Get the equilibration records.
|
2016-10-13 09:03:35 -05:00
|
|
|
const std::vector<EquilRecord> rec = getEquil(eclipseState);
|
|
|
|
const auto& tables = eclipseState.getTableManager();
|
2014-03-28 11:35:43 -05:00
|
|
|
// Create (inverse) region mapping.
|
2014-06-26 07:46:57 -05:00
|
|
|
const RegionMapping<> eqlmap(equilnum(deck, eclipseState, G));
|
2014-03-28 11:35:43 -05:00
|
|
|
|
|
|
|
// Create Rs functions.
|
|
|
|
rs_func_.reserve(rec.size());
|
2016-10-13 09:03:35 -05:00
|
|
|
if (deck.hasKeyword("DISGAS")) {
|
2016-04-08 09:30:01 -05:00
|
|
|
const TableContainer& rsvdTables = tables.getRsvdTables();
|
2014-03-28 11:35:43 -05:00
|
|
|
for (size_t i = 0; i < rec.size(); ++i) {
|
2016-05-06 14:40:33 -05:00
|
|
|
if (eqlmap.cells(i).empty())
|
|
|
|
{
|
|
|
|
rs_func_.push_back(std::shared_ptr<Miscibility::RsVD>());
|
|
|
|
continue;
|
|
|
|
}
|
2014-03-31 09:16:45 -05:00
|
|
|
const int cell = *(eqlmap.cells(i).begin());
|
2016-02-29 08:41:08 -06:00
|
|
|
if (!rec[i].liveOilInitConstantRs()) {
|
|
|
|
if (rsvdTables.size() <= 0 ) {
|
|
|
|
OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table not available.");
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
2016-02-29 08:41:08 -06:00
|
|
|
const RsvdTable& rsvdTable = rsvdTables.getTable<RsvdTable>(i);
|
|
|
|
std::vector<double> depthColumn = rsvdTable.getColumn("DEPTH").vectorCopy();
|
|
|
|
std::vector<double> rsColumn = rsvdTable.getColumn("RS").vectorCopy();
|
|
|
|
rs_func_.push_back(std::make_shared<Miscibility::RsVD>(props,
|
|
|
|
cell,
|
|
|
|
depthColumn , rsColumn));
|
2014-03-28 11:35:43 -05:00
|
|
|
} else {
|
2016-02-29 08:41:08 -06:00
|
|
|
if (rec[i].gasOilContactDepth() != rec[i].datumDepth()) {
|
2014-03-28 11:35:43 -05:00
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"Cannot initialise: when no explicit RSVD table is given, \n"
|
|
|
|
"datum depth must be at the gas-oil-contact. "
|
|
|
|
"In EQUIL region " << (i + 1) << " (counting from 1), this does not hold.");
|
|
|
|
}
|
2016-02-29 08:41:08 -06:00
|
|
|
const double p_contact = rec[i].datumDepthPressure();
|
2014-11-20 05:15:01 -06:00
|
|
|
const double T_contact = 273.15 + 20; // standard temperature for now
|
|
|
|
rs_func_.push_back(std::make_shared<Miscibility::RsSatAtContact>(props, cell, p_contact, T_contact));
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (size_t i = 0; i < rec.size(); ++i) {
|
|
|
|
rs_func_.push_back(std::make_shared<Miscibility::NoMixing>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rv_func_.reserve(rec.size());
|
2016-10-13 09:03:35 -05:00
|
|
|
if (deck.hasKeyword("VAPOIL")) {
|
2016-04-08 09:30:01 -05:00
|
|
|
const TableContainer& rvvdTables = tables.getRvvdTables();
|
2014-03-28 11:35:43 -05:00
|
|
|
for (size_t i = 0; i < rec.size(); ++i) {
|
2016-05-06 14:40:33 -05:00
|
|
|
if (eqlmap.cells(i).empty())
|
|
|
|
{
|
|
|
|
rv_func_.push_back(std::shared_ptr<Miscibility::RvVD>());
|
|
|
|
continue;
|
|
|
|
}
|
2014-03-31 09:16:45 -05:00
|
|
|
const int cell = *(eqlmap.cells(i).begin());
|
2016-02-29 08:41:08 -06:00
|
|
|
if (!rec[i].wetGasInitConstantRv()) {
|
|
|
|
if (rvvdTables.size() <= 0) {
|
|
|
|
OPM_THROW(std::runtime_error, "Cannot initialise: RVVD table not available.");
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
2016-02-29 08:41:08 -06:00
|
|
|
|
|
|
|
const RvvdTable& rvvdTable = rvvdTables.getTable<RvvdTable>(i);
|
|
|
|
std::vector<double> depthColumn = rvvdTable.getColumn("DEPTH").vectorCopy();
|
|
|
|
std::vector<double> rvColumn = rvvdTable.getColumn("RV").vectorCopy();
|
|
|
|
|
|
|
|
rv_func_.push_back(std::make_shared<Miscibility::RvVD>(props,
|
|
|
|
cell,
|
|
|
|
depthColumn , rvColumn));
|
|
|
|
|
2014-03-28 11:35:43 -05:00
|
|
|
} else {
|
2016-02-29 08:41:08 -06:00
|
|
|
if (rec[i].gasOilContactDepth() != rec[i].datumDepth()) {
|
2014-03-28 11:35:43 -05:00
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"Cannot initialise: when no explicit RVVD table is given, \n"
|
|
|
|
"datum depth must be at the gas-oil-contact. "
|
|
|
|
"In EQUIL region " << (i + 1) << " (counting from 1), this does not hold.");
|
|
|
|
}
|
2016-02-29 08:41:08 -06:00
|
|
|
const double p_contact = rec[i].datumDepthPressure() + rec[i].gasOilContactCapillaryPressure();
|
2014-11-20 05:15:01 -06:00
|
|
|
const double T_contact = 273.15 + 20; // standard temperature for now
|
|
|
|
rv_func_.push_back(std::make_shared<Miscibility::RvSatAtContact>(props, cell, p_contact, T_contact));
|
2014-03-28 11:35:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (size_t i = 0; i < rec.size(); ++i) {
|
|
|
|
rv_func_.push_back(std::make_shared<Miscibility::NoMixing>());
|
|
|
|
}
|
|
|
|
}
|
2014-06-10 07:02:22 -05:00
|
|
|
|
2014-03-28 11:35:43 -05:00
|
|
|
// Compute pressures, saturations, rs and rv factors.
|
|
|
|
calcPressSatRsRv(eqlmap, rec, props, G, grav);
|
|
|
|
|
|
|
|
// Modify oil pressure in no-oil regions so that the pressures of present phases can
|
|
|
|
// be recovered from the oil pressure and capillary relations.
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::vector<double> Vec;
|
|
|
|
typedef std::vector<Vec> PVec; // One per phase.
|
|
|
|
|
|
|
|
const PVec& press() const { return pp_; }
|
|
|
|
const PVec& saturation() const { return sat_; }
|
|
|
|
const Vec& rs() const { return rs_; }
|
|
|
|
const Vec& rv() const { return rv_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef DensityCalculator<BlackoilPropertiesInterface> RhoCalc;
|
|
|
|
typedef EquilReg<RhoCalc> EqReg;
|
|
|
|
|
|
|
|
std::vector< std::shared_ptr<Miscibility::RsFunction> > rs_func_;
|
|
|
|
std::vector< std::shared_ptr<Miscibility::RsFunction> > rv_func_;
|
|
|
|
|
|
|
|
PVec pp_;
|
|
|
|
PVec sat_;
|
|
|
|
Vec rs_;
|
|
|
|
Vec rv_;
|
2014-06-10 07:02:22 -05:00
|
|
|
Vec swat_init_;
|
2014-03-28 11:35:43 -05:00
|
|
|
|
2015-02-20 02:26:03 -06:00
|
|
|
template <class RMap, class Grid>
|
2014-03-28 11:35:43 -05:00
|
|
|
void
|
2014-06-10 07:02:22 -05:00
|
|
|
calcPressSatRsRv(const RMap& reg ,
|
|
|
|
const std::vector< EquilRecord >& rec ,
|
|
|
|
Opm::BlackoilPropertiesInterface& props,
|
2015-02-20 02:26:03 -06:00
|
|
|
const Grid& G ,
|
2014-03-28 11:35:43 -05:00
|
|
|
const double grav)
|
|
|
|
{
|
2015-09-02 03:36:07 -05:00
|
|
|
for (const auto& r : reg.activeRegions()) {
|
|
|
|
const auto& cells = reg.cells(r);
|
2016-05-06 14:40:33 -05:00
|
|
|
if (cells.empty())
|
|
|
|
{
|
2016-06-15 03:53:51 -05:00
|
|
|
OpmLog::warning("Equilibration region " + std::to_string(r + 1)
|
2016-06-15 02:40:38 -05:00
|
|
|
+ " has no active cells");
|
2016-06-15 03:52:32 -05:00
|
|
|
continue;
|
2016-05-06 14:40:33 -05:00
|
|
|
}
|
2014-03-28 11:35:43 -05:00
|
|
|
const int repcell = *cells.begin();
|
2015-09-02 03:36:07 -05:00
|
|
|
|
2014-03-28 11:35:43 -05:00
|
|
|
const RhoCalc calc(props, repcell);
|
|
|
|
const EqReg eqreg(rec[r], calc,
|
|
|
|
rs_func_[r], rv_func_[r],
|
|
|
|
props.phaseUsage());
|
|
|
|
|
2015-09-02 06:23:54 -05:00
|
|
|
PVec pressures = phasePressures(G, eqreg, cells, grav);
|
2014-11-20 05:15:01 -06:00
|
|
|
const std::vector<double>& temp = temperature(G, eqreg, cells);
|
2014-03-28 11:35:43 -05:00
|
|
|
|
2015-09-02 06:23:54 -05:00
|
|
|
const PVec sat = phaseSaturations(G, eqreg, cells, props, swat_init_, pressures);
|
2014-03-28 11:35:43 -05:00
|
|
|
|
|
|
|
const int np = props.numPhases();
|
|
|
|
for (int p = 0; p < np; ++p) {
|
2015-09-02 06:23:54 -05:00
|
|
|
copyFromRegion(pressures[p], cells, pp_[p]);
|
2014-03-28 11:35:43 -05:00
|
|
|
copyFromRegion(sat[p], cells, sat_[p]);
|
|
|
|
}
|
|
|
|
if (props.phaseUsage().phase_used[BlackoilPhases::Liquid]
|
|
|
|
&& props.phaseUsage().phase_used[BlackoilPhases::Vapour]) {
|
|
|
|
const int oilpos = props.phaseUsage().phase_pos[BlackoilPhases::Liquid];
|
|
|
|
const int gaspos = props.phaseUsage().phase_pos[BlackoilPhases::Vapour];
|
2015-09-02 06:23:54 -05:00
|
|
|
const Vec rs_vals = computeRs(G, cells, pressures[oilpos], temp, *(rs_func_[r]), sat[gaspos]);
|
|
|
|
const Vec rv_vals = computeRs(G, cells, pressures[gaspos], temp, *(rv_func_[r]), sat[oilpos]);
|
|
|
|
copyFromRegion(rs_vals, cells, rs_);
|
|
|
|
copyFromRegion(rv_vals, cells, rv_);
|
2014-02-27 06:14:48 -06:00
|
|
|
}
|
2014-02-21 01:52:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 02:31:48 -06:00
|
|
|
template <class CellRangeType>
|
|
|
|
void copyFromRegion(const Vec& source,
|
|
|
|
const CellRangeType& cells,
|
|
|
|
Vec& destination)
|
|
|
|
{
|
|
|
|
auto s = source.begin();
|
|
|
|
auto c = cells.begin();
|
|
|
|
const auto e = cells.end();
|
|
|
|
for (; c != e; ++c, ++s) {
|
|
|
|
destination[*c] = *s;
|
|
|
|
}
|
|
|
|
}
|
2014-02-21 01:52:25 -06:00
|
|
|
|
2014-01-23 03:16:49 -06:00
|
|
|
};
|
|
|
|
} // namespace DeckDependent
|
2016-02-29 08:41:08 -06:00
|
|
|
} // namespace EQUIL
|
Add basic equilibration facility
This commit adds a simple facility for calculating initial phase
pressures assuming stationary conditions, a known reference pressure
in the oil zone as well as the depth and capillary pressures at the
water-oil and gas-oil contacts.
Function 'Opm::equil::phasePressures()' uses a simple ODE/IVP-based
approach, solved using the traditional RK4 method with constant step
sizes, to derive the required pressure values. Specifically, we
solve the ODE
dp/dz = rho(z,p) * g
with 'z' represening depth, 'p' being a phase pressure and 'rho' the
associate phase density. Finally, 'g' is the acceleration of
gravity. We assume that we can calculate phase densities, e.g.,
from table look-up. This assumption holds in the case of an ECLIPSE
input deck.
Using RK4 with constant step sizes is a limitation of this
implementation. This, basically, assumes that the phase densities
varies only smoothly with depth and pressure (at reservoir
conditions).
2014-01-14 13:37:28 -06:00
|
|
|
} // namespace Opm
|
|
|
|
|
|
|
|
#include <opm/core/simulator/initStateEquil_impl.hpp>
|
|
|
|
|
|
|
|
#endif // OPM_INITSTATEEQUIL_HEADER_INCLUDED
|