예제 #1
0
def test_go_fromtable_problems():
    df1 = pd.DataFrame(columns=["Sg", "KRG", "KROG", "PCOG"],
                       data=[[0.1, 0, 1, 2], [0.9, 1, 0, 0]])
    # Now sgcr and swl is wrong:
    go = GasOil(h=0.1)
    with pytest.raises(ValueError):
        # Should say sg must start at zero.
        go.add_fromtable(df1, pccolname="PCOG")
    df2 = pd.DataFrame(columns=["Sg", "KRG", "KROG", "PCOG"],
                       data=[[0.0, 0, 1, 2], [0.9, 0.8, 0, 0]])
    with pytest.raises(ValueError):
        # should say too large swl for pcog interpolation
        go = GasOil(h=0.1)
        go.add_fromtable(df2, pccolname="PCOG")
    go = GasOil(h=0.1, swl=0.1)
    go.add_fromtable(df2, pccolname="PCOG")
    assert np.isclose(go.table["pc"].max(), 2.0)
    assert np.isclose(go.table["pc"].min(), 0.0)
    assert np.isclose(go.table["sg"].max(), 0.9)

    go = GasOil(h=0.1)
    with pytest.raises(ValueError):
        # sg must start at zero
        go.add_fromtable(df1, krgcolname="KRG", krogcolname="KROG")
    # This works fine, but we get warnings on swl not seemingly correct
    go.add_fromtable(df2, krgcolname="KRG", krogcolname="KROG")
    # krg will be extrapolated to sg=1
    float_df_checker(go.table, "sg", 1.0, "krg", 0.8)
    float_df_checker(go.table, "sg", 1.0, "krog", 0.0)
    go = GasOil(h=0.1, swl=0.1)
    go.add_fromtable(df2, krgcolname="KRG", krogcolname="KROG")
예제 #2
0
def check_endpoints(go, krgend, krgmax, kroend, kromax):
    swtol = 1 / SWINTEGERS

    # Check endpoints for oil curve:
    # krog at sgcr should be kroend
    if go.sgcr > go.swl + swtol:
        assert float_df_checker(go.table, "son", 1.0, "krog", kroend)
    # krog at son=0 (1-sorg-swl or 1 - swl) should be zero:
    assert float_df_checker(go.table, "son", 0.0, "krog", 0)

    if go.sgcr > go.swl + swtol:
        assert float_df_checker(go.table, "sg", 0, "krog", kromax)
        assert float_df_checker(go.table, "sg", go.sgcr, "krog", kroend)
    else:
        if not np.isclose(go.table["krog"].max(), kroend):
            print(go.table.head())
        assert np.isclose(go.table["krog"].max(), kroend)

    assert float_df_checker(go.table, "sgn", 0.0, "krg", 0)
    assert float_df_checker(go.table, "sg", go.sgcr, "krg", 0)

    # If krgendanchor == "sorg" then krgmax is irrelevant.
    if go.sorg > swtol and go.sorg > go.h and go.krgendanchor == "sorg":
        assert float_df_checker(go.table, "sgn", 1.0, "krg", krgend)
        assert np.isclose(go.table["krg"].max(), krgmax)
    if go.krgendanchor != "sorg":
        assert np.isclose(go.table["krg"].max(), krgend)
예제 #3
0
def test_wateroil_normalization(swirr, swl, swcr, sorw, h, tag):
    """Shoot with more realistic values and test normalized saturations"""
    wo = WaterOil(swirr=swirr, swl=swl, swcr=swcr, sorw=sorw, h=h, tag=tag)
    assert not wo.table.empty
    assert not wo.table.isnull().values.any()

    # Check that son is 1 at swcr:
    assert float_df_checker(wo.table, "sw", wo.swcr, "son", 1)
    # Check that son is 0 at sorw:
    if wo.sorw > h:
        assert float_df_checker(wo.table, "sw", 1 - wo.sorw, "son", 0)

    # Check that swn is 0 at swcr:
    assert float_df_checker(wo.table, "sw", wo.swcr, "swn", 0)
    # Check that swn is 1 at 1 - sorw
    if wo.sorw > 1 / SWINTEGERS:
        assert float_df_checker(wo.table, "sw", 1 - wo.sorw, "swn", 1)

    # Check that swnpc is 0 at swirr and 1 at 1:
    if wo.swirr >= wo.swl + h:
        assert float_df_checker(wo.table, "sw", wo.swirr, "swnpc", 0)
    else:
        # Let this go, when swirr is too close to swl. We
        # are not guaranteed to have sw=swirr present
        pass

    assert float_df_checker(wo.table, "sw", 1.0, "swnpc", 1)
