// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- // vi: set et ts=4 sw=4 sts=4: /* 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 2 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 . Consult the COPYING file in the top-level source directory of this module for the precise wording of the license and the list of copyright holders. */ /*! * \file * * \brief This test makes sure that the programming interface is * observed by all fluid systems */ #include "config.h" #include #define BOOST_TEST_MODULE FluidSystems #include #include #include #include // include all fluid systems in opm-material #include #include #include #include #include #include #include #include #include #include // include all fluid states #include #include #include #include #include #include #include #include // include the tables for CO2 which are delivered with opm-material by default #include #include #if HAVE_ECL_INPUT #include #include #include #endif // check that the blackoil fluid system implements all non-standard functions template void ensureBlackoilApi() { // here we don't want to call these methods at runtime, we just want to make sure // that they compile while (false) { #if HAVE_ECL_INPUT auto python = std::make_shared(); Opm::Deck deck; Opm::EclipseState eclState(deck); Opm::Schedule schedule(deck, eclState, python); FluidSystem::initFromState(eclState, schedule); #endif typedef typename FluidSystem::Scalar Scalar; typedef Opm::BlackOilFluidState FluidState; FluidState fluidState; Evaluation XoG = 0.0; Evaluation XwG = 0.0; Evaluation XgO = 0.0; Evaluation Rs = 0.0; Evaluation Rv = 0.0; // some additional typedefs typedef typename FluidSystem::OilPvt OilPvt; typedef typename FluidSystem::GasPvt GasPvt; typedef typename FluidSystem::WaterPvt WaterPvt; // check the black-oil specific enums static_assert(FluidSystem::numPhases == 3, ""); static_assert(FluidSystem::numComponents == 3, ""); static_assert(0 <= FluidSystem::oilPhaseIdx && FluidSystem::oilPhaseIdx < 3, ""); static_assert(0 <= FluidSystem::gasPhaseIdx && FluidSystem::gasPhaseIdx < 3, ""); static_assert(0 <= FluidSystem::waterPhaseIdx && FluidSystem::waterPhaseIdx < 3, ""); static_assert(0 <= FluidSystem::oilCompIdx && FluidSystem::oilCompIdx < 3, ""); static_assert(0 <= FluidSystem::gasCompIdx && FluidSystem::gasCompIdx < 3, ""); static_assert(0 <= FluidSystem::waterCompIdx && FluidSystem::waterCompIdx < 3, ""); // check the non-parser initialization std::shared_ptr oilPvt; std::shared_ptr gasPvt; std::shared_ptr waterPvt; unsigned numPvtRegions = 2; FluidSystem::initBegin(numPvtRegions); FluidSystem::setEnableDissolvedGas(true); FluidSystem::setEnableVaporizedOil(true); FluidSystem::setEnableDissolvedGasInWater(true); FluidSystem::setGasPvt(gasPvt); FluidSystem::setOilPvt(oilPvt); FluidSystem::setWaterPvt(waterPvt); FluidSystem::setReferenceDensities(/*oil=*/600.0, /*water=*/1000.0, /*gas=*/1.0, /*regionIdx=*/0); FluidSystem::initEnd(); // the molarMass() method has an optional argument for the PVT region [[maybe_unused]] unsigned numRegions = FluidSystem::numRegions(); [[maybe_unused]] Scalar Mg = FluidSystem::molarMass(FluidSystem::gasCompIdx, /*regionIdx=*/0); [[maybe_unused]] bool b1 = FluidSystem::enableDissolvedGas(); [[maybe_unused]] bool b2 = FluidSystem::enableVaporizedOil(); [[maybe_unused]] Scalar rhoRefOil = FluidSystem::referenceDensity(FluidSystem::oilPhaseIdx, /*regionIdx=*/0); std::cout << FluidSystem::convertXoGToRs(XoG, /*regionIdx=*/0); std::cout << FluidSystem::convertXwGToRsw(XwG, /*regionIdx=*/0); std::cout << FluidSystem::convertXgOToRv(XgO, /*regionIdx=*/0); std::cout << FluidSystem::convertXoGToxoG(XoG, /*regionIdx=*/0); std::cout << FluidSystem::convertXgOToxgO(XgO, /*regionIdx=*/0); std::cout << FluidSystem::convertRsToXoG(Rs, /*regionIdx=*/0); std::cout << FluidSystem::convertRvToXgO(Rv, /*regionIdx=*/0); for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++ phaseIdx) { std::cout << FluidSystem::density(fluidState, phaseIdx, /*regionIdx=*/0); std::cout << FluidSystem::saturatedDensity(fluidState, phaseIdx, /*regionIdx=*/0); std::cout << FluidSystem::inverseFormationVolumeFactor(fluidState, phaseIdx, /*regionIdx=*/0); std::cout << FluidSystem::saturatedInverseFormationVolumeFactor(fluidState, phaseIdx, /*regionIdx=*/0); std::cout << FluidSystem::viscosity(fluidState, phaseIdx, /*regionIdx=*/0); std::cout << FluidSystem::saturatedDissolutionFactor(fluidState, phaseIdx, /*regionIdx=*/0); std::cout << FluidSystem::saturatedDissolutionFactor(fluidState, phaseIdx, /*regionIdx=*/0, /*maxSo=*/1.0); std::cout << FluidSystem::saturationPressure(fluidState, phaseIdx, /*regionIdx=*/0); for (unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++ compIdx) std::cout << FluidSystem::fugacityCoefficient(fluidState, phaseIdx, compIdx, /*regionIdx=*/0); } // the "not considered safe to use directly" API [[maybe_unused]] const OilPvt& oilPvt2 = FluidSystem::oilPvt(); [[maybe_unused]] const GasPvt& gasPvt2 = FluidSystem::gasPvt(); [[maybe_unused]] const WaterPvt& waterPvt2 = FluidSystem::waterPvt(); } } using EvalTypes = boost::mpl::list,Opm::DenseAd::Evaluation>; BOOST_AUTO_TEST_CASE_TEMPLATE(SimpleModularFluidState, Eval, EvalTypes) { Opm::SimpleModularFluidState fs; checkFluidState(fs); using FluidSystem = Opm::H2ON2FluidSystem; Opm::SimpleModularFluidState fs2; checkFluidState(fs2); } BOOST_AUTO_TEST_CASE_TEMPLATE(CompositionalFluidState, Eval, EvalTypes) { using FluidSystem = Opm::H2ON2FluidSystem; Opm::CompositionalFluidState fs; checkFluidState(fs); } BOOST_AUTO_TEST_CASE_TEMPLATE(NonEquilibriumFluidState, Eval, EvalTypes) { using FluidSystem = Opm::H2ON2FluidSystem; Opm::NonEquilibriumFluidState fs; checkFluidState(fs); } BOOST_AUTO_TEST_CASE_TEMPLATE(ImmiscibleFluidState, Eval, EvalTypes) { using FluidSystem = Opm::H2ON2FluidSystem; Opm::ImmiscibleFluidState fs; checkFluidState(fs); } BOOST_AUTO_TEST_CASE_TEMPLATE(TemperatureOverlayFluidState, Eval, EvalTypes) { using FluidSystem = Opm::H2ON2FluidSystem; using BaseFluidState = Opm::CompositionalFluidState; BaseFluidState baseFs; Opm::TemperatureOverlayFluidState fs(baseFs); checkFluidState(fs); } BOOST_AUTO_TEST_CASE_TEMPLATE(PressureOverlayFluidState, Eval, EvalTypes) { using FluidSystem = Opm::H2ON2FluidSystem; using BaseFluidState = Opm::CompositionalFluidState; BaseFluidState baseFs; Opm::PressureOverlayFluidState fs(baseFs); checkFluidState(fs); } BOOST_AUTO_TEST_CASE_TEMPLATE(SaturationOverlayFluidState, Eval, EvalTypes) { using FluidSystem = Opm::H2ON2FluidSystem; using BaseFluidState = Opm::CompositionalFluidState; BaseFluidState baseFs; Opm::SaturationOverlayFluidState fs(baseFs); checkFluidState(fs); } using ScalarTypes = boost::mpl::list; BOOST_AUTO_TEST_CASE_TEMPLATE(BlackoilFluidSystem, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using FluidSystem = Opm::BlackOilFluidSystem; if (false) checkFluidSystem(); if (false) checkFluidSystem(); if (false) checkFluidSystem(); using BlackoilDummyEval = Opm::DenseAd::Evaluation; ensureBlackoilApi(); ensureBlackoilApi(); } BOOST_AUTO_TEST_CASE_TEMPLATE(BrineCO2FluidSystem, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using FluidSystem = Opm::BrineCO2FluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(H2ON2FluidSystem, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using FluidSystem = Opm::H2ON2FluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(H2ON2LiquidPhaseFluidSystem, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using FluidSystem = Opm::H2ON2LiquidPhaseFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(H2OAirFluidSystem, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using H2O = Opm::SimpleH2O; using FluidSystem = Opm::H2OAirFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(H2OAirXyleneFluidSystem, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using FluidSystem = Opm::H2OAirXyleneFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(TwoPhaseImmiscibleFluidSystemLL, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using Liquid = Opm::LiquidPhase>; using FluidSystem = Opm::TwoPhaseImmiscibleFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(TwoPhaseImmiscibleFluidSystemLG, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using Gas = Opm::GasPhase>; using Liquid = Opm::LiquidPhase>; using FluidSystem = Opm::TwoPhaseImmiscibleFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(TwoPhaseImmiscibleFluidSystemGL, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using Gas = Opm::GasPhase>; using Liquid = Opm::LiquidPhase>; using FluidSystem = Opm::TwoPhaseImmiscibleFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(SinglePhaseFluidSystemL, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using Liquid = Opm::LiquidPhase>; using FluidSystem = Opm::SinglePhaseFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); } BOOST_AUTO_TEST_CASE_TEMPLATE(SinglePhaseFluidSystemG, Scalar, ScalarTypes) { using Evaluation = Opm::DenseAd::Evaluation; using Gas = Opm::GasPhase>; using FluidSystem = Opm::SinglePhaseFluidSystem; checkFluidSystem(); checkFluidSystem(); checkFluidSystem(); }