Exemplo n.º 1
0
int main()
{
    typedef double Scalar;

    Opm::Parser parser;
    Opm::ParseMode parseMode;

    const auto deck = parser.parseString(deckString1, parseMode);
    const auto eclState = std::make_shared<Opm::EclipseState>(deck, parseMode);
    const auto eclGrid = eclState->getEclipseGrid();

    const auto pvtwKeyword = deck->getKeyword("PVTW");
    size_t numPvtRegions = pvtwKeyword->size();

    if (numPvtRegions != 2)
        OPM_THROW(std::logic_error,
                  "The number of PVT regions of the test deck must be 2. (is "
                  << numPvtRegions << ")");

    //////////
    // constant compressibility water
    //////////
    Opm::ConstantCompressibilityWaterPvt<Scalar> constCompWaterPvt;
    constCompWaterPvt.initFromDeck(deck, eclState);

    // make sure that the values at the reference points are the ones specified in the
    // deck.
    Scalar refTmp, tmp;

    refTmp = 1.1e-3; // the deck value is given in cP, while the SI units use Pa s...
    tmp = constCompWaterPvt.viscosity(/*regionIdx=*/0,
                                      /*temperature=*/273.15 + 20.0,
                                      /*pressure=*/1e5);
    if (std::abs(tmp - refTmp)  > 1e-30)
        OPM_THROW(std::logic_error,
                  "The reference water viscosity at region 0 is supposed to be " << refTmp
                  << ". (is " << tmp << ")");

    refTmp = 1.2e-3;
    tmp = constCompWaterPvt.viscosity(/*regionIdx=*/1,
                                      /*temperature=*/273.15 + 20.0,
                                      /*pressure=*/2e5);
    if (std::abs(tmp - refTmp)  > 1e-30)
        OPM_THROW(std::logic_error,
                  "The reference water viscosity at region 1 is supposed to be " << refTmp
                  << ". (is " << tmp << ")");

    refTmp = 500/1.1;
    tmp = constCompWaterPvt.density(/*regionIdx=*/0,
                                    /*temperature=*/273.15 + 20.0,
                                    /*pressure=*/1e5);
    if (std::abs(tmp - refTmp)  > 5e-14)
        OPM_THROW(std::logic_error,
                  "The reference water density at region 0 is supposed to be " << refTmp
                  << ". (is " << tmp << ")");


    refTmp = 600/1.2;
    tmp = constCompWaterPvt.density(/*regionIdx=*/1,
                                    /*temperature=*/273.15 + 20.0,
                                    /*pressure=*/2e5);
    if (std::abs(tmp - refTmp)  > 5e-14)
        OPM_THROW(std::logic_error,
                  "The reference water density at region 1 is supposed to be " << refTmp
                  << ". (is " << tmp << ")");

    //////////
    // the gas and oil PVT classes.
    //
    // TODO: check the results
    //////////
    Opm::GasPvtMultiplexer<Scalar> gasPvt;
    Opm::OilPvtMultiplexer<Scalar> oilPvt;
    Opm::WaterPvtMultiplexer<Scalar> waterPvt;

    gasPvt.initFromDeck(deck, eclState);
    oilPvt.initFromDeck(deck, eclState);
    waterPvt.initFromDeck(deck, eclState);

    gasPvt.initEnd(&oilPvt);
    oilPvt.initEnd(&gasPvt);
    waterPvt.initEnd();

    // make sure that the BlackOil fluid system's initFromDeck() method compiles.
    typedef Opm::FluidSystems::BlackOil<Scalar> BlackOilFluidSystem;
    BlackOilFluidSystem::initFromDeck(deck, eclState);

    return 0;
}
Exemplo n.º 2
0
inline void testAll()
{
    static const Scalar tolerance = std::numeric_limits<Scalar>::epsilon()*1e3;

    Opm::Parser parser;
    Opm::ParseMode parseMode;

    const auto deck = parser.parseString(deckString1, parseMode);
    const auto eclState = std::make_shared<Opm::EclipseState>(deck, parseMode);
    const auto eclGrid = eclState->getEclipseGrid();

    const auto pvtwKeyword = deck->getKeyword("PVTW");
    size_t numPvtRegions = pvtwKeyword->size();

    if (numPvtRegions != 2)
        OPM_THROW(std::logic_error,
                  "The number of PVT regions of the test deck must be 2. (is "
                  << numPvtRegions << ")");

    //////////
    // constant compressibility water
    //////////
    Opm::ConstantCompressibilityWaterPvt<Scalar> constCompWaterPvt;
    constCompWaterPvt.initFromDeck(deck, eclState);

    // make sure that the values at the reference points are the ones specified in the
    // deck.
    Scalar refTmp, tmp;

    refTmp = 1.1e-3; // the deck value is given in cP, while the SI units use Pa s...
    tmp = constCompWaterPvt.viscosity(/*regionIdx=*/0,
                                      /*temperature=*/273.15 + 20.0,
                                      /*pressure=*/1e5);
    if (std::abs(tmp - refTmp)  > tolerance)
        OPM_THROW(std::logic_error,
                  "The reference water viscosity at region 0 is supposed to be " << refTmp
                  << ". (is " << tmp << ")");

    refTmp = 1.2e-3;
    tmp = constCompWaterPvt.viscosity(/*regionIdx=*/1,
                                      /*temperature=*/273.15 + 20.0,
                                      /*pressure=*/2e5);
    if (std::abs(tmp - refTmp)  > tolerance)
        OPM_THROW(std::logic_error,
                  "The reference water viscosity at region 1 is supposed to be " << refTmp
                  << ". (is " << tmp << ")");

    //////////
    // the gas and oil PVT classes.
    //
    // TODO: check the results
    //////////
    Opm::GasPvtMultiplexer<Scalar> gasPvt;
    Opm::OilPvtMultiplexer<Scalar> oilPvt;
    Opm::WaterPvtMultiplexer<Scalar> waterPvt;

    gasPvt.initFromDeck(deck, eclState);
    oilPvt.initFromDeck(deck, eclState);
    waterPvt.initFromDeck(deck, eclState);

    gasPvt.initEnd();
    oilPvt.initEnd();
    waterPvt.initEnd();

    struct Foo;
    typedef Opm::LocalAd::Evaluation<Scalar, Foo, 1> FooEval;
    ensurePvtApi<Scalar>(oilPvt, gasPvt, waterPvt);
    ensurePvtApi<FooEval>(oilPvt, gasPvt, waterPvt);

    // make sure that the BlackOil fluid system's initFromDeck() method compiles.
    typedef Opm::FluidSystems::BlackOil<Scalar> BlackOilFluidSystem;
    BlackOilFluidSystem::initFromDeck(deck, eclState);
}