示例#1
0
def test_minimal_well():
    """Test a dummy well dataset

    |    segidx 1

    """
    one_seg = pd.DataFrame(
        {"SEGIDX": [1], "SEGNXT": [None], "SEGBRNO": [1], "SEGPRES": [195.8]}
    )
    with pytest.raises(ValueError, match="Insufficient topology"):
        rft.process_seg_topology(one_seg.drop("SEGIDX", axis="columns"))

    m_one_seg = rft.process_seg_topology(one_seg)
    assert m_one_seg["LEAF"][0]
    assert len(m_one_seg) == 1
    assert rft.count_wellbranches(one_seg) == 1
    assert rft.split_seg_icd(one_seg)[1].empty

    con_data = pd.DataFrame({"CONSEGNO": [1], "PRESSURE": [200.1], "CONPRES": [196.0]})
    con_seg = rft.merge_icd_seg_conseg(con_data, m_one_seg)
    assert len(con_seg) == 1
    assert "CONSEGNO" in con_seg
    assert "SEGIDX" in con_seg
    con_seg = rft.add_extras(con_seg)
    assert "COMPLETION_DP" in con_seg
    assert con_seg["COMPLETION_DP"].values[0] == 196.0 - 195.8
    assert con_seg["DRAWDOWN"].values[0] == 200.1 - 196.0
    assert rft.seg2dicttree(m_one_seg) == {1: {}}
    print(rft.pretty_print_well(m_one_seg))
示例#2
0
def test_minimal_branched_well():
    r"""
     |       segidx 1
    / \      segidx 2 and 3
    """
    two_branch = pd.DataFrame({
        "SEGIDX": [1, 2, 3],
        "SEGNXT": [None, 1, 1],
        "SEGBRNO": [1, 1, 2]
    })
    con_data = pd.DataFrame({
        "CONSEGNO": [2, 3],
        "PRESSURE": [301, 302],
        "CONPRES": [291, 292]
    })
    m_two_branch = rft.process_seg_topology(two_branch)
    assert len(m_two_branch) == 4  # One extra row for the junction segment
    assert sum(m_two_branch["LEAF"]) == 2
    assert rft.count_wellbranches(m_two_branch) == 2
    assert rft.split_seg_icd(two_branch)[1].empty
    con_seg = rft.merge_icd_seg_conseg(con_data, m_two_branch)

    # Junction segment has no reservoir connection and is not included
    # in the merge.
    assert len(con_seg) == 2

    assert rft.seg2dicttree(m_two_branch) == {1: {2: {}, 3: {}}}
    # Junction segment points to two upstream segments:
    assert set(m_two_branch[m_two_branch["SEGIDX"] == 1]
               ["SEGIDX_upstream"].astype(int)) == {2, 3}
    assert int(m_two_branch.loc[0, "SEGIDX_upstream"]) == 2
    assert int(m_two_branch.loc[1, "SEGIDX_upstream"]) == 3
示例#3
0
def test_longer_branched_icd_well():
    r"""Test a well with two connections on each of two laterals,
    with an ICD segment for each connection

           |          segidx 1
      * - / \ - *     segidx 4 and 2 (lateral1) and 6 and 8
      * - | | - *     segidx 5 and 3 (lateral1) and 7 and 9

    """
    wellseg = {
        "SEGIDX": [1] + [2, 3, 4, 5] + [6, 7, 8, 9],
        "SEGNXT": [None] + [1, 2, 2, 3] + [1, 6, 6, 7],
        "SEGBRNO": [1] + [1, 1, 3, 4] + [2, 2, 5, 6],
    }

    # Shuffle the segment list randomly, that should not matter:
    shuffled = list(range(9))
    random.shuffle(shuffled)
    print(shuffled)
    wellseg = pd.DataFrame(
        {segname: [wellseg[segname][idx] for idx in shuffled] for segname in wellseg}
    )

    con_data = pd.DataFrame(
        {
            "CONSEGNO": [4, 5, 8, 9],
            "PRESSURE": [301, 302, 401, 402],
            "CONPRES": [291, 292, 392, 393],
        }
    )
    seg_data = rft.process_seg_topology(wellseg)
    assert sum(seg_data["LONELYSEG"]) == 4
    assert sum(seg_data["LEAF"]) == 4
    assert sum(seg_data["JUNCTION"]) == 6  # 1, 2 and 6 counted twice
    assert sum(seg_data["LEAF"]) == 4
    (seg_data, icd_data) = rft.split_seg_icd(wellseg)
    print(rft.seg2dicttree(wellseg))
    print(rft.pretty_print_well(wellseg))

    assert len(icd_data) == 4
    assert all(icd_data.columns.str.startswith("ICD"))
    assert set(icd_data["ICD_SEGIDX"].values) == {4, 5, 8, 9}
    assert set(icd_data["ICD_SEGBRNO"].values) == {3, 4, 5, 6}
    assert all(icd_data["ICD_SEGBRNO_upstream"].values == [0, 0, 0, 0])

    print(seg_data)
    assert rft.count_wellbranches(seg_data) == 2

    con_seg = rft.merge_icd_seg_conseg(con_data, seg_data, icd_data)
    print(con_seg)
    assert len(con_seg) == 4
    con_seg = rft.add_extras(con_seg)
    assert all(con_seg["DRAWDOWN"].values == [10, 10, 9, 9])