예제 #4
0
def test_gasoil_normalization(swl, sgcr, sorg, h, tag):
    """Check that normalization (sgn and son) is correct
    for all possible saturation endpoints"""
    go = GasOil(
        swirr=0.0, swl=swl, sgcr=sgcr, sorg=sorg, h=h, krgendanchor="sorg", tag=tag
    )
    assert not go.table.empty
    assert not go.table.isnull().values.any()

    # Check that son is 1 at sgcr
    assert float_df_checker(go.table, "sg", go.sgcr, "son", 1)

    # Check that son is 0 at sorg with this krgendanchor
    assert float_df_checker(go.table, "sg", 1 - go.sorg - go.swl, "son", 0)

    # Check that sgn is 0 at sgcr
    assert float_df_checker(go.table, "sg", go.sgcr, "sgn", 0)

    # Check that sgn is 1 at sorg
    assert float_df_checker(go.table, "sg", 1 - go.sorg - go.swl, "sgn", 1)

    # Redo with different krgendanchor
    go = GasOil(swirr=0.0, swl=swl, sgcr=sgcr, sorg=sorg, h=h, krgendanchor="", tag=tag)
    assert float_df_checker(go.table, "sg", 1 - go.swl, "sgn", 1)
    assert float_df_checker(go.table, "sg", go.sgcr, "sgn", 0)
예제 #5
0
def test_gasoil_kromax():
    go = GasOil(h=0.1, sgcr=0.1)
    go.add_corey_oil(2, 0.5)  # Default for kromax
    assert float_df_checker(go.table, "sg", 0.0, "krog", 1.0)
    assert float_df_checker(go.table, "sg", 0.1, "krog", 0.5)
    go.add_corey_oil(2, 0.5, 0.7)
    assert float_df_checker(go.table, "sg", 0.0, "krog", 0.7)
    assert float_df_checker(go.table, "sg", 0.1, "krog", 0.5)

    go = GasOil(h=0.1, sgcr=0.0)
    go.add_corey_oil(2, 0.5)
    assert float_df_checker(go.table, "sg", 0.0, "krog", 0.5)
    go.add_corey_oil(2, 0.5, 1)  # A warning will be given
    assert float_df_checker(go.table, "sg", 0.0, "krog", 0.5)
예제 #6
0
def test_normalized_J():
    wo = WaterOil(swirr=0.1, h=0.1)
    with pytest.raises(ValueError):
        wo.add_normalized_J(a=0.5, b=-0.2, poro=0.2, perm=10, sigma_costau=30)

    wo = WaterOil(swirr=0, swl=0.1, h=0.1)
    wo.add_normalized_J(a=0.5, b=-0.2, poro=0.2, perm=10, sigma_costau=30)
    check_table(wo.table)

    # Sample numerical tests taken from a prior implementation
    # NB: Prior implementation created Pc in atm, we create in bar
    bar_to_atm = 1.0 / 1.01325
    wo.add_normalized_J(a=0.22, b=-0.5, perm=100, poro=0.2, sigma_costau=30)
    float_df_checker(wo.table, "sw", 0.1, "pc", 2.039969 * bar_to_atm)
    float_df_checker(wo.table, "sw", 0.6, "pc", 0.056666 * bar_to_atm)
    float_df_checker(wo.table, "sw", 1.0, "pc", 0.02040 * bar_to_atm)