def test_branched_icd_well(): r"""Simplest possible branched well with ICD segments | segidx 1 * - / \ - * segidx 2 and 3 """ wellseg = pd.DataFrame({ "SEGIDX": [1, 2, 3, 4, 5], "SEGNXT": [None, 1, 1, 2, 3], "SEGBRNO": [1, 1, 2, 3, 4], }) con_data = pd.DataFrame({ "CONSEGNO": [4, 5], "PRESSURE": [301, 302], "CONPRES": [291, 292] }) (seg_data, icd_data) = rft.split_seg_icd(wellseg) print(rft.seg2dicttree(wellseg)) print(rft.pretty_print_well(wellseg)) assert len(icd_data) == 2 assert all(icd_data.columns.str.startswith("ICD")) assert all(icd_data["ICD_SEGIDX"].values == [4, 5]) assert all(icd_data["ICD_SEGBRNO"].values == [3, 4]) assert all(icd_data["ICD_SEGBRNO_upstream"].values == [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) == 2 con_seg = rft.add_extras(con_seg) assert all(con_seg["DRAWDOWN"].values == [10, 10])
def test_minimal_well(): """Test a dummy well dataset | segidx 1 """ one_seg = pd.DataFrame({ "SEGIDX": [1], "SEGNXT": [None], "SEGBRNO": [1], "SEGPRES": [195.8] }) 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))
def test_single_branch_partly_icd(): r""" Test that we are able to untangle segment dataframes with ICDs modelled as individual branches, but not on all reservoir connections Single branch well, one mother segment, two connections, one icd to one connection: | segidx 1 | - * segidx 2 and 4 (icd), and reservoir | * segidx 3, and reservoir legend: | = tubing - = icd * = reservoir connection This is the same layout as | segidx 1 | segidx 2 / \ segidx 3 and 4 * * which is a two-branch well. It is not possible to separate these two based on topology. Current code interprets the topology as the latter case. The ambiguity arises due to the assumption that ICD segments are on their on branches with only one segment. In real modelled wells, this assumption will be valid, as the tubing segments will consist of more segments than 1 (except corner cases) (check the LONELYSEG segment toplogy metadata column which is used in determining whether a segment is ICD or not) """ wellseg = pd.DataFrame({ "SEGIDX": [1, 2, 3, 4], "SEGNXT": [None, 1, 2, 2], "SEGBRNO": [1, 1, 1, 2] }) con_data = pd.DataFrame({ "CONSEGNO": [4, 3], "PRESSURE": [301, 302], "CONPRES": [291, 292] }) (seg_data, icd_data) = rft.split_seg_icd(wellseg) print(rft.seg2dicttree(wellseg)) print(rft.pretty_print_well(wellseg)) assert rft.count_wellbranches(seg_data) == 2 assert len(icd_data) == 0 con_seg = rft.merge_icd_seg_conseg(con_data, seg_data, icd_data) assert len(con_seg) == 2 con_seg = rft.add_extras(con_seg) assert all(con_seg["DRAWDOWN"].values == [10, 10])
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])
def test_longer_branched_partly_icd_well(): r"""Test a well with two connections on each of two laterals, with an ICD segment for each connection only on the first lateral | segidx 1 * - / \ * segidx 4 and 2 (lateral1) and 6 and * - | | * segidx 5 and 3 (lateral1) and 7 and """ wellseg = pd.DataFrame( { # [wellhead] + [lateral 1, tubing, then icd layer] + [lateral 2] "SEGIDX": [1] + [2, 3, 4, 5] + [6, 7], "SEGNXT": [None] + [1, 2, 2, 3] + [1, 6], "SEGBRNO": [1] + [1, 1, 3, 4] + [2, 2], } ) con_data = pd.DataFrame( { "CONSEGNO": [4, 5, 6, 7], "PRESSURE": [301, 302, 401, 402], "CONPRES": [291, 292, 392, 393], } ) (seg_data, icd_data) = rft.split_seg_icd(wellseg) print() print(seg_data) print(rft.seg2dicttree(wellseg)) print(rft.pretty_print_well(wellseg)) assert len(icd_data) == 2 assert all(icd_data.columns.str.startswith("ICD")) assert set(icd_data["ICD_SEGIDX"].values) == {4, 5} assert set(icd_data["ICD_SEGBRNO"].values) == {3, 4} assert all(icd_data["ICD_SEGBRNO_upstream"].values == [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])
def test_single_branch_icd(): """ Test that we are able to untangle segment dataframes with ICDs modelled as individual brances. """ # Single branch well, one mother segment, two connections, # one icd to each connection: # | segidx 1 # | - * segidx 2 and 4, and reservoir # | - * segidx 3 and 5, and reservoir # legend: | = tubing # - = icd # * = reservoir connection wellseg = pd.DataFrame({ "SEGIDX": [1, 2, 3, 4, 5], "SEGNXT": [None, 1, 2, 2, 3], "SEGBRNO": [1, 1, 1, 2, 3], }) con_data = pd.DataFrame({ "CONSEGNO": [4, 5], "PRESSURE": [301, 302], "CONPRES": [291, 292] }) (seg_data, icd_data) = rft.split_seg_icd(wellseg) print(rft.seg2dicttree(wellseg)) print(rft.pretty_print_well(wellseg)) assert rft.count_wellbranches(seg_data) == 1 assert len(icd_data) == 2 assert all(icd_data.columns.str.startswith("ICD")) assert all(icd_data["ICD_SEGIDX"].values == [4, 5]) assert all(icd_data["ICD_SEGBRNO"].values == [2, 3]) assert all(icd_data["ICD_SEGBRNO_upstream"].values == [0, 0]) con_seg = rft.merge_icd_seg_conseg(con_data, seg_data, icd_data) assert len(con_seg) == 2 con_seg = rft.add_extras(con_seg) assert all(con_seg["DRAWDOWN"].values == [10, 10])