2013-05-14 07:59:31 -05:00
|
|
|
/*
|
|
|
|
Copyright 2013 SINTEF ICT, Applied Mathematics.
|
|
|
|
Copyright 2013 Statoil ASA.
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2013-05-15 09:10:20 -05:00
|
|
|
#include <config.h>
|
|
|
|
|
2013-05-14 07:59:31 -05:00
|
|
|
#define BOOST_TEST_MODULE FluidPropertiesTest
|
|
|
|
|
2015-10-06 05:11:49 -05:00
|
|
|
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
2013-05-14 07:59:31 -05:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2015-10-06 05:11:49 -05:00
|
|
|
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
2015-08-11 02:20:35 -05:00
|
|
|
|
|
|
|
#include <opm/autodiff/BlackoilPropsAdFromDeck.hpp>
|
2013-05-14 07:59:31 -05:00
|
|
|
|
2018-02-09 06:42:16 -06:00
|
|
|
#include <opm/grid/GridManager.hpp>
|
2016-10-10 09:57:06 -05:00
|
|
|
#include <opm/parser/eclipse/Units/Units.hpp>
|
2018-01-30 06:25:35 -06:00
|
|
|
#include <opm/common/utility/parameters/ParameterGroup.hpp>
|
2013-05-14 07:59:31 -05:00
|
|
|
|
2014-04-11 04:54:16 -05:00
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
2016-03-16 21:02:50 -05:00
|
|
|
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
2014-06-06 07:28:40 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2014-04-11 04:54:16 -05:00
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
|
|
|
2013-05-14 07:59:31 -05:00
|
|
|
#include <fstream>
|
2013-09-03 08:30:00 -05:00
|
|
|
#include <iostream>
|
|
|
|
|
2013-05-14 07:59:31 -05:00
|
|
|
|
|
|
|
struct SetupSimple {
|
2016-10-14 02:23:26 -05:00
|
|
|
SetupSimple() :
|
|
|
|
deck( Opm::Parser{}.parseFile("fluid.data") ),
|
|
|
|
eclState( deck, Opm::ParseContext() )
|
2013-05-14 07:59:31 -05:00
|
|
|
{
|
2013-05-14 08:45:31 -05:00
|
|
|
param.disableOutput();
|
2013-05-14 08:41:34 -05:00
|
|
|
param.insertParameter("init_rock" , "false" );
|
2013-05-14 07:59:31 -05:00
|
|
|
param.insertParameter("threephase_model", "simple");
|
2013-05-14 08:41:45 -05:00
|
|
|
param.insertParameter("pvt_tab_size" , "0" );
|
|
|
|
param.insertParameter("sat_tab_size" , "0" );
|
2013-05-14 07:59:31 -05:00
|
|
|
}
|
|
|
|
|
2017-04-28 08:36:25 -05:00
|
|
|
Opm::ParameterGroup param;
|
2016-10-14 02:23:26 -05:00
|
|
|
Opm::Deck deck;
|
|
|
|
Opm::EclipseState eclState;
|
2013-05-14 07:59:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Setup>
|
|
|
|
struct TestFixture : public Setup
|
|
|
|
{
|
|
|
|
TestFixture()
|
|
|
|
: Setup()
|
2016-10-14 02:23:26 -05:00
|
|
|
, grid (eclState.getInputGrid())
|
2014-12-23 02:40:00 -06:00
|
|
|
, boprops_ad(deck, eclState, *grid.c_grid(), param.getDefault("init_rock", false))
|
2013-05-14 07:59:31 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-14 08:31:41 -05:00
|
|
|
using Setup::param;
|
2014-04-15 04:51:44 -05:00
|
|
|
using Setup::deck;
|
2014-06-06 07:28:40 -05:00
|
|
|
using Setup::eclState;
|
2013-05-14 08:31:41 -05:00
|
|
|
|
2014-12-23 02:40:00 -06:00
|
|
|
Opm::GridManager grid;
|
|
|
|
Opm::BlackoilPropsAdFromDeck boprops_ad;
|
2013-05-14 07:59:31 -05:00
|
|
|
};
|
|
|
|
|
2015-02-03 09:42:09 -06:00
|
|
|
template <class Setup>
|
|
|
|
struct TestFixtureAd : public Setup
|
|
|
|
{
|
|
|
|
TestFixtureAd()
|
|
|
|
: Setup()
|
2016-10-14 02:23:26 -05:00
|
|
|
, grid (eclState.getInputGrid())
|
2015-02-03 09:42:09 -06:00
|
|
|
, props(deck, eclState, *grid.c_grid(),
|
|
|
|
param.getDefault("init_rock", false))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
using Setup::param;
|
|
|
|
using Setup::deck;
|
|
|
|
using Setup::eclState;
|
|
|
|
|
|
|
|
Opm::GridManager grid;
|
|
|
|
Opm::BlackoilPropsAdFromDeck props;
|
|
|
|
};
|
|
|
|
|
2013-05-14 07:59:31 -05:00
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_CASE(Construction, TestFixture<SetupSimple>)
|
|
|
|
{
|
|
|
|
}
|
2013-05-14 10:29:49 -05:00
|
|
|
|
2015-02-03 09:42:09 -06:00
|
|
|
BOOST_FIXTURE_TEST_CASE(SubgridConstruction, TestFixtureAd<SetupSimple>)
|
|
|
|
{
|
|
|
|
Opm::BlackoilPropsAdFromDeck subgrid_props(props);
|
|
|
|
}
|
2013-09-03 07:41:38 -05:00
|
|
|
|
2013-05-14 10:29:49 -05:00
|
|
|
BOOST_FIXTURE_TEST_CASE(SurfaceDensity, TestFixture<SetupSimple>)
|
|
|
|
{
|
2015-10-26 04:33:58 -05:00
|
|
|
const Opm::BlackoilPropsAdFromDeck::Cells cells(1, 0);
|
|
|
|
|
|
|
|
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
|
|
|
|
2016-12-30 04:51:47 -06:00
|
|
|
enum { Water = Opm::Water };
|
2015-11-10 07:22:14 -06:00
|
|
|
V rho0AD_Water = boprops_ad.surfaceDensity(Water, cells);
|
|
|
|
BOOST_REQUIRE_EQUAL(rho0AD_Water.size(), cells.size());
|
|
|
|
BOOST_CHECK_EQUAL(rho0AD_Water[0], 1000.0);
|
2013-05-14 10:29:49 -05:00
|
|
|
|
2016-12-30 04:51:47 -06:00
|
|
|
enum { Oil = Opm::Oil };
|
2015-11-10 07:22:14 -06:00
|
|
|
V rho0AD_Oil = boprops_ad.surfaceDensity(Oil, cells);
|
|
|
|
BOOST_REQUIRE_EQUAL(rho0AD_Oil.size(), cells.size());
|
|
|
|
BOOST_CHECK_EQUAL(rho0AD_Oil[0], 800.0);
|
2013-05-14 10:29:49 -05:00
|
|
|
|
2016-12-30 04:51:47 -06:00
|
|
|
enum { Gas = Opm::Gas };
|
2015-11-10 07:22:14 -06:00
|
|
|
V rho0AD_Gas = boprops_ad.surfaceDensity(Gas, cells);
|
|
|
|
BOOST_REQUIRE_EQUAL(rho0AD_Gas.size(), cells.size());
|
|
|
|
BOOST_CHECK_EQUAL(rho0AD_Gas[0], 1.0);
|
2013-05-14 10:29:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_CASE(ViscosityValue, TestFixture<SetupSimple>)
|
|
|
|
{
|
2014-12-23 02:40:00 -06:00
|
|
|
const Opm::BlackoilPropsAdFromDeck::Cells cells(5, 0);
|
2013-05-14 10:29:49 -05:00
|
|
|
|
2014-12-23 02:40:00 -06:00
|
|
|
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
2015-03-02 06:10:41 -06:00
|
|
|
typedef Opm::BlackoilPropsAdFromDeck::ADB ADB;
|
2013-05-14 10:29:49 -05:00
|
|
|
|
|
|
|
V Vpw;
|
|
|
|
Vpw.resize(cells.size());
|
|
|
|
Vpw[0] = 1*Opm::unit::barsa;
|
|
|
|
Vpw[1] = 2*Opm::unit::barsa;
|
|
|
|
Vpw[2] = 4*Opm::unit::barsa;
|
|
|
|
Vpw[3] = 8*Opm::unit::barsa;
|
|
|
|
Vpw[4] = 16*Opm::unit::barsa;
|
|
|
|
|
2014-11-20 05:31:50 -06:00
|
|
|
// standard temperature
|
2014-12-02 02:24:03 -06:00
|
|
|
V T = V::Constant(cells.size(), 273.15+20);
|
2014-11-20 05:31:50 -06:00
|
|
|
|
2014-12-23 02:40:00 -06:00
|
|
|
BOOST_REQUIRE_EQUAL(Vpw.size(), cells.size());
|
|
|
|
|
2015-03-02 06:10:41 -06:00
|
|
|
const V VmuWat = boprops_ad.muWat(ADB::constant(Vpw), ADB::constant(T), cells).value();
|
2014-12-23 02:40:00 -06:00
|
|
|
|
|
|
|
BOOST_REQUIRE_EQUAL(Vpw.size(), cells.size());
|
2013-05-14 10:29:49 -05:00
|
|
|
|
|
|
|
// Zero pressure dependence in water viscosity
|
|
|
|
for (V::Index i = 0, n = VmuWat.size(); i < n; ++i) {
|
|
|
|
BOOST_CHECK_EQUAL(VmuWat[i], VmuWat[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_CASE(ViscosityAD, TestFixture<SetupSimple>)
|
|
|
|
{
|
2014-12-23 02:40:00 -06:00
|
|
|
const Opm::BlackoilPropsAdFromDeck::Cells cells(5, 0);
|
2013-05-14 10:29:49 -05:00
|
|
|
|
2014-12-23 02:40:00 -06:00
|
|
|
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
2015-03-02 06:10:41 -06:00
|
|
|
typedef Opm::BlackoilPropsAdFromDeck::ADB ADB;
|
2013-05-14 10:29:49 -05:00
|
|
|
|
|
|
|
V Vpw;
|
|
|
|
Vpw.resize(cells.size());
|
|
|
|
Vpw[0] = 1*Opm::unit::barsa;
|
|
|
|
Vpw[1] = 2*Opm::unit::barsa;
|
|
|
|
Vpw[2] = 4*Opm::unit::barsa;
|
|
|
|
Vpw[3] = 8*Opm::unit::barsa;
|
|
|
|
Vpw[4] = 16*Opm::unit::barsa;
|
|
|
|
|
2014-11-20 05:31:50 -06:00
|
|
|
// standard temperature
|
2014-12-02 02:24:03 -06:00
|
|
|
V T = V::Constant(cells.size(), 273.15+20);
|
2014-11-20 05:31:50 -06:00
|
|
|
|
2014-12-23 02:40:00 -06:00
|
|
|
typedef Opm::BlackoilPropsAdFromDeck::ADB ADB;
|
2013-05-14 10:29:49 -05:00
|
|
|
|
2015-03-02 06:10:41 -06:00
|
|
|
const V VmuWat = boprops_ad.muWat(ADB::constant(Vpw), ADB::constant(T), cells).value();
|
2013-05-14 10:29:49 -05:00
|
|
|
for (V::Index i = 0, n = Vpw.size(); i < n; ++i) {
|
|
|
|
const std::vector<int> bp(1, grid.c_grid()->number_of_cells);
|
|
|
|
|
2014-12-23 02:40:00 -06:00
|
|
|
const Opm::BlackoilPropsAdFromDeck::Cells c(1, 0);
|
2013-05-14 10:29:49 -05:00
|
|
|
const V pw = V(1, 1) * Vpw[i];
|
|
|
|
const ADB Apw = ADB::variable(0, pw, bp);
|
2014-11-20 05:31:50 -06:00
|
|
|
const ADB AT = ADB::constant(T);
|
|
|
|
const ADB AmuWat = boprops_ad.muWat(Apw, AT, c);
|
2013-05-14 10:29:49 -05:00
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(AmuWat.value()[0], VmuWat[i]);
|
|
|
|
}
|
|
|
|
}
|
2015-12-08 09:07:23 -06:00
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_CASE(criticalSaturations, TestFixture<SetupSimple>)
|
|
|
|
{
|
|
|
|
const Opm::BlackoilPropsAdFromDeck::Cells cells(10, 0);
|
|
|
|
|
|
|
|
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
|
|
|
|
|
|
|
V sgcr = boprops_ad.scaledCriticalGasSaturations(cells);
|
|
|
|
V sogcr = boprops_ad.scaledCriticalOilinGasSaturations(cells);
|
|
|
|
BOOST_CHECK_EQUAL(sgcr[0], 0.02);
|
|
|
|
BOOST_CHECK_EQUAL(sogcr[0], 0.13);
|
|
|
|
|
|
|
|
}
|