Пример #1
0
def test_factory_gaswater():
    """Test that we can create gas-water curves from dictionaries of parameters"""
    pyscal_factory = PyscalFactory()

    with pytest.raises(TypeError):
        # pylint: disable=unexpected-keyword-arg
        pyscal_factory.create_gas_water(swirr=0.01)  # noqa

    gaswater = pyscal_factory.create_gas_water(
        dict(swirr=0.01,
             swl=0.03,
             sgrw=0.1,
             sgcr=0.15,
             tag="gassy sand",
             ng=2,
             nw=2))

    assert isinstance(gaswater, GasWater)

    assert gaswater.swirr == 0.01
    assert gaswater.swl == 0.03
    assert gaswater.sgrw == 0.1
    assert gaswater.sgcr == 0.15
    assert gaswater.tag == "gassy sand"

    sgfn = gaswater.SGFN()
    swfn = gaswater.SWFN()
    sat_table_str_ok(sgfn)
    sat_table_str_ok(swfn)
    check_table(gaswater.wateroil.table)
    check_table(gaswater.gasoil.table)

    assert "sgrw=0.1" in swfn
    assert "swirr=0.01" in sgfn
    assert "swirr=0.01" in swfn
    assert "sgrw=0.1" in swfn
    assert "sgcr=0.15" in sgfn
    assert "nw=2" in swfn
    assert "ng=2" in sgfn
    assert "gassy sand" in sgfn

    gaswater = pyscal_factory.create_gas_water(dict(lg=1, eg=1, tg=1, nw=3))

    sgfn = gaswater.SGFN()
    swfn = gaswater.SWFN()
    sat_table_str_ok(sgfn)
    sat_table_str_ok(swfn)
    check_table(gaswater.wateroil.table)
    check_table(gaswater.gasoil.table)
Пример #2
0
def test_fast_mode():
    """Test that the fast-flag is passed on to constructed objects

    Each object's own test code tests the actual effects of the fast flag"""
    wateroil = PyscalFactory.create_water_oil({"nw": 2, "now": 2})
    assert not wateroil.fast
    wateroil = PyscalFactory.create_water_oil({"nw": 2, "now": 2}, fast=True)
    assert wateroil.fast

    gasoil = PyscalFactory.create_gas_oil({"ng": 2, "nog": 2})
    assert not gasoil.fast
    gasoil = PyscalFactory.create_gas_oil({"ng": 2, "nog": 2}, fast=True)
    assert gasoil.fast

    gaswater = PyscalFactory.create_gas_water({"nw": 2, "ng": 2})
    assert not gaswater.gasoil.fast
    assert not gaswater.wateroil.fast
    gaswater = PyscalFactory.create_gas_water({"nw": 2, "ng": 2}, fast=True)
    assert gaswater.gasoil.fast
    assert gaswater.wateroil.fast
    assert gaswater.fast

    wateroilgas = PyscalFactory.create_water_oil_gas(
        {"nw": 2, "now": 2, "ng": 2, "nog": 2}, fast=True
    )
    assert wateroilgas.fast
    assert wateroilgas.wateroil.fast
    assert wateroilgas.gasoil.fast

    scalrec = PyscalFactory.create_scal_recommendation(
        {
            "low": {"nw": 2, "now": 2, "ng": 2, "nog": 2},
            "base": {"nw": 2, "now": 2, "ng": 2, "nog": 2},
            "high": {"nw": 2, "now": 2, "ng": 2, "nog": 2},
        },
        fast=True,
    )
    assert scalrec.low.fast
    assert scalrec.base.fast
    assert scalrec.high.fast

    interpolant = scalrec.interpolate(-0.5)
    assert interpolant.fast
Пример #3
0
def test_relative_swcr():
    """swcr can be initialized relative to swl

    Relevant when swl is initialized from swlheight."""
    pyscal_factory = PyscalFactory()

    with pytest.raises(ValueError, match="swl must be provided"):
        pyscal_factory.create_water_oil(dict(swcr_add=0.1, nw=1, now=1, swirr=0.01))
    with pytest.raises(ValueError, match="swcr and swcr_add at the same time"):
        pyscal_factory.create_water_oil(
            dict(swcr_add=0.1, swcr=0.1, swl=0.1, nw=1, now=1, swirr=0.01)
        )
    wateroil = pyscal_factory.create_water_oil(
        dict(swcr_add=0.1, swl=0.1, nw=1, now=1, swirr=0.01)
    )
    assert wateroil.swcr == 0.2

    # Test when relative to swlheight:
    wateroil = pyscal_factory.create_water_oil(
        dict(
            swlheight=200,
            swcr_add=0.01,
            nw=1,
            now=1,
            swirr=0.01,
            a=1,
            b=-2,
            poro_ref=0.2,
            perm_ref=100,
            drho=200,
        )
    )
    assert np.isclose(wateroil.swl, 0.02480395)
    assert np.isclose(wateroil.swcr, 0.02480395 + 0.01)

    gaswater = pyscal_factory.create_gas_water(
        dict(
            swlheight=200,
            nw=1,
            ng=1,
            swirr=0.01,
            swcr_add=0.1,
            a=1,
            b=-2,
            poro_ref=0.2,
            perm_ref=100,
            drho=200,
        )
    )
    assert np.isclose(gaswater.swl, 0.02480395)
    assert np.isclose(gaswater.swcr, 0.02480395 + 0.1)
Пример #4
0
def test_init_with_swlheight():
    """With sufficient parameters, swl will be calculated on the fly
    when initializing the WaterOil object"""
    pyscal_factory = PyscalFactory()
    wateroil = pyscal_factory.create_water_oil(
        dict(
            swlheight=200,
            nw=1,
            now=1,
            swirr=0.01,
            a=1,
            b=-2,
            poro_ref=0.2,
            perm_ref=100,
            drho=200,
        )
    )
    assert np.isclose(wateroil.swl, 0.02480395)
    assert "swl=0.024" in wateroil.SWOF()

    with pytest.raises(
        ValueError,
        match="Can't initialize from SWLHEIGHT without sufficient simple-J parameters",
    ):
        # This should fail because capillary pressure parameters are not provided.
        pyscal_factory.create_water_oil(dict(swlheight=200, nw=1, now=1))

    # swcr must be larger than swl:
    with pytest.raises(ValueError, match="lower than computed swl"):
        pyscal_factory.create_water_oil(
            dict(
                swlheight=200,
                nw=1,
                now=1,
                swirr=0.01,
                swcr=0.0101,
                a=1,
                b=-2,
                poro_ref=0.2,
                perm_ref=100,
                drho=200,
            )
        )

    # If swcr is large enough, it will pass:
    wateroil = pyscal_factory.create_water_oil(
        dict(
            swlheight=200,
            nw=1,
            now=1,
            swirr=0.01,
            swcr=0.3,
            a=1,
            b=-2,
            poro_ref=0.2,
            perm_ref=100,
            drho=200,
        )
    )
    assert wateroil.swcr > wateroil.swl
    assert wateroil.swcr == 0.3
    assert "swcr=0.3" in wateroil.SWOF()

    # Test that GasWater also can be initialized with swlheight:
    gaswater = pyscal_factory.create_gas_water(
        dict(
            swlheight=200,
            nw=1,
            ng=1,
            swirr=0.01,
            swcr=0.3,
            a=1,
            b=-2,
            poro_ref=0.2,
            perm_ref=100,
            drho=200,
        )
    )
    assert "swl=0.024" in gaswater.SWFN()
    assert gaswater.swcr > gaswater.swl
    assert gaswater.swcr == 0.3
    assert "swcr=0.3" in gaswater.SWFN